Codebase Context Packer
Pack code files into an LLM prompt under a token budget with per-file truncation (full, signatures, first N lines) and XML, Markdown or plain output.
Codebase Context Packer
Files (3)
Output preview
Packed 266 tokens266 tokens<file path="src/index.ts">
import { createApp } from "./app";
const port = Number(process.env.PORT ?? 3000);
createApp().listen(port, () => {
console.log(`Listening on http://localhost:${port}`);
});
</file>
<file path="src/app.ts">
import express from "express";
import { listUsers, getUser } from "./users";
export function createApp() {
const app = express();
app.get("/users", async (_req, res) => {
res.json(await listUsers());
});
app.get("/users/:id", async (req, res) => {
const user = await getUser(req.params.id);
if (!user) return res.status(404).json({ error: "Not found" });
res.json(user);
});
return app;
}
</file>
<file path="src/users.ts">
export interface User {
id: string;
name: string;
email: string;
}
const users: User[] = [
{ id: "1", name: "Jane Doe", email: "jane@example.com" },
{ id: "2", name: "John Smith", email: "john@example.com" },
];
export async function listUsers(): Promise<User[]> { ... }
}
export async function getUser(id: string): Promise<User | undefined> { ... }
}
</file>Token allocation per file:
Updated . Provided as is. Check the output before you rely on it in production.
How to use Codebase Context Packer
- 1
Add your code files
Click Add File for each file you want to include. Enter the file path and paste the contents. You can also use bulk paste mode with file separators.
- 2
Set your token budget
Enter your target token budget or select a model preset (the current Anthropic, OpenAI and Google flagships plus the 200K Haiku tier, from the live model catalog). The budget bar shows how much space your files use.
- 3
Choose truncation mode
For large files, switch from Full to Signatures Only (keeps function and class signatures, drops bodies) or First N Lines to fit within your budget.
- 4
Copy the packed output
Select your output format (XML for Claude, Markdown, or Plain), review the preview, and click Copy to get the optimized context package ready to paste.
Questions and answers
What is Codebase Context Packer?
What output formats are available?
Does it send my code to a server?
How does the signatures-only truncation work?
For AI agents: how to call this tool
Machine-readable contract, endpoints and examples. Humans can ignore this section.
Best Path For Builders
Browser workflow
Runs instantly in the browser with private local processing and copy/export-ready output.
Browser Workflow
This tool is optimized for instant in-browser execution with local data handling. Run it here and copy/export the output directly.
/codebase-context-packer/
For automation planning, fetch the canonical contract at /api/tool/codebase-context-packer.json.