ChatGPT is good at reviewing code, explaining an unfamiliar project and writing tests. It is bad at guessing what is in the 40 files you did not paste. Copying files one by one is slow, you lose the folder structure, and you never know how close you are to the context limit.
Repomix packs an entire repository into a single AI-friendly file with one command. It respects your .gitignore, counts tokens per file and for the whole repo, scans for secrets with Secretlint so credentials stay out of the output, and can compress code down to its structure with Tree-sitter. You then upload that one file to ChatGPT, Claude, Gemini or any other model.
This guide walks through the workflow end to end.
Step 1: pack your repo
You do not even need to install it. In your project folder:
npx repomix@latest
If you will use it often, install it once. On a Mac, Homebrew works:
brew install repomix
npm (npm install -g repomix), yarn and bun work too. Then just run:
repomix
Repomix writes repomix-output.xml to the current folder: a file summary, the directory structure and every file's contents. The terminal output shows the token count and your five largest files, so you know before uploading whether it will fit.
Step 2: hand it to ChatGPT
Upload repomix-output.xml to a ChatGPT chat (or paste it if it is small) and start with a prompt like the one the README suggests:
This file contains all the files in the repository combined into one.
I want to refactor the code, so please review it first.
Want to skip the upload? --copy puts the output straight on your clipboard:
repomix --copy
Step 3: keep it inside the context window
Big repos are where most people give up. Repomix has four levers for this.
Pack only what matters. Use glob patterns to include or ignore paths:
repomix --include "src/**/*.ts,**/*.md"
repomix --ignore "**/*.log,tmp/"
Compress. --compress uses Tree-sitter to keep the essential structure (classes, functions, interfaces) and drop the rest. Great for "explain the architecture" questions where the model does not need every line:
repomix --compress
Strip noise. --remove-comments and --remove-empty-lines cut tokens further.
Split it. If a pack is still too big for one upload, --split-output writes numbered files of a size you choose:
repomix --split-output 2mb
To find the heavy folders first, --token-count-tree prints your file tree with token counts. The default counting uses the o200k_base tokenizer, which the README lists as GPT-4o's, and you can change it with --token-count-encoding.
Step 4: pick a format the model reads well
XML is the default. You can also ask for Markdown, JSON or plain text:
repomix --style markdown
Markdown is easy to skim yourself before you upload. JSON is useful if you want to query the pack with jq.
Pack a GitHub repo you have not cloned
This is the underrated feature. Want ChatGPT to explain a library before you adopt it? Point Repomix at the repo:
repomix --remote yamadashy/repomix
It accepts full GitHub URLs, the user/repo shorthand, and a branch, tag or commit with --remote-branch. Combine it with compression for a quick architecture overview:
repomix --remote yamadashy/repomix --compress
Then use the README's library overview prompt:
This file contains the entire codebase of library. Please provide a comprehensive overview of the library, including its main purpose, key features, and overall architecture.
For security, Repomix does not load config files from remote repos unless you pass --remote-trust-config.
Give the model history, not just code
When you are asking "why did this break?", recent changes matter more than the full source. Repomix can add git context:
repomix --include-logs --include-diffs
--include-logs adds the last 50 commits by default, with dates, messages and changed files. --include-diffs adds your working tree and staged changes.
Prompts worth saving
The README ships a few prompts you can paste after uploading:
- Code review: "This file contains my entire codebase. Please review the overall structure and suggest any improvements or refactoring opportunities, focusing on maintainability and scalability."
- Docs: "Based on the codebase in this file, please generate a detailed README.md that includes an overview of the project, its main features, setup instructions, and usage examples."
- Tests: "Analyze the code in this file and suggest a comprehensive set of unit tests for the main functions and classes. Include edge cases and potential error scenarios."
Save your settings
Once you find flags you like, write them to a config file so every run uses them:
repomix --init
That creates repomix.config.json in the project. Add --global to make it your default everywhere.
No terminal? Three other ways in
- Website: repomix.com packs a public repo in the browser, with format options and a token estimate.
- Browser extension: Chrome and Firefox add-ons put a Repomix button on GitHub repo pages.
- VS Code: the community extension Repomix Runner runs it on any folder from the editor.
Going further
We wrote up this workflow in a shorter form, with who it suits and where it falls down: Repomix tutorial: pack your codebase into one file for an LLM. The Repomix repo page on Deduped collects other ways people use it.
If your real goal is to understand a codebase you just inherited rather than chat about it, compare this with how to map an unfamiliar codebase in one run with Graphify.
Deduped tracks the AI repos people are actually building with and writes up how to use them. Repo: github.com/yamadashy/repomix.
Get one email every Monday with the week's hottest AI repos and exactly how to use them: subscribe free at dedupedai.com
Top comments (0)