Learn how to create custom profiles to tailor CopyTree's file selection for your specific needs.
The default profile works great for general use, but you might want a custom profile to:
- Focus on specific features or modules (e.g., only authentication code)
- Apply transformers (extract text from PDFs, run OCR on images)
- Include external sources (GitHub repos, other directories)
- Override default exclusions (include lock files, test files, etc.)
- Share team configurations (commit profiles to version control)
A profile is a YAML file that tells CopyTree:
- Which files to include
- Which files to exclude
- Which transformers to apply
- Where to find external sources
Let's create a profile that focuses on your project's documentation.
Profiles can be stored in three locations, with this search order:
- Project:
.copytree/(committed with your code) - User:
~/.copytree/profiles/(personal, available globally) - Built-in:
profiles/(comes with CopyTree)
For this tutorial, we'll create a project profile:
# In your project root
mkdir -p .copytree
# Create the profile file
touch .copytree/docs-only.ymlEdit .copytree/docs-only.yml:
name: docs-only
description: Include only documentation files
version: 1.0.0
# Include patterns (glob syntax)
include:
- "**/*.md" # All Markdown files
- "docs/**/*" # Everything in docs directory
- "README*" # README files
- "CHANGELOG*" # Changelog files
# Exclude patterns
exclude:
- "node_modules/**" # Never include dependencies
- "**/test/**" # Skip test documentationPreview what files will be selected:
copytree --profile docs-only --dry-runThis shows which files match your rules without actually copying.
# Copy to clipboard
copytree --profile docs-only
# Display in terminal
copytree --profile docs-only --display
# Save to file
copytree --profile docs-only --output documentation.mdSuccess! You've created and used your first custom profile.
Focus on implementation files:
name: source-only
description: Source code without tests or config
include:
- "src/**/*.{js,jsx,ts,tsx}"
- "lib/**/*.{js,ts}"
- "*.{js,ts}"
exclude:
- "**/*.test.{js,ts}"
- "**/*.spec.{js,ts}"
- "**/__tests__/**"
- "**/*.config.{js,ts}"
always:
- "package.json"
- "tsconfig.json"API endpoints and schemas:
name: api-docs
description: API routes, controllers, and schemas
include:
- "src/routes/**/*"
- "src/controllers/**/*"
- "src/models/**/*"
- "src/middleware/**/*"
- "**/*.swagger.{yml,yaml,json}"
- "**/*.openapi.{yml,yaml,json}"
exclude:
- "**/*.test.*"
always:
- "package.json"
- "README.md"React/Vue components:
name: components
description: Frontend components and styles
include:
- "src/components/**/*"
- "src/pages/**/*"
- "src/styles/**/*"
- "**/*.{jsx,tsx,vue}"
- "**/*.{css,scss,sass}"
exclude:
- "**/*.test.{jsx,tsx}"
- "**/*.spec.{jsx,tsx}"
- "**/*.stories.{jsx,tsx}"
always:
- "package.json"
- "tailwind.config.js"Add transformers to handle file loading:
name: with-transformers
description: Profile with file loading
include:
- "**/*.{md,txt,js,ts}"
- "docs/**/*"
transformers:
# Load file content
file-loader:
enabled: trueBuilt-in transformers:
- file-loader: Loads text file content
- binary: Handles binary files (placeholder or base64)
- streaming-file-loader: Streams large files (>10MB)
Extend existing profiles:
name: my-docs
description: Docs profile based on default
extends: default
# Additional includes (merged with parent)
include:
- "examples/**/*"
- "tutorials/**/*"
# Additional excludes (merged with parent)
exclude:
- "**/*.draft.md"
- "docs/archive/**"Include files from other locations:
name: with-external
description: Include files from external sources
include:
- "src/**/*"
external:
# Include from GitHub
- source: https://github.com/user/shared-docs
destination: external/shared
rules:
- include: "**/*.md"
# Include from local directory
- source: /path/to/shared/library
destination: external/lib
rules:
- include: "**/*.js"
- exclude: "**/node_modules/**"CopyTree processes rules in this order:
- Initial Discovery - Find all files in directory
- Exclude Rules - Remove excluded files
- Include Rules - Keep only included files
- Always Rules - Force-include specific files
- Transformers - Process files as configured
Important: always rules override all exclusions.
include:
- "src/**/*.js"
exclude:
- "src/legacy/**"
always:
- "src/legacy/important.js" # Included despite exclude ruleChoose where to store your profiles based on usage:
Project profiles (.copytree/):
- Committed to version control
- Shared with team members
- Project-specific configurations
- Override user and built-in profiles
# Create project profile
mkdir -p .copytree
vi .copytree/myproject.ymlUser profiles (~/.copytree/profiles/):
- Personal configurations
- Available across all projects
- Not committed to repositories
# Create user profile
mkdir -p ~/.copytree/profiles
vi ~/.copytree/profiles/personal.ymlBuilt-in profiles (package installation):
- Shipped with CopyTree
- Read-only (do not modify)
- Used as base for inheritance
# Good - specific and focused
include:
- "src/auth/**/*.{js,ts}"
- "src/auth/**/*.test.{js,ts}"
# Avoid - too broad, then exclude
include:
- "**/*"
exclude:
- "everything/you/dont/want/**"# Good names
name: react-components
name: api-documentation
name: test-files
# Avoid generic names
name: my-profile
name: custom
name: testAlways include a description:
name: feature-payment
description: |
Payment feature files including:
- Stripe integration
- Payment components
- Related tests and docs
version: 1.0.0Always preview before copying:
# Preview selection
copytree --profile myprofile --dry-run
# View in terminal first
copytree --profile myprofile --displayInclude profiles in version control when appropriate:
# .gitignore - DO commit project profiles
# (don't add .copytree/ to .gitignore)
# Commit to share with team
git add .copytree/
git commit -m "Add CopyTree profiles for documentation and API"Check search paths:
# Check specific locations
ls .copytree/ # Project profiles
ls ~/.copytree/profiles/ # User profilesRules might be too restrictive:
# Use dry-run mode to debug
copytree --profile myprofile --dry-run
# This shows:
# - Which rules matched
# - Which files were excluded
# - Final file countCheck YAML syntax:
# Common issues:
# - Incorrect indentation (use spaces, not tabs)
# - Missing colons after keys
# - Quotes in wrong placesNow that you can create custom profiles:
-
Configuration Reference - Project-wide and global settings
-
Basic Usage - Common workflows and patterns
-
CLI Reference - All command-line options
# Profile usage
copytree --profile <name> --dry-run # Preview file selection
# Using profiles
copytree --profile myprofile # Use custom profile
copytree --profile default # Explicit default
copytree # Implicit default
# Profile locations
.copytree/ # Project profiles (committed)
~/.copytree/profiles/ # User profiles (personal)
<install>/profiles/ # Built-in profiles (read-only)Well done! You now know how to create custom profiles to tailor CopyTree for any project or use case.