TouchFS Touch Command

The touchfs touch command provides an explicit way to mark files for content generation, equivalent to using the standard touch command within a TouchFS filesystem.

Usage

touchfs touch [options] file [file ...]

Options

Key Features

  1. Sets the generate_content xattr on files to mark them for generation
  2. Interactive mode for directory-based file creation
  3. Context-aware filename suggestions
  4. Handles multiple files in a single command
  5. Creates parent directories with --parents flag

Common Use Cases

Basic File Marking

# Mark a single file for generation
touchfs touch README.md

# Mark multiple files
touchfs touch app.py tests/test_app.py

Interactive Directory Mode

# Enter interactive mode for a directory
touchfs touch src/components

# This will:
# 1. Generate filename suggestions based on directory context
# 2. Display an interactive menu for selection
# 3. Allow multiple selections
# 4. Option to regenerate suggestions

Project Structure Creation

# Create and mark multiple related files
touchfs touch -p \
  src/models/user.py \
  src/models/product.py \
  tests/test_models.py

Non-TouchFS Usage

# Mark files outside TouchFS filesystem
touchfs touch --force external/file.txt

# Create with parent directories
touchfs touch -p -f new/project/setup.py

Context Generation

The command automatically builds context from the parent directory of the first specified file. This context is used for:

  1. Generating filename suggestions in interactive mode
  2. Understanding project structure for marking files
  3. Ensuring consistent file organization
# Files will be marked with awareness of existing project context
touchfs touch \
  src/components/NewFeature.tsx \  # Context from src/components/
  src/hooks/useNewFeature.ts \     # Uses same context
  tests/NewFeature.test.tsx        # Uses same context

Interactive Mode Features

When a single directory is provided as an argument, the command enters interactive mode:

  1. Filename Suggestions:

  2. Selection Menu:

  3. Iterative Creation:

Error Handling

Key Differences from Generate Command

The touch command differs from the generate command in several ways:

  1. Marking vs Generation: Only marks files for generation rather than generating content immediately
  2. TouchFS Integration: Designed to work within TouchFS filesystems
  3. Interactive Mode: Provides interactive directory-based file creation
  4. Filename Suggestions: Generates contextual filename suggestions
  5. Extended Attributes: Sets filesystem extended attributes for TouchFS processing

See Also