← All posts

CLI

Repomix: Pack Your Whole Repo Into One AI-Friendly File

Repomix packs your entire codebase into one AI-ready file with token counts, secret scanning, and code compression.

R CLI

If you've ever tried to hand a whole project to an AI assistant, you know the friction: you copy-paste files one at a time, lose the directory structure, and blow past the context window without realizing it. Repomix solves exactly that. It's a small, fast tool that packs your entire repository into a single, AI-friendly file — structured so a model can navigate it, token-counted so you know what will actually fit, and scanned for secrets before it ever leaves your machine. It runs with one npx command, needs no install, and has quietly become one of the most-starred tools in the "feed your codebase to an LLM" category.

What It Actually Produces

Point Repomix at a directory and it walks the tree, respects your .gitignore, and emits one consolidated file with a header, a directory map, and the contents of every included file wrapped in clear delimiters. The default output is XML because models parse it reliably, but Markdown and plain text are one flag away:

# Pack the current repo into repomix-output.xml npx repomix # Markdown output, just the src directory npx repomix --style markdown --include "src/**/*.ts" # Pack a remote repo without cloning it yourself npx repomix --remote yamadashy/repomix

The single-file output is the whole point: instead of the model reconstructing your project from a dozen fragments, it gets the structure and the code together, in the order you chose.

Token Counting Is the Feature I'd Use Most

Repomix reports a token count for the whole pack and, optionally, per file. That number is the difference between "this fits in the context window" and "the model silently truncated half my code." Seeing which files dominate the budget also tells you what to cut — a generated lockfile or a vendored dependency can eat more tokens than all your actual source combined. It turns "paste and hope" into a deliberate decision about what the model sees.

Secret Scanning and Compression

Two features push it past "cat all the files together." First, Repomix runs Secretlint over the content and flags likely credentials — API keys, tokens — before you paste the output anywhere. It's not a substitute for reading the file yourself, but it catches the obvious leaks. Second, the --compress flag uses Tree-sitter to strip function bodies down to signatures and structure, so the model sees the shape of the codebase at a fraction of the tokens — useful when the full source simply won't fit.

# Compress to signatures and structure, and scan for secrets npx repomix --compress

Where It Fits Your Workflow

Beyond the CLI, Repomix ships a VS Code extension, a browser version at repomix.com for quick one-off packs, and an MCP server so an AI assistant can call Repomix directly as a tool rather than you running it by hand. Include and exclude globs, custom ignore files, and git-aware options (packing a diff, or sorting by recent changes) let you narrow a large repo down to just the part you're asking about.

Rough Edges and Limitations

  • It doesn't beat physics. A large repo can still exceed any context window. Compression and include filters help, but on big codebases you'll be curating what you pack, not dumping everything.
  • XML is verbose. The default format is reliable for models but adds tokens; on a tight budget, Markdown or plain output can be leaner.
  • Token counts are estimates. They track the common tokenizers closely but won't match every provider exactly — treat them as a strong guide, not a guarantee.
  • Compression loses detail. --compress discards implementation bodies, so it's right for "understand the architecture" and wrong for "debug this function."
  • Secret scanning is a safety net, not a guarantee. Secretlint catches common patterns; review the output yourself before sharing anything from a private repo.

If any part of your workflow involves handing code to an LLM — review, refactoring, or onboarding a model to an unfamiliar project — Repomix removes the tedious part and adds the one number you actually need (the token count) to do it deliberately. It's MIT-licensed, install-free via npx, and the kind of tool you reach for weekly once it's in muscle memory.

Internal link suggestion: link "feed your codebase to an LLM" or "MCP server" to a future DevTools post about an MCP workflow or a review tool like PR-Agent, which pairs naturally with Repomix's context-packing step.