Complete reference for CopyTree configuration system, including precedence rules, environment variables, and profile configuration.
CopyTree uses a simple two-level configuration system:
User config > Default config
Settings are loaded from:
- Built-in defaults from
config/*.jsfiles - User overrides from
~/.copytree/*.jsor~/.copytree/*.jsonfiles
The two levels are deeply merged, with user configuration overriding defaults.
# Default config (config/app.js)
maxFileSize: 10MB
# User config (~/.copytree/app.js)
maxFileSize: 20MB
# Effective value: 20MB (user config wins)Built-in defaults (lowest precedence):
{
maxFileSize: 10485760, // 10MB
maxTotalSize: 104857600, // 100MB
maxFileCount: 10000,
respectGitignore: true,
includeHidden: false,
followSymlinks: false,
defaultProfile: 'default',
cacheEnabled: true,
cacheTTL: 3600000 // 1 hour
}Global settings for all projects:
Location: ~/.copytree/*.js or ~/.copytree/*.json
JavaScript Format:
// ~/.copytree/app.js
export default {
maxFileSize: 20971520, // 20MB
maxTotalSize: 209715200, // 200MB
respectGitignore: true,
includeHidden: false,
// Default profile for all projects
defaultProfile: 'default',
// Cache settings
cache: {
enabled: true,
ttl: 3600000, // 1 hour
directory: '~/.copytree/cache'
}
};JSON Format:
{
"maxFileSize": 20971520,
"maxTotalSize": 209715200,
"respectGitignore": true,
"includeHidden": false,
"defaultProfile": "default",
"cache": {
"enabled": true,
"ttl": 3600000,
"directory": "~/.copytree/cache"
}
}Note: Configuration file names must match the config section name (e.g., app.js, ai.js).
| Config Key | CLI Flag | Type | Default | Description |
|---|---|---|---|---|
maxFileSize |
N/A | bytes | 10485760 | Maximum single file size |
maxTotalSize |
N/A | bytes | 104857600 | Maximum total size of all files |
maxFileCount |
--limit |
number | 10000 | Maximum number of files |
defaultProfile |
--profile |
string | default |
Default profile to use |
respectGitignore |
N/A | boolean | true |
Respect .gitignore rules |
includeHidden |
N/A | boolean | false |
Include hidden files |
followSymlinks |
--follow-symlinks |
boolean | false |
Follow symbolic links |
cache.enabled |
N/A | boolean | true |
Enable caching |
cache.ttl |
N/A | milliseconds | 3600000 | Cache time-to-live |
Profiles control file selection. See Your First Custom Profile for details.
1. CLI --profile flag
2. User config defaultProfile
3. Built-in default profile (automatic)
Example:
# 1. CLI flag (highest precedence)
copytree --profile api-docs
# 2. User config
# ~/.copytree/app.js
export default {
defaultProfile: 'api-docs'
};
# 3. Built-in default (automatic)
copytree # Uses built-in default profileWhen loading a profile by name, CopyTree searches in this order:
1. Project: .copytree/<name>.yml
2. User: ~/.copytree/profiles/<name>.yml
3. Built-in: <install>/profiles/<name>.yml
Transformers handle file loading and processing. The built-in transformers include:
- file-loader: Loads file content
- binary: Handles binary files with placeholder or base64 encoding
- streaming-file-loader: Streams large files (>10MB) for memory efficiency
# In profile file (.copytree/myprofile.yml)
transformers:
file-loader:
enabled: trueCheck your effective configuration:
# Validate syntax and values
copytree config:validate
# Show configuration with sources
copytree config:inspectExample output:
Configuration Validation: ✓ Valid
Effective Configuration:
maxFileSize: 20971520 (20MB)
Source: User config (~/.copytree/app.js)
maxTotalSize: 104857600 (100MB)
Source: Default config
defaultProfile: "myproject"
Source: User config (~/.copytree/app.js)
respectGitignore: true
Source: Default config
cache.enabled: true
Source: Default config
Valid configuration options:
# File size limits
maxFileSize: 10485760 # Maximum single file size (bytes)
maxTotalSize: 104857600 # Maximum total size of all files (bytes)
maxFileCount: 10000 # Maximum number of files to process
# File discovery
respectGitignore: true # Respect .gitignore rules
includeHidden: false # Include hidden files (starting with .)
followSymlinks: false # Follow symbolic links
# Default behavior
defaultProfile: "default" # Default profile to use
defaultFormat: "xml" # Default output format (xml, json, markdown, tree)
# Cache configuration
cache:
enabled: true # Enable caching
ttl: 3600000 # Cache time-to-live (milliseconds)
directory: "~/.copytree/cache" # Cache directory
# Additional exclusions (merged with profile)
additionalExclusions:
- "vendor/**"
- "storage/**"
- "*.log"
# Performance
streaming:
enabled: false # Enable streaming mode
threshold: 10485760 # Stream files larger than this (bytes)
# Debug
verbose: false # Enable verbose logging
debug: false # Enable debug loggingOptimize for large codebases:
# .copytree/config.yml
maxFileSize: 52428800 # 50MB
maxTotalSize: 1073741824 # 1GB
maxFileCount: 50000
streaming:
enabled: true
threshold: 10485760 # Stream files >10MB
cache:
enabled: true
ttl: 7200000 # 2 hoursStandardize settings via shared profile:
# .copytree/team-standard.yml (committed to repo)
name: team-standard
description: Team standard profile
include:
- "src/**"
- "docs/**"
exclude:
- "vendor/**"
- "storage/**"
- "coverage/**"
- "*.log"
transformers:
file-loader:
enabled: trueNote: Configuration files (not profiles) cannot be shared at the project level. Use profiles for team standardization.
Use CLI flags for CI environments:
# CI script
copytree --profile ci-minimal --displaySet personal preferences globally:
// ~/.copytree/app.js
export default {
defaultProfile: 'mydefault',
defaultFormat: 'markdown',
maxFileSize: 52428800, // 50MB
cache: {
enabled: true,
ttl: 14400000 // 4 hours
},
// Prefer hidden files for my workflow
includeHidden: true
};Location: ~/.copytree/*.json
{
"maxFileSize": 20971520,
"defaultProfile": "myproject",
"cache": {
"enabled": true,
"ttl": 3600000
}
}Location: ~/.copytree/*.js
// ~/.copytree/app.js
export default {
maxFileSize: 20 * 1024 * 1024, // 20MB
defaultProfile: 'myproject',
cache: {
enabled: true,
ttl: 60 * 60 * 1000, // 1 hour
},
// Dynamic configuration
additionalExclusions: process.env.NODE_ENV === 'production'
? ['test/**', '**/*.test.js']
: [],
};Note: Configuration files must use ES module syntax (export default) and match the config section name.
See which settings are active and their sources:
copytree config:inspectEnsure configuration is valid:
copytree config:validateEnable verbose logging:
DEBUG=copytree:config copytree config:inspect"Configuration validation failed"
Check YAML/JSON syntax:
# Validate just the syntax
copytree config:validate
# Common issues:
# - Incorrect indentation (YAML)
# - Missing commas (JSON)
# - Invalid values (e.g., strings for numbers)"User config not loading"
Check file location and format:
# Must be in ~/.copytree/ directory
ls ~/.copytree/app.js
ls ~/.copytree/app.json
# Check file has proper ES module export (for .js files)
# Must use: export default { ... }
# Not: module.exports = { ... }
# File name must match config section
# app.js for app config
# ai.js for AI configCommit profiles to share team standards:
# .copytree/team-standard.yml (committed)
name: team-standard
description: Team standard profile
include:
- "src/**"
- "docs/**"
exclude:
- "vendor/**" # PHP dependencies
- "storage/**" # Laravel storage
- "coverage/**" # Test coverage
- "*.log"Keep personal settings in ~/.copytree/:
// ~/.copytree/app.js (not committed)
export default {
defaultFormat: 'markdown',
cache: {
ttl: 7200000 // I prefer longer cache
}
};# Try different settings without modifying config
copytree --profile test-profile --displayAdd comments to user config:
// ~/.copytree/app.js
export default {
// Prefer larger file size for my projects
maxFileSize: 20 * 1024 * 1024, // 20MB
// Always use my custom profile by default
defaultProfile: 'mydefault',
// Longer cache TTL for slower network
cache: {
enabled: true,
ttl: 4 * 60 * 60 * 1000 // 4 hours
}
};# Check configuration is valid
copytree config:validate
# Inspect effective configuration
copytree config:inspect- Your First Custom Profile - Creating custom profiles
- CLI Reference - Command-line options
- Troubleshooting Guide - Common issues and solutions