Skip to main content

CopyTree

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

Updated
Reviewed

What is CopyTree?

CopyTree builds a structured snapshot of your codebase and copies it to your clipboard. Paste the output wherever you need it: an agent terminal, the Portal, ChatGPT, Gemini, or any tool that takes text input. You don't have to copy files one at a time or describe your project structure in prose. CopyTree produces a formatted representation an agent can read directly.

Quick Start

The main 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

The Copy Context button in the toolbar copies the full context in one click. The keyboard shortcut Cmd+Shift+C does the same for the active worktree.

Tip
The toolbar button and keyboard shortcut always copy full context. To copy only modified files, use the worktree card menu.

Copy Modes

CopyTree has two modes, one for each stage of the workflow.

Full Context

Copies every file that matches your filter settings. Use this when you start a new session, ask architectural questions, or onboard an agent to a project. The agent gets a complete picture of the codebase.

Modified Files Only

Copies only git-tracked files with staged or unstaged changes. The snapshot stays focused on what you've actually been working on. Use it for iterative work, when the agent already has the broader context.

Choosing Modified Files Only from the menu applies the modified-only filter on top of any other filters configured in your project settings.

Note
Untracked new files, ones you haven't 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 know what's happening. This matters most on 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 shows progress too. It displays a spinner while generating, then a checkmark with the result for two seconds after it finishes.

Tip
The success toast reports file count and size. Read it as a quick token-budget check before you send the context to an agent.

Output Formats

CopyTree writes the output in one of two formats:

  • XML: structured tags wrapping file contents, suited to AI consumption
  • Markdown: human-readable, with each file in a code block

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

These filters control what ends up in the output:

FilterDescription
Include pathsInclude only files matching these glob patterns.
Exclude pathsSkip files matching these patterns (e.g., node_modules, .git).
Always includeGlob patterns for files included regardless of other filters.
Always excludeGlob patterns for files excluded regardless of other filters.
Modified onlyInclude only files with uncommitted changes.
Changed since branchInclude only files changed since the worktree forked from a base branch.

CopyTree also reads your project's .gitignore and .copytreeignore files and honors them.

Limits

Set limits to keep the output size in check:

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

Options

  • Sort: set the file ordering in the output (by path, size, modified date, name, or extension)
  • Line numbers: add line numbers to file contents so an agent can reference exact lines
  • Dry run: preview what would be included without generating the full output

File Tree View

CopyTree can also generate a file tree view of your project structure. It gives an agent a quick overview of how the codebase is organized before it reads 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, which holds all the filtering, limit, and format options described above.

Testing Your Config

Use dry run to test a CopyTree configuration before you generate the full output. It reports which files would be included and the estimated output size without generating anything. The Test Config button in the settings panel runs the same 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 check that your filters and limits are catching the right files at a reasonable size.