AI Coding Agents
Repomix Review: Pack Your Repository Into One AI-Friendly File
Repomix packs an entire repository into a single AI-friendly file with per-file token counts, a tree-sitter --compress mode that keeps code structure while dropping function bodies, and a Secretlint pass that excludes likely credentials. It earns its tokens when you must hand a model a codebase it cannot browse itself, or when the task genuinely needs most of the repo; for a focused fix where an agent only needs a few files, letting it explore is cheaper.
Repomix packs an entire repository into a single AI-friendly file with per-file token counts, a tree-sitter --compress mode that keeps code structure while dropping function bodies, and a Secretlint pass that excludes likely credentials. It earns its tokens when you must hand a model a codebase it cannot browse itself, or when the task genuinely needs most of the repo. For a focused fix where an agent only needs a few files, letting it explore is cheaper.
At a glance
| Question | Answer |
|---|---|
| What is it? | A CLI that packs repository files into one artifact with per-file token counts. |
| What cost does it target? | The input cost of supplying repository context up front. |
| Where does it act? | Before the prompt is assembled. The CLI writes a static snapshot, and an optional MCP server can pack on demand. |
| How do you try it? | Run the npm package through npx or install the CLI for repeated use. |
| Can you recover omitted content? | Read the source files or pack them again with compression disabled. The compressed snapshot omits function bodies. |
| What license is stated? | MIT. |
| What is its maturity signal? | 29,522 stars and 179 open issues as of November 30, 2026. |
| When is it a good fit? | You need to give a model repository context where it cannot browse the source itself. |
What it is and which cost layer it targets
Repomix (yamadashy/repomix) is a TypeScript CLI that merges a repository into one file you can paste into a chat or attach to a prompt. As of November 30, 2026 it had 29,522 stars, 1,664 forks and 179 open issues, under an MIT license. The repository was created in July 2024. The latest release in the evidence snapshot is v1.19.0, dated November 8, 2026.
The cost layer it targets is file reads and exploration: how source code gets into the model’s context in the first place. It is not middleware and it does not sit between your agent and the API. It produces a static artifact, and the economic question it answers is a simple one: is it cheaper to front-load the whole repo as one input, or to let an agent fetch files on demand? The answer depends entirely on how much of the repo the task actually needs.
How it works
One command walks the repository, applies your ignore rules, and writes a single output file (default repomix-output.xml). The output opens with an AI-oriented explanation of its own format, a <file_summary>, a <directory_structure> tree, then each file’s contents inside <file path="..."> tags, plus an optional <instruction> block. XML is the default style; the README links Anthropic’s XML-tagging guidance as the rationale, and --style markdown, --style json and --style plain produce equivalent structures for tools that prefer them.
Selection and shaping options that affect token spend:
--include/--ignoreglob patterns, plus.gitignore,.ignoreand.repomixignoresupport--stdinto pipe a file list fromrg,fd,fzfor your own filter--compressto extract code structure with tree-sitter (classes, functions, interfaces) while dropping bodies--remove-comments,--remove-empty-lines,--truncate-base64,--output-show-line-numbers--split-output <size>to break a large pack into numbered files--include-logs/--include-diffsto add git history and working-tree changes--no-filesfor a metadata-only pack (summary and tree, no contents)
By default files are sorted by git change frequency, most-changed first, which puts the files an agent is most likely to ask about near the top of the context. --no-git-sort-by-changes disables that ordering.
Two cost-relevant features deserve detail. First, token accounting is built in: Repomix reports per-file and total token counts, --token-count-tree [threshold] prints a tree annotated with counts, and --token-count-encoding picks the tokenizer (o200k_base by default, cl100k_base optional). Because the default counter is an OpenAI tokenizer, treat the numbers as an estimate when the target is Claude or another model with its own tokenizer. Second, --token-budget <number> fails with a non-zero exit code when the packed output exceeds N tokens, which makes the pack a guardable step in CI or an agent workflow: the file is still written, but the exit code tells the caller it will not fit.
For agent integration, repomix --mcp runs a Model Context Protocol server so an agent can pack on demand, and --sandbox [dir] confines the server’s file tools to one workspace (remote packing, skill generation and external outputs are disabled in that mode). --skill-generate writes the pack as a Claude Agent Skills directory under .claude/skills/<name>/.
Install and first run
The first command runs Repomix without a global install.
npx repomix@latest
Or install it for repeated use:
npm install -g repomix
# or: yarn global add repomix / bun add -g repomix / brew install repomix
repomix
That writes repomix-output.xml in the current directory. The README also shows how to pack a public repo remotely or run Repomix in a container:
repomix --remote yamadashy/repomix
docker run -v .:/app -it --rm ghcr.io/yamadashy/repomix
Remote config files require --remote-trust-config, which asks for confirmation on an interactive terminal. repomix --init creates repomix.config.json for repeatable configurations, and repomix --watch re-packs on file changes for local directories.
The npx path avoids a global install. Remove any generated packs, config or skill directory you no longer need. For a global install, use the package manager that installed it. If you added the MCP server to an agent’s config, delete that entry.
What it saves: claims vs independent evidence
The README makes a structural claim rather than a percentage claim: --compress “uses Tree-sitter to extract key code elements, reducing token count while preserving structure.” It does not publish a compression ratio or a dollar figure, and there is no independent benchmark of Repomix in the sources available for this review. That restraint is worth noting: you will have to measure the savings on your own repository, which is easy because the tool prints the token counts.
The savings mechanism is straightforward to reason about. A full pack replaces many small file-read operations with one input you control exactly. Compression trades information for tokens: the model sees signatures and structure but not function bodies, which is fine for “how is this organized” questions and wrong for “find the bug in this function” tasks. A closed issue asking to preserve type declarations while compressing function bodies (issue #359) shows users hitting that boundary; an open request for include/exclude options specific to --compress (issue #516) suggests the current granularity is all-or-nothing.
Prompt-cache and extra-turn risk
An unchanged pack can qualify for cache-read pricing when the client keeps it in a matching, cacheable prompt prefix. A regenerated pack or changed header can break the match and make the block eligible for fresh-input or cache-write billing. Reuse the same pack within a task while the files it covers stay current. The other failure mode is over-sending: every token in the pack is paid for on every turn it stays in context, so a 200k-token pack attached for a question that needed 20k tokens of files wastes money in a way that compounds with session length. How providers price prompt caching covers the mechanics.
What the GitHub issues show
As of November 30, 2026, Repomix had 179 open issues. The snapshot includes reports about file selection, output formatting and workspace scope.
- Issue #208:
removeCommentsandremoveEmptyLinesdescribed as unstable. Open. - Issue #867: the
--stdinoption does not seem to work. Open. - Issue #1060:
files falsedoes not work. Open. - Issue #226: a request for an unpack command to restore a packed file back to files. Open.
- Issue #1754: a feature request for a sandbox mode for the MCP server confining tools to one workspace. Open; the README now documents
--sandbox, so check whether your version includes it. - Issue #278: GitHub repo names containing a dot did not work. Closed.
- Issue #274:
SyntaxError: Unexpected token 'with'when running repomix. Closed. - Issue #1010: a request to split
--skill-generateoutput into smaller files to reduce loaded context. Closed.
Open requests include compression levels, file truncation, and related-file selection.
A cost example (estimate)
Assumptions, stated: a repository packs to 200,000 tokens, --compress brings it to 60,000 tokens, and the alternative is an agent that reads the 40,000 tokens of files the task actually needs. Priced at the committed claude-sonnet-5-5 rates (input $2 per million tokens, cache read $0.10 per million; check the AI provider pricing index for current rates), cost = tokens x rate:
- Full pack estimate: 200,000 × $2/1M plus 20 × 200,000 × $0.10/1M = $0.80.
- Compressed pack on the same shape: 60,000 fresh = about $0.12, plus 20 cached turns = about $0.12. Estimate: ~$0.24.
- Agent exploration reading only what it needs: 40,000 fresh = about $0.08, cached across the same 20 turns = about $0.08. Estimate: ~$0.16.
All three estimates assume 20 cache hits and exclude cache-write charges, other prompt content, and output. The shape is the point: the pack wins when the model needs most of the repo or cannot fetch files at all, and loses when it only needed a slice. Compression narrows the gap but throws away function bodies, which is the wrong trade when the task lives inside those bodies.
Who should use it, who should skip it
Use it if you:
- Feed code to a tool without file access: web chats, one-shot API scripts, or a second model that reviews a repo it cannot clone
- Ask whole-repo questions: architecture review, documentation or test generation across the codebase, onboarding a model to an unfamiliar project
- Want a fixed, inspectable input:
--token-count-treeshows exactly what you are paying for, and--token-budgetcan fail a pipeline before a giant pack ships - Need to send a public repo to a model without cloning it locally (
--remote)
Skip it if you:
- Run an agent that already reads files on demand and your tasks touch a small slice of the repo
- Work in a repository whose pack exceeds the model’s context window even with
--compress(see what is an LLM context window) - Need iterative edits: the pack is a snapshot and goes stale the moment files change
- Cannot review the output before sending; the pack contains the whole repo minus ignored and flagged files
How to trial it safely
- Run the first pack locally, then use the token-count tree to find the largest files before sending the pack to a model.
- Pack with your real ignore rules and check the total against the model’s context window; keep a
--token-budgetline in any scripted use. - Send the same task twice: once with the pack, once letting the agent explore. Compare provider-billed input tokens and answer quality, not vibes.
- Try
--compressonly for structure-level questions, and diff the answer quality before trusting it for implementation work. - Search the packed output for anything sensitive before pasting it into a web tool; Secretlint filters known credential formats, not all secrets.
The measurement protocol in how to measure coding agent token savings applies directly.
Alternatives and next reads
- Serena vs Repomix vs Graphify: the three ways to put a codebase in front of a model, compared.
- Graphify codebase knowledge graph review: query a pre-built graph instead of shipping the whole repo.
- Serena MCP semantic code tools review: symbol-level reads via MCP, the on-demand end of the spectrum.
- Choose a token saving stack for coding agents: where a pack file fits next to hooks, proxies and memory.
Sources
- yamadashy/repomix repository (GitHub, accessed 2026-11-30)
- repomix issue #208: unstable removeComments and removeEmptyLines (GitHub, accessed 2026-11-30)
- repomix issue #359: preserve type declarations while allowing function compression (GitHub, accessed 2026-11-30)
- repomix issue #516: include/exclude options specific to --compress (GitHub, accessed 2026-11-30)
- repomix issue #1754: sandbox mode for the MCP server (GitHub, accessed 2026-11-30)
How this note was produced
Drafted with AI assistance from committed ByteCosts pricing snapshots and deterministic cost formulas. Figures are grounded in the linked sources (last updated 2026-11-30). Read our editorial & automation policy, inspect the methodology, or report a discrepancy.
Repomix Review: Pack Your Repository Into One AI-Friendly File. ByteCosts. Updated 2026-11-30. https://bytecosts.com/blog/repomix-pack-repository-for-llm/