Use Repomix to Feed Code to Gemini Carbon
Pack local projects into one secret-checked file with Repomix so you can use Gemini 4 Carbon on the web without connecting your repo directly.

Why pack your codebase with Repomix for Gemini Carbon?
When a frontier model like Gemini 4 Carbon is only available inside the browser UI, you can still give it full project context without wiring up an IDE plugin or granting write access to your machine. Running Repomix locally turns your repository into one deterministic, secret-checked XML file you upload straight into the web prompt.
I started doing this the same week we saw what builders are shipping with Gemini 4 Carbon. That frontier model shines at multi-file architecture calls, security audits, and tricky bug hunts, yet when a model only lives in a browser tab you normally get stuck pasting three files at a time and losing half the call graph. Packing the repo into one structured bundle gives you deep reasoning on tap while keeping git, secrets, and write permissions strictly local.
flowchart LR
A[Local Git Repo] --> B[Token Audit<br />--token-count-tree]
B --> C[Repomix Pack<br />Ignore + Secretlint + Optional --compress]
C --> D[Single XML Context Bundle]
D --> E[Gemini 4 Carbon Web UI<br />Structured Diff Prompt]
E --> F[Review & Apply Patch Locally]What do you need before packing a repository?
You only need Node.js 22 or newer (for npx), a clean Git working tree so .gitignore rules filter build artifacts automatically, and access to the browser app with Gemini 4 Carbon selected. Installing Repomix globally is optional because npx --yes repomix runs the current release on demand without adding dependencies to your project.
According to the Google DeepMind model specification, Carbon supports up to a 1M token combined context window across input, reasoning, and output. The Repomix official documentation also covers four main output modes, and picking the right one decides whether the model reads crisp structure or chokes on noise.
| Packing Mode | CLI Flag | Best Use Case in Gemini Web | Trade-off |
|---|---|---|---|
| Default XML | --style xml | Full subsystem debugging and cross-file refactors | Largest token footprint when uncompressed |
| Compressed XML | --style xml --compress | Whole-repo architecture reviews on large codebases | Strips function bodies to signatures via Tree-sitter |
| Scoped Slice | --include "src/api/**" | Targeted feature work with full line-by-line context | Requires you to know the active folder boundaries |
| Markdown Bundle | --style markdown | Small modules or config audits under 50k tokens | Weaker file-boundary separation than XML tags |
How do you pack a project for Gemini Carbon?
Run these steps inside the root of any local repository. We tested every command below with Repomix v1.19.0 on our ZeroLabs TypeScript codebase running on Node.js v24.20.0.
-
Audit your token distribution before generating any bundle. Never pack blind on an unfamiliar repo. Run a files-omitted tree scan with a threshold so large artifacts jump straight to the top:
npx --yes repomix --no-files --token-count-tree 5000Expected output: a top-5 token hog list and a directory tree filtered to files over
5000tokens. Do not add--quietto this command because--quietsuppresses the token tree summary completely. On our first scan across788repo files, a single vendored minified bundle (babel.min.js) measured1,079,101tokens on its own, enough to consume Gemini 4 Carbon's entire window before a single line of application code appeared. -
Create a reusable
repomix.config.jsonto ban noise globally. Save this configuration at your project root so you do not have to retype ignore globs on every session:{ "$schema": "https://repomix.com/schemas/latest/schema.json", "input": { "maxFileSize": 52428800 }, "output": { "filePath": "repomix-output.xml", "style": "xml", "parsableStyle": true, "fileSummary": true, "directoryStructure": true, "files": true, "removeComments": false, "removeEmptyLines": false, "compress": false, "topFilesLength": 10, "showLineNumbers": true, "truncateBase64": true }, "include": [], "ignore": { "useGitignore": true, "useDotIgnore": true, "useDefaultPatterns": true, "customPatterns": [ "**/*.min.js", "**/*.min.css", "**/*.map", "**/package-lock.json", "**/pnpm-lock.yaml", "**/yarn.lock", "**/dist/**", "**/build/**", "**/.next/**", "**/coverage/**", "**/vendor/**", "**/__pycache__/**", "**/*.log", "repomix-output.*" ] }, "security": { "enableSecurityCheck": true }}Verify the config loads cleanly by running
npx --yes repomix -c repomix.config.json --no-files --top-files-len 5. You should see zero config parse warnings and a clean file count. -
Pack your target directory with line numbers and a hard token ceiling. Leaving headroom inside a 1M token window matters because Gemini shares that budget across your uploaded file, thinking tokens, follow-up turns, and long code replies. Cap the bundle at
600000tokens:npx --yes repomix src --style xml --output-show-line-numbers --token-budget 600000 -o repomix-output.xmlExpected output:
Packing completed successfully!with total files, total tokens, and security status. When we packedsrc/on our Next.js codebase, Repomix bundled357files into508,547tokens (2,046,282characters, roughly2.0Mon disk) and Secretlint automatically flagged and excluded2test fixtures containing synthetic token strings. -
Drop to
--compressor--includewhen a repo still runs too hot. If your fullsrc/directory crosses600000tokens, you have two clean levers. First, use--compress, which calls Tree-sitter to keep class names, types, exports, and function signatures while stripping function bodies:npx --yes repomix src --style xml --compress --token-budget 600000 -o repomix-compressed.xmlOn the exact same
357source files,--compressdropped our output from508,547tokens down to80,553tokens (317,741characters), freeing room for multi-turn architectural debates. Second, when you need full implementation lines for a specific bug, slice strictly by glob:npx --yes repomix --include "src/lib/editorial-*.ts,src/lib/review-checks.ts" --style markdown -o slice.mdThat scoped pack dropped our context down to
4files and10,958tokens (43,185characters). -
Optionally bake your project rules into the bundle header. If you already maintain an instruction contract like the one in our guide on how to write a strict AGENTS.md contract, attach it straight to the bundle with
--instruction-file-path AGENTS.mdso the model starts with your repo conventions already loaded. -
Verify the final artifact before dragging it into the browser. Run a quick check on file size, token budget exit status, and accidental
.envinclusion:ls -lh repomix-output.xml && grep -c " **The hard rule:** Never pass `--no-security-check` when packing code destined for a hosted web model, and never override Secretlint warnings without inspecting the flagged file first.
How do you prompt Gemini Carbon once the bundle is uploaded?
Attach repomix-output.xml in your Gemini web prompt and pair it with a tight output contract. Without boundaries, a web model handed half a million tokens of source code will happily rewrite four modules from memory and invent helper paths that do not exist.
Paste this prompt template alongside your attached file:
The attached XML file is a Repomix bundle of my codebase, including the directory tree and numbered source files.Task:[Describe the exact bug, architecture review, security check, or refactor.]Rules:1. Cite exact file paths and line numbers from for every claim.2. Never invent files, symbols, or dependencies absent from the bundle.3. If critical context is missing, stop and list the exact file paths I need to pack next.4. Output proposed changes as unified diffs plus local verification commands I can run.That four-rule contract turns Carbon into a senior reviewer sitting across the desk. When it spots a bug, you get a git apply-ready patch tied to real line numbers rather than a wall of hand-wavy prose, and you keep full control over what actually lands on disk. If you also run local CLI coding tools alongside browser sessions, see our setup walkthrough for Claude Code, Codex, and Gemini CLI so your repo conventions stay consistent across both workflows.
What fails in production when packing large repos?
Most failures with Repomix happen before you ever hit send in the browser. Watch out for these five traps when packing real projects:
- Minified vendor files and giant JSON reports: A single built script or static audit dump can burn over a million tokens on its own. Always run
--token-count-tree 5000first and add**/*.min.js,**/*.map, and report folders toignore.customPatternsinrepomix.config.json. - Running
--quietduring diagnostics: Passing--quietsuppresses the summary and token tree output in Repomixv1.19.0. Drop--quietwhenever you inspect token counts, and reserve it for automated scripts where you only care about exit status from--token-budget. - Silent exclusion of legitimate code by Secretlint: Repomix skips any file where Secretlint triggers, which is great for
.envsafety but can quietly omit a test file or mock fixture you actually wanted reviewed. Check theSecurity Checkblock in stdout after every pack, and pair this workflow with a 6-area security audit on vibe-coded apps so fake keys in tests are clearly isolated from real secrets. - Forgetting output headroom in the 1M window: Packing
950,000tokens leaves almost no room for Carbon's reasoning trace, your follow-up questions, or multi-file diffs. Keep individual bundles under600,000tokens or use--split-output 2mbif you want separate chunks you can upload across targeted threads. - Packing stale
repomix-output.xmlback into itself: Running Repomix twice without ignoringrepomix-output.*folds the previous XML dump right back into the new bundle. Always addrepomix-output.*to.gitignoreorrepomix.config.jsonignore patterns.
How can AI agents execute this workflow directly?
Drop this portable skill file into your local agent workspace so coding assistants audit tokens, enforce Secretlint, and build clean bundles for web sessions automatically.
---name: repomix-web-packdescription: Audit token distribution, scrub secrets, and pack a local codebase into a single XML or Markdown bundle sized for frontier web models such as Gemini 4 Carbon.---# Repomix Web Context PackUse this skill when preparing a local repository for a web-only frontier model session without connecting live IDE or repository integrations.## Execution Rules1. **Audit token weight before packing.** Run `npx --yes repomix --no-files --token-count-tree 5000` first to catch vendored bundles, lockfiles, or generated JSON artifacts that would exhaust the target context window.2. **Never disable security checks on outbound bundles.** Keep Secretlint enabled (default behavior). Never pass `--no-security-check` for files you plan to upload to a hosted web model.3. **Scope before compressing.** Prefer `--include` and `--ignore` to isolate the target subsystem first. Add `--compress` only when the scoped slice still exceeds roughly 400,000 tokens or when you only need architectural signatures across a large tree.4. **Enforce a hard token ceiling.** Pass `--token-budget 600000` (leaving headroom for your prompt, follow-up turns, and model output inside a 1M token window). If a monorepo exceeds the budget, pack subsystem slices or use `--split-output 2mb`.5. **Attach a task contract.** Include `--instruction-file-path` or paste an explicit prompt requiring file-path citations and unified diffs rather than ungrounded rewrites.## Standard Commands```bash# 1. Inspect token hogs before generating outputnpx --yes repomix --no-files --token-count-tree 5000# 2. Pack full source with line numbers and token ceilingnpx --yes repomix src --style xml --output-show-line-numbers --token-budget 600000 -o context.xml# 3. Pack a scoped feature slice in Markdown for quick reviewnpx --yes repomix --include "src/api/**,src/lib/**" --ignore "**/*.test.*" --style markdown -o slice.md# 4. Pack architectural skeleton of a large repo using Tree-sitter compressionnpx --yes repomix src --style xml --compress --token-budget 600000 -o skeleton.xml```## Verification ProbeRun a non-destructive token audit and verify the pack exits 0 without exceeding budget or leaking secrets:```bashnpx --yes repomix src --style xml --token-budget 600000 -o /tmp/repomix-verify.xml && wc -c /tmp/repomix-verify.xml && rm -f /tmp/repomix-verify.xml```You can also grab the ready-to-use repomix.config.json, prompt template, and skill manifest from our companion recipe bundle or check the upstream source repository for new releases.
FAQ
Does Repomix upload my code anywhere automatically?
No. Running npx repomix executes completely locally on your machine and writes a file on disk unless you explicitly visit the hosted web app at repomix.com. Nothing leaves your laptop until you attach the generated XML or Markdown file to your Gemini web chat.
Should I use XML or Markdown when uploading to Gemini 4 Carbon?
Use --style xml as your default for multi-file coding work. Explicit `` tags keep file boundaries unambiguous across hundreds of files, while --style markdown works nicely for small, targeted slices under 50,000 tokens.
How do I stop Repomix from leaking my .env or API keys?
Keep enableSecurityCheck: true enabled in repomix.config.json and keep .env* inside .gitignore. Repomix respects .gitignore automatically and runs Secretlint across every candidate file before packing, dropping any file that trips a credential pattern.
What if my whole repository is still too big even with --compress?
Pack by subsystem with --include "apps/web/src/**" or pass --split-output 2mb to break the output into numbered XML parts. Splitting by architectural boundary usually produces cleaner reasoning in Gemini Carbon than dumping unrelated microservices into one chat.