Repomix

Packs an entire repository into a single AI-friendly file, complete with token counts, secret scanning, and an MCP server for direct AI assistant access.

Tool
npm
v1.18.0
28,391stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
87/100Excellent
Development Activity96
Maintenance100
Community68
Maturity44
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
92/100Excellent
Architecture90
Code Quality92
Innovation90
Learning Curve95

Repomix takes a codebase — local or remote — and flattens it into one output file (XML, Markdown, or plain text) built for feeding into an LLM’s context window. Instead of manually copy-pasting files into a chat prompt, you point it at a directory or a GitHub URL and it walks the tree, respects .gitignore/.repomixignore, and produces a single document with a directory summary, per-file token counts, and the file contents themselves.

Beyond the basic pack, it runs a Secretlint-based security check to keep credentials and API keys out of the output, and offers a --compress mode that uses Tree-sitter to strip a file down to its structural signatures (function signatures, class definitions) when the goal is an architectural overview rather than full source. A --remote flag lets it clone and pack a GitHub repo without a manual git clone step first, guarded by a config-trust prompt so an untrusted repository’s repomix.config.js can’t silently execute.

Repomix also runs as a Model Context Protocol server (--mcp), exposing pack/read/grep tools so an AI assistant like Claude can pull codebase context on demand instead of relying on a pre-generated file. A --sandbox mode confines that server’s file tools to a single workspace root for untrusted-agent use. It ships as both a CLI binary and an importable library, with a companion website, Chrome/Firefox extensions, and a community VS Code extension.

What You Get

  • A single-file pack of a repository (XML, Markdown, or plain text) with a directory tree, per-file token counts, and total token count against configurable model budgets
  • Built-in secret scanning via Secretlint that flags files matching known credential patterns before they land in the output
  • --compress mode using Tree-sitter to reduce files to their structural signatures, cutting token count while preserving code shape
  • --remote packing of any public GitHub repo (or a specific branch/tag/commit) without a manual clone step, gated by a content-pinned config-trust prompt
  • An MCP server mode (--mcp) exposing pack/read/grep tools so AI assistants like Claude, Cursor, or Cline can pull codebase context on demand, with an optional --sandbox to confine it to one workspace root
  • Git-aware output ordering (sort files by change frequency), optional git log/diff inclusion, and a --skill-generate mode that turns a packed repo into a reusable Claude/agent skill

Common Use Cases

  • Feeding an entire small-to-medium repository to ChatGPT, Claude, or Gemini for a refactor, code review, or onboarding-style walkthrough in one prompt
  • Packing a remote open-source repo by URL to evaluate or explain it without cloning it locally first
  • Running as an MCP server so an AI coding assistant can request codebase context directly instead of working from a stale, manually generated file
  • Generating a compressed, structure-only view of a large codebase to fit within a tight token budget
  • Wiring into CI (GitHub Actions) to produce an up-to-date AI-context artifact on every push

Under The Hood

Architecture The core pack() function in src/core/packager.ts runs a staged pipeline — search, collect, apply file processors, process/read content, validate file safety, calculate metrics, sort, then produce output — with every stage’s dependency injected through a defaultDeps object that call sites can override, which is what makes the pipeline testable without mocking modules directly. CLI, watch, and remote entry points (src/cli/actions/) all funnel into buildMergedConfig, which merges default, file (repomix.config.*), and CLI-flag configs through Valibot schemas before the pack runs. Slower stages overlap deliberately: the token-count cache load and git-history prefetch both kick off before file search finishes, trading a bit of extra plumbing for measurably lower wall-clock time, and CPU-bound work (content processing, Secretlint scanning) is offloaded to worker pools via Tinypool rather than run inline. The MCP server (src/mcp/) sits alongside the CLI as a second entry point over the same pack() core, with a --sandbox mode that swaps in a restricted tool set instead of bolting sandboxing onto the existing tools.

Tech Stack Repomix is a TypeScript ESM package (Node >=22) built with tsc, distributing a bin/repomix.cjs CLI wrapper around commander. Config and CLI-argument validation run through both Valibot and Zod schemas; gpt-tokenizer produces per-file and total token counts; web-tree-sitter plus @repomix/tree-sitter-wasms power the --compress structural-extraction mode; @secretlint/core handles credential scanning; @modelcontextprotocol/sdk implements the MCP server; chokidar drives watch mode; and handlebars renders the generated-skill templates. Linting runs through both Biome and oxlint plus a standalone tsc --noEmit pass, and tests run on Vitest with v8 coverage.

Code Quality The repository carries roughly 150 test files spread across tests/cli, tests/core, tests/mcp, tests/config, and a dedicated tests/integration-tests suite, backed by Vitest with coverage reporting to Codecov. CI (.github/workflows/ci.yml) runs Biome, oxlint, and tsc --noEmit as separate jobs against every push and PR, and the project lints its own source with Secretlint — the same tool it ships to end users. Comments in the core modules (e.g. the reasoning behind overlapping the token-cache load, or why remote clones skip config migration) explain non-obvious decisions rather than restating what the code does, which is a good sign for a codebase this size.

What Makes It Unique Most “pack a repo for an LLM” scripts stop at concatenating files. Repomix layers in things that only matter once the tool is actually used against untrusted or sensitive input: a content-pinned trust prompt before it will execute a cloned repository’s own config file (comparable to a direnv allow model), a --sandbox mode that changes which MCP tools are even registered rather than just checking paths at call time, and Secretlint scanning that runs by default instead of as an opt-in. Combined with --compress for fitting large codebases into a token budget and a skill-generation mode that turns a pack into a reusable agent skill, it treats “safely handing a codebase to an AI” as the actual problem, not just the file concatenation step.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search