Skip to content

Latest commit

 

History

History
335 lines (241 loc) · 5.98 KB

File metadata and controls

335 lines (241 loc) · 5.98 KB

CopyTree CLI Reference

Basic Usage

copytree [path] [options]

Arguments:

  • path - Directory path or GitHub URL to copy (defaults to current directory)

Command Options

Profile Options

--profile=<name>, -p <name>

Use a specific profile for file selection. If omitted, CopyTree uses the default profile.

Examples:

copytree --profile mycustom
copytree -p mycustom

Note: The default profile is automatically used when no profile is specified. Create custom profiles in ~/.copytree/profiles/ or .copytree/ for project-specific needs.

Filter Options

--filter=<pattern>, -f <pattern>

Include files matching glob patterns. Can be used multiple times.

copytree --filter "*.js" --filter "*.ts"
copytree -f "src/**/*.php" -f "tests/**/*.php"

--modified, -m

Only include files modified since the last Git commit.

copytree --modified
copytree -m

--changed=<ref>, -c <ref>

Include files changed since a specific Git reference (commit, branch, or tag).

copytree --changed HEAD~5
copytree -c main
copytree --changed v1.0.0

Output Options

--output[=<file>], -o [<file>]

Save output to a file.

copytree --output output.xml
copytree -o output.xml

--display, -i

Display output in console instead of copying to clipboard.

copytree --display
copytree -i

--stream, -S

Stream output without buffering (useful for piping).

copytree --stream | less
copytree -S > project.xml

--clipboard

Explicitly copy to clipboard (default behavior).

copytree --clipboard

Format Options

--format=<type>

Output format: xml, markdown|md, json, ndjson, sarif, or tree.

Default: xml

copytree --format json
copytree --format ndjson
copytree --format sarif
copytree --format tree
copytree --format xml  # default
copytree --format markdown

Display Control Options

--head=<number>, -l <number>

Limit to first N files processed.

copytree --head 50
copytree -l 100

--char-limit=<number>, -C <number>

Character limit for total output.

copytree --char-limit 100000
copytree -C 50000

--only-tree, -t

Show only directory structure, no file contents.

copytree --only-tree
copytree -t

Sorting & Git Status Options

--sort=<by>, -s <by>

Sort files by: path, size, modified, name, or extension.

copytree --sort modified
copytree --sort size
copytree -s name

--with-git-status

Include Git status indicators for each file.

copytree --with-git-status

--always=<patterns...>

Always include these patterns (force-include), even if excluded by profile.

copytree --always "*.config.js" --always "config.example.js"

Content Options

--with-line-numbers

Include line numbers in output.

copytree --with-line-numbers

--show-size

Show file sizes in output.

copytree --show-size

--info

Show information table with project statistics.

copytree --info

--include-binary

Include binary files in output (normally excluded).

copytree --include-binary

--dedupe

Remove duplicate files from output.

copytree --dedupe

--as-reference, -r

Generate reference documentation format.

copytree --as-reference
copytree -r

--external=<source...>

Include external sources (GitHub URLs or local paths).

copytree --external https://github.com/user/repo

Transformation Options

Note: Transformers are configured in profiles, not via CLI flags. Built-in transformers include file-loader, binary, and streaming-file-loader.

Debug & Optimization Options

--dry-run

Simulate execution without generating output.

copytree --dry-run

--validate

Validate profile syntax without processing files.

copytree --validate --profile myprofile

--no-cache

Disable caching for AI operations and external sources.

copytree --no-cache

--no-validate

Disable configuration validation (for testing/debugging).

copytree --no-validate

Instructions Options

--no-instructions

Disable including instructions in output.

copytree --no-instructions

--instructions=<name>

Use custom instructions set (default: default).

copytree --instructions custom
copytree --instructions default

Exit Codes

  • 0 - Success
  • 1 - Profile validation or loading errors
  • 2 - Invalid option combination
  • 3 - File system or Git errors

Examples

Basic Usage

# Copy current directory to clipboard
copytree

# Copy specific directory
copytree /path/to/project

# Copy from GitHub
copytree https://github.com/facebook/react

Using Profiles

# Uses default profile automatically
copytree

# Use custom profile
copytree --profile mycustom

# Preview profile selection
copytree --profile mycustom --dry-run

Filtering Files

# Pattern matching
copytree --filter "src/**/*.js" --filter "*.json"

# Git integration
copytree --modified
copytree --changed HEAD~5

Output Options

# Save to file (Markdown by default)
copytree --output project-snapshot.md

# Save as XML
copytree --output project-snapshot.xml --format xml

# Display in console
copytree --display

# Different formats
copytree --format json
copytree --format tree

Advanced Usage

# Combine multiple options
copytree --profile myproject --modified --output snapshot.md

# Dry run with validation
copytree --dry-run --validate

# Limit output
copytree --head 50 --char-limit 100000

# Stream large projects
copytree --stream | gzip > project.md.gz

Notes

  • The --validate option cannot be combined with output options or filters
  • External sources (GitHub URLs) are cached by default in ~/.copytree/repos/
  • Use DEBUG=copytree:* environment variable for detailed debugging