Zero Runtime Dependencies
Built with pure Node.js standard modules. No massive node_modules folder, no native binary compile issues, and instant cold start in CI.
FastPress Labs · Zero Dependencies · Apache-2.0
Zero-runtime-dependency CLI, Node.js library, and stdio MCP server. Pack full directories, subtrees, and Git diffs into Anthropic XML, Markdown, or llms-full.txt with strict token budgeting.
Test how ContextPack formats your code and estimates token consumption in real time right in your browser.
src/math.jsClick "Pack Context" above to format.
Built from scratch with zero bloat to serve the needs of engineers building with LLMs daily.
Built with pure Node.js standard modules. No massive node_modules folder, no native binary compile issues, and instant cold start in CI.
Never crash an LLM API with context overflows. Set --max-tokens 32k and ContextPack fits as much vital code as possible, tracking omitted files cleanly.
Instantly connect your local coding agent (Claude Code, OpenCode, Cursor) using standard Model Context Protocol tools for codebase packing, tree views, and diff analysis.
Automatically detects and parses .gitignore, skips binary files (images, compiled binaries, archives), and filters build artifacts effortlessly.
Pack working tree changes, staged edits, or branch diffs directly with line numbers to feed pull request reviewers and bug-triage prompts.
Export directly to Anthropic-standard XML (<documents><document>), Markdown code blocks, JSON metadata, or web-standard llms-full.txt.
Structured formats proven to maximize retrieval and reasoning accuracy in modern frontier models.
Recommended by Anthropic for Claude 3.5 Sonnet and Opus. Segregates files into indexed <document> wrappers with CDATA protection.
<documents>
<directory_tree>
├── src/
│ └── index.js
</directory_tree>
<document index="1">
<source>src/index.js</source>
<document_content>
1: console.log("Hello");
</document_content>
</document>
</documents>
Perfect for pasting into ChatGPT, DeepSeek, or storing as persistent documentation files in your repository.
# Codebase Context
## Directory Tree
```
├── src/
│ └── index.js
```
## Codebase Contents
### `src/index.js`
```javascript
1: console.log("Hello");
```
Empower your AI coding tools to inspect and pack repository context autonomously.
{
"mcpServers": {
"contextpack": {
"command": "npx",
"args": ["-y", "-p", "github:fastpresspages/contextpack", "contextpack-mcp"]
}
}
}
pack_codebase
Pack directory trees with token caps, git diffs, and formatting options into ready context.
get_tree
Generate visual directory hierarchies with file sizes and token estimates.
pack_diff
Extract and pack staged or branch Git diffs with affected file context.
estimate_tokens
Fast BPE token approximation for any arbitrary text snippet or disk file.
Generate packed codebase contexts inside your CI/CD workflows for automated PR review or documentation steps.
- name: Pack Repository Context
uses: fastpresspages/contextpack@main
id: pack
with:
path: '.'
format: 'xml'
max-tokens: '64k'
with-tree: 'true'
git-diff: 'true'
out: 'context.xml'
- name: AI Review Step
run: |
echo "Packed ${{ steps.pack.outputs.files }} files (${{ steps.pack.outputs.tokens }} tokens)"
# Pass context.xml to your LLM API call
Straightforward answers about licensing, token algorithms, and security.
Yes, 100% free and open-source under the Apache-2.0 license. There are no paid tiers, no API keys, and no telemetry.
ContextPack's tokenizer uses a calibrated heuristic calibrated against Claude and cl100k_base models. In benchmark testing on real codebases (JavaScript, TypeScript, Python, Go, Rust), it correlates within ~3-5% of true tokenizers while executing orders of magnitude faster without large WASM/Rust binary dependencies.
When you set --max-tokens, ContextPack reserves tokens for header metadata and the directory tree, packs files until the budget ceiling is approached, and cleanly tracks omitted files in an <omitted_files> block so your model knows which files were skipped.
Never. All file operations, tree generations, token counts, and diffs are computed locally in your Node.js process.
ContextPack is developed and maintained by FastPress Labs (github.com/fastpresspages), an open-source studio committed to building zero-bloat developer tools.
ContextPack is actively maintained. Have a feature request, check pattern suggestion, or question? Send us a note or open an issue on GitHub.
Email: meetcode99@gmail.com · GitHub Repository
ContextPack is part of the FastPress Labs ecosystem: open-source developer tools with zero telemetry and verified quality audits. Check out our companion tools: