Skip to main content

CopyTree

Copy structured codebase snapshots to your clipboard for AI agents and tools.

Updated
Reviewed

What is CopyTree?

CopyTree generates structured snapshots of your codebase and copies them to your clipboard. Paste the output wherever you need it: an agent terminal, the Portal, ChatGPT, Gemini, or any tool that accepts text input. Instead of manually copying files or describing your project structure, CopyTree produces a formatted representation that agents can immediately understand.

Quick Start

The primary way to copy context is through the worktree card menu:

  1. Click the button on a worktree card (or right-click the card directly)
  2. Hover Copy Context
  3. Choose Full Context or Modified Files Only

You can also use the Copy Context button in the toolbar for a quick full-context copy. The keyboard shortcut Cmd+Shift+C does the same thing for the active worktree.

Tip
The toolbar button and keyboard shortcut always copy full context. Use the worktree card menu when you want to copy only modified files.

Copy Modes

CopyTree offers two modes, each suited to a different stage of your workflow.

Full Context

Copies all files that match your filter settings. This is the right choice when you're starting a new session, asking architectural questions, or onboarding an agent to your project. It gives the agent a complete picture of the codebase.

Modified Files Only

Copies only git-tracked files with staged or unstaged changes. This keeps the snapshot focused on what you've actually been working on, which is useful for iterative work where the agent already has broader context.

Choosing Modified Files Only from the menu applies the modified-only filter automatically, alongside any other filters you've configured in your project settings.

Note
Untracked new files (not yet staged with git add) are not included in Modified Files Only snapshots. Stage them first if you want them in the output.

Progress and Completion Feedback

CopyTree shows toast notifications so you always know what's happening, especially useful for larger codebases where generation takes a moment.

StateWhat you seeDuration
In progress"Copying context…" or "Copying modified files…"Stays until complete
Success"Copied N files (X.X KB) as FORMAT to clipboard"3 seconds
No files"No files to copy"3 seconds
Error"Copy context failed: [reason]"5 seconds

The toolbar button also reflects progress visually: it shows a spinner while generating and a checkmark with the result for two seconds after completion.

Tip
The success toast reports file count and size. Use it as a quick token-budget signal before sending context to an agent.

Output Formats

CopyTree supports two output formats:

  • XML — structured tags wrapping file contents, ideal for AI consumption
  • Markdown — human-readable format with code blocks

XML Example

<project name="my-app">
  <file path="src/auth/provider.ts">
import { createContext, useContext } from 'react';
import { AuthConfig } from './types';

export const AuthContext = createContext<AuthConfig | null>(null);

export function AuthProvider({ children }: Props) {
  // ...
}
  </file>
  <file path="src/auth/oauth.ts">
export async function handleOAuthCallback(code: string) {
  const token = await exchangeCode(code);
  return createSession(token);
}
  </file>
  <file path="src/hooks/useAuth.ts">
import { useContext } from 'react';
import { AuthContext } from '../auth/provider';

export function useAuth() {
  return useContext(AuthContext);
}
  </file>
</project>

Markdown Example

# Project: my-app

## src/auth/provider.ts

```typescript
import { createContext, useContext } from 'react';
import { AuthConfig } from './types';

export const AuthContext = createContext<AuthConfig | null>(null);
```

## src/auth/oauth.ts

```typescript
export async function handleOAuthCallback(code: string) {
  const token = await exchangeCode(code);
  return createSession(token);
}
```

Filtering

Control what's included in the output with these filters:

FilterDescription
Include pathsOnly include files matching these glob patterns.
Exclude pathsSkip files matching these patterns (e.g., node_modules, .git).
Always includeGlob patterns for files that are always included regardless of other filters.
Always excludeGlob patterns for files that are always excluded regardless of other filters.
Modified onlyOnly include files with uncommitted changes.
Changed since branchOnly include files changed since forking from a base branch.

CopyTree also respects your project's .gitignore and .copytreeignore files automatically.

Limits

Set limits to control output size:

  • Character limit — maximum total characters in the output
  • Max file size — skip individual files larger than this
  • Max total size — overall size cap across all files
  • Max file count — limit the number of files included

Options

  • Sort — control file ordering in the output (by path, size, modified date, name, or extension)
  • Line numbers — add line numbers to file contents for precise referencing
  • Dry run — preview what would be included without generating full output

File Tree View

CopyTree can also generate a file tree view showing your project structure. This gives agents a quick overview of how the codebase is organized before diving into specific files.

Per-Project Configuration

CopyTree settings are stored per-project, so each repository gets its own include/exclude patterns and limits. Configure them in Project Settings → Context, where you'll find all the filtering, limit, and format options described above.

Testing Your Config

Use dry run to test your CopyTree configuration before generating full output. It shows which files would be included and the estimated output size without actually generating anything. You can also use the Test Config button in the settings panel to run a dry-run preview directly from the configuration screen.

Tip
Run a test before your first full copy on a large project. It's a quick way to check that your filters and limits are capturing the right files at a reasonable size.