How to give ChatGPT your whole codebase in one file with Repomix
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

Posted on Oct 29 • Originally published at dedupedai.com
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.
You do not even need to install it. In your project folder:
npx repomix@latest Enter fullscreen mode Exit fullscreen mode If you will use it often, install it once. On a Mac, Homebrew works:
brew install repomix Enter fullscreen mode Exit fullscreen mode npm ( npm install -g repomix ), yarn and bun work too. Then just run:
repomix Enter fullscreen mode Exit fullscreen mode 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.
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. Enter fullscreen mode Exit fullscreen mode Want to skip the upload? --copy puts the output straight on your clipboard:
repomix --copy Enter fullscreen mode Exit fullscreen mode 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/" Enter fullscreen mode Exit fullscreen mode 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 Enter fullscreen mode Exit fullscreen mode 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 Enter fullscreen mode Exit fullscreen mode 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.
XML is the default. You can also ask for Markdown, JSON or plain text:
repomix --style markdown Enter fullscreen mode Exit fullscreen mode Markdown is easy to skim yourself before you upload. JSON is useful if you want to query the pack with jq.
This is the underrated feature. Want ChatGPT to explain a library before you adopt it? Point Repomix at the repo:
repomix --remote yamadashy/repomix Enter fullscreen mode Exit fullscreen mode 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 Enter fullscreen mode Exit fullscreen mode 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. Enter fullscreen mode Exit fullscreen mode For security, Repomix does not load config files from remote repos unless you pass --remote-trust-config.
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 Enter fullscreen mode Exit fullscreen mode --include-logs adds the last 50 commits by default, with dates, messages and changed files. --include-diffs adds your working tree and staged changes.
The README ships a few prompts you can paste after uploading:
Once you find flags you like, write them to a config file so every run uses them:
repomix --init Enter fullscreen mode Exit fullscreen mode That creates repomix.config.json in the project. Add --global to make it your default everywhere.
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