How to Use Aider on a Large Monorepo Without Losing Context
A large monorepo is where Aider either pays off or falls over. The repo map is what makes it possible, and the repo map is also what burns your token budget if you leave it on defaults. Getting a 50,000-file tree working means tuning three settings and accepting a slower startup.
Why does Aider slow down on a big repo?
Aider walks your tracked files, extracts function and class signatures with tree-sitter, and ranks them by relevance to the conversation. On a small repo that finishes in a second. On a monorepo with 50k files it can take 20 to 60 seconds on first run, and the resulting map is compressed into a token budget that defaults to around 1,000 tokens on smaller windows.
That default is too small for cross-service work. You ask it to change an API response shape and it never sees the consumer because the map only had room for the files nearest the top of the ranking.
How do you widen the repo map?
Two flags matter:
--map-tokens 4096raises the budget. On a 200k-token window you can go higher, but every token in the map is a token not available for code you actually add.--map-refresh alwaysrebuilds on every turn. Leave it onautounless you are actively adding files, because rebuilds on a monorepo are slow.
If the ranking is wasting space on vendored code, add an ignore file. Aider respects .gitignore, and you can supplement with --aiderignore .aiderignore listing directories like node_modules, generated protobufs, and migration snapshots.
A useful rule: if the tree-sitter parse takes more than 15 seconds, cut the map, do not raise it. Relevance beats size.
How do you use two models at once?
Aider supports separate models for the main edit loop and for weak or auxiliary tasks like summarising commit messages. In practice: a strong model for edits, a cheap one for the surrounding chatter.
aider --model claude-sonnet-4 --weak-model gpt-4o-mini
That pairing cuts spend noticeably on long sessions. The weak model never touches your code.
There is also architect mode, where one model proposes a solution and another applies it to files. It costs roughly double per turn but produces fewer bad multi-file edits on unfamiliar code. Worth it for a refactor across six files; overkill for a one-line change.
How do you script repeatable Aider runs?
--message turns Aider into a one-shot tool. Useful for mechanical jobs across many files:
aider --message "add type hints to every public function in src/" --yes --auto-commits --no-stream
Pair it with --dry-run first to see the diff without committing. On a monorepo, always dry-run. A single misread instruction can touch 40 files, and reviewing 40 diffs after the fact is worse than reviewing one before.
For chunked work, use --read to feed context files without allowing edits to them:
aider --read docs/api-contract.md --message "update the client to match the contract"
That flag is underused. It lets you give the model a spec as read-only context, which stops it from helpfully rewriting your documentation along the way.
What are the practical limits?
Aider does not index your codebase into a vector store. There is no semantic search on 2026 builds. Retrieval is the repo map plus whatever you add, which means discovery still depends on you knowing file names. In a monorepo with inconsistent naming that is a real friction point.
Git performance also matters. A repo with a 200,000-commit history makes Aider’s initial status check feel sluggish, and on network filesystems it is worse.
Budget-wise, a substantial cross-service change on a mid-tier model lands somewhere between 40,000 and 120,000 tokens per question-answer cycle. Ten such cycles in an afternoon is a real bill, so check /tokens occasionally rather than discovering it at the end of the month.
Quick Summary
- On large repos, tune
--map-tokensand add an.aiderignore; raising the map blindly backfires. - Pair a strong edit model with a cheap
--weak-modelto cut session cost. - Use
--dry-runbefore any--messagebatch job on a monorepo. --readsupplies context files the agent cannot edit — good for specs and contracts.- There is no semantic code search; discovery still relies on knowing your file layout.
