How to Cut Aider Costs and Token Usage in Git Repos

November 12, 2026

Aider charges you for everything in the chat every round. The fix is not a cheaper model, it is a smaller chat. Dropping files after each task, using the repo map instead of adding whole directories, and committing often can take a 40-cent refactor down to under a dime.

That is the whole thesis. The rest of this guide is the mechanics: which flag does what, where the hidden token bloat comes from, and how to spot a session that is quietly burning money.

Why does the same Aider edit cost 10x more some days?

Because a request resends the full chat context. Eight files plus 20 messages of history is one large request, not 21 small ones.

Aider prints the token count on every turn. Two numbers matter: total context and the per-request cost line. If context is over 40,000 tokens, you are paying for the model to re-read a scroll of old decisions it has already made.

Typical bloat sources, in order of impact:

  1. Files you added for one question and never dropped.
  2. Long back-and-forth where you iterated on a diff.
  3. Large generated files (lock files, minified JS, fixtures) pulled in by accident.
  4. Whole test directories added instead of the two files you changed.

How do /drop, /reset and /clear differ?

Each solves a different problem and people mix them up constantly.

  • /drop removes a named file from the chat. Use it the moment you finish with a file.
  • /clear empties the message history but keeps the file list. Good after finishing a task, before starting the next.
  • /reset wipes both history and files. Use it when the model has gone down a wrong path.

Routine that keeps sessions cheap: finish a task, /clear the history, /drop files no longer needed, then add the next batch. Ten seconds of housekeeping adds up to real savings across a week.

What is the repo map and when should you rely on it?

Aider builds a repo map: a compact tree of files with key function and class signatures, ranked by relevance to your request. It is how Aider finds the right file to suggest before you add anything.

Two flags control it:

  • --map-tokens sets how much budget the map gets. Default is around 1,000 tokens. Raising it helps on large repos where relevant code sits deep in the tree.
  • --no-map disables it. Bad idea on a big repo, fine on a ten-file script where you know where everything is.

On a 200-file codebase, letting the map do discovery and adding only what you need beats adding five files “just in case” every time. The map costs about 1K tokens; a wrong file guess costs 5K or more.

Does Aider’s diff mode save money?

Yes, and it is the single most underrated setting. By default Aider asks a model to return whole-file rewrites in an edit-block format. With --edit-format diff, it asks for unified diffs instead. Output tokens drop sharply on large files.

On a 900-line module, a whole-file rewrite might return 900+ lines against a model that bills output at 3-4x input rate. A diff for the same change is often 30 lines.

Command form:

aider --edit-format diff --model sonnet

Diffs fail to apply more often than block edits, so budget one extra attempt per three changes. Even with retries the math usually wins on files over a few hundred lines.

How do commits and test runs change the bill?

Every time Aider runs your test suite it pulls the output into the chat. A 400-line pytest failure dump is 2,000+ tokens of context you now carry forward.

Practical rules:

  • Run the narrow test file, not the suite, when asking Aider to fix something.
  • After a commit, /drop the test file if you will not touch it again this session.
  • Use --no-auto-test if you prefer to run tests yourself and paste only the failing assertion.

None of this is dramatic on one edit. Over a full day of work it is the difference between a two-dollar session and a twelve-dollar one.

What still costs money no matter what you do?

  • Multi-file refactors. There is no way around sending those files. Accept 20-50 cents and move on.
  • Unfamiliar codebases. The map and a few trial files cost real tokens before you understand the structure. That is tuition, not waste.
  • Model choice. Switching to a weak model to save money usually ends in a failed attempt plus a retry on the strong model, which costs more than starting strong.

If you want zero marginal cost, point Aider at a local model through Ollama. Expect noticeably worse multi-file reasoning. Fine for renames and small patches, painful for anything architectural.

Quick Summary

  • Aider resends the whole chat each turn, so context size drives cost, not answer length.
  • Use /drop after finishing a file, /clear between tasks, /reset when the model goes wrong.
  • The repo map costs about 1,000 tokens and replaces guesswork file additions on large repos.
  • --edit-format diff cuts output tokens a lot on large files, at the cost of more failed applies.
  • Narrow test runs and frequent commits keep failure dumps out of the context window.
Tags: