Gather code into your clipboard in a shape that is convenient to paste into a chat with an LLM. Right-click files or folders in the Explorer, highlight a block in the editor, or grab a Git diff — the extension formats what you picked, with file paths and fenced code blocks, and puts it on the clipboard.
It can also route file contents through RTK, a command-line tool that strips code down to a more compact representation before it reaches your context window. RTK reports token reductions in the region of 60–90% on typical source files; that figure is RTK's own measurement of its compression, not a benchmark of this extension.
Attribution
This project is a fork of Copy to LLM by
Tomasz Kasperczyk, used under the MIT license. The copy, selection and diff functionality is his
work. What this fork adds is the RTK integration: detection of the rtk binary, parallel
compressed reads, and the "Copy Compressed Context" command. The original extension is a separate
project, is not affiliated with this one, and remains available under its own name.
RTK itself is a separate MIT-licensed project by the RTK authors and is not bundled with this extension — you install it yourself if you want the compression command.
Requirements
The plain copy commands work on their own. For the compressed command you need the rtk binary on
your PATH; see the RTK installation instructions. If rtk is
not found, the extension falls back to copying uncompressed contents.
Commands
All commands are prefixed RTK Copier in the Command Palette.
| Command | What it does |
|---|---|
| Copy Files as Context | Copies the selected files, or every matching file in the selected folders |
| Copy Selection as Context | Copies the highlighted blocks, each annotated with its path and line range |
| Copy Git Diff as Context | Copies the diff for the selected files, submodules included |
| Copy Compressed Context (RTK) | Copies file contents after passing them through rtk read |
The file and compressed commands also appear in the Explorer context menu, the selection command in the editor context menu, and the diff command in the Source Control view.
Settings
| Setting | Default | Purpose |
|---|---|---|
rtkContextCopier.extensions |
a list of common source extensions | Which files to include when you copy a whole directory |
rtkContextCopier.useRelativePaths |
false |
Label each file with its path relative to the project root |
rtkContextCopier.showPreview |
true |
Open the formatted result in a new tab as well as copying it |
rtkContextCopier.ignore |
[] |
Glob patterns to skip |
Example:
"rtkContextCopier.extensions": [".ts", ".tsx", ".py"],
"rtkContextCopier.useRelativePaths": true,
"rtkContextCopier.ignore": ["**/node_modules/**", "**/*.lock"]
Output shape
Uncompressed output is a sequence of labelled, fenced blocks, one per file. Compressed output is wrapped so the model can tell it has been through RTK:
<context compressed="true">
<file src="src/utils/format.ts">...</file>
</context>
Contributing
Issues and pull requests are welcome at luutuankiet/vscode-rtk-context-copier. Please report problems here rather than to the upstream project, which does not include the RTK integration.
License
MIT — see LICENSE. Copyright is held by Tomasz Kasperczyk for the original work and by Tuan Kiet Luu for the modifications in this fork.