This guide covers the fundamental usage patterns of CopyTree for everyday development tasks.
First, verify CopyTree is installed correctly:
# Check version
copytree --version
# View help
copytree --helpThe simplest use case - copy your current project to clipboard:
# Copy current directory
copytree
# Copy specific directory
copytree /path/to/project
# Copy and display in terminal
copytree --displayProfiles are the heart of CopyTree's intelligent file selection. CopyTree includes a default profile that works for most projects, or you can create custom profiles for specific needs.
CopyTree uses the following profile selection order:
- If
--profileflag is provided → use the specified profile - Else → use the built-in default profile automatically
# Use default profile (automatic)
copytree
# Explicitly specify default profile
copytree --profile default
# Use a custom profile
copytree --profile mycustomThe default profile provides sensible exclusions for common build artifacts, dependencies, and IDE files while including all source code and documentation.
Create custom profiles when you need to:
- Focus on specific file types or directories
- Apply transformers to certain files
- Include files from external sources
- Override default exclusion rules
# Use custom React profile
copytree --profile my-react
# Use custom API profile
copytree --profile api-docs
# Preview profile selection
copytree --profile api-docs --dry-runreact-components- Only React component filesapi-docs- API endpoints and schemasdocs-only- Documentation files onlyminimal-js- Essential JavaScript filesfull-stack- Both frontend and backend code
Use glob patterns to select specific files:
# Only JavaScript files
copytree --filter "*.js"
# Multiple patterns
copytree --filter "*.js" --filter "*.jsx"
# Complex patterns
copytree --filter "src/**/*.{js,ts}"Select files based on Git status:
# Only modified files
copytree --modified
# Files changed between commits
copytree --changed main..feature-branch
# Files changed in last 5 commits
copytree --changed HEAD~5..HEAD# Copy to clipboard
copytree
# Explicitly specify clipboard
copytree --clipboard# Save to specific file (defaults to xml)
copytree --output project-snapshot.xml
# Different formats
copytree --output snapshot.json --format json
copytree --output snapshot.md --format markdown# Display in terminal
copytree --display
# Display with syntax highlighting
copytree --display --format tree# Stream output (for piping)
copytree --stream | gzip > project.xml.gz
# Stream to another tool
copytree --stream | some-analysis-tool# Disable instructions in output
copytree --no-instructions
# Use custom instructions
copytree --instructions custom
# Use default instructions (explicit)
copytree --instructions defaultcopytree --format markdownOutput structure:
---
format: copytree-md@1
...
---
# CopyTree Export — project
## Directory Tree
```text
├── src/
└── README.md// File content here
### JSON
```bash
copytree --format json
Output structure:
{
"files": [
{
"path": "src/index.js",
"content": "// File content here"
}
]
}copytree --format treeOutput structure:
project/
├── src/
│ ├── index.js
│ └── components/
│ └── App.js
└── package.json
copytree --format xmlProduces XML metadata and files; useful when integrating with XML-based tooling.
# Copy project for AI analysis
copytree --profile my-react
# Copy with transformations (configured in profile)
copytree --profile my-react# Copy recent changes
copytree --modified
# Copy feature branch changes
copytree --changed main..feature/new-feature
# Include git status
copytree --with-git-status# Copy for documentation
copytree --profile docs-only
# Copy with file info
copytree --profile mycustom --show-size --with-line-numbers
# Tree structure only
copytree --profile mycustom --only-tree# Copy with line numbers
copytree --with-line-numbers
# Dry run to see what would be copied
copytree --dry-run# Limit characters per file
copytree --char-limit 5000
# Limit to first N files
copytree --head 50# Include line numbers
copytree --with-line-numbers
# Include file sizes
copytree --show-size
# Include git status
copytree --with-git-status
# Show file info table
copytree --infoTransformers are configured in profiles, not via CLI flags. To enable transformations like PDF-to-text or image OCR, configure them in your profile:
# In your profile (e.g., .copytree/myprofile.yml)
transformers:
pdf:
enabled: true
options:
maxPages: 50
image:
enabled: true
options:
extractText: trueThen use the profile:
copytree --profile myprofileBuilt-in transformers: file-loader, binary, streaming-file-loader.
# Copy from GitHub
copytree https://github.com/user/repo
# Specific branch
copytree https://github.com/user/repo/tree/develop
# Subdirectory
copytree https://github.com/user/repo/tree/main/srcCreate a profile with external sources:
name: with-docs
external:
- source: https://github.com/org/docs
destination: docs/external
rules:
- "*.md"
- "**/*.md"# Better performance
copytree --profile api
# Than generic
copytree --profile full# Focus on specific directories
copytree src/ --profile react
# Limit number of files
copytree --head 100# Skip cache for fresh results
copytree --no-cache# Dry run
copytree --dry-run
# Validate profile
copytree --validate --profile myprofile# Check configuration
copytree config:validate
# Inspect configuration with provenance
copytree config:inspect- Nothing copied: Check if files match profile rules
- Too many files: Use more specific profile or filters
- Missing files: Check .copytreeignore and gitignore
- Slow performance: Limit scope with
--heador disable cache with--no-cache
- Create Your First Profile - Custom file selection
- Claude Code Integration - Use with Claude Code
- Configuration Reference - Project-wide settings