Aider Cheatsheet - Terminal AI Pair Programming

Aider is the open-source Apache 2.0 terminal AI pair programmer for developers who want a model to edit local files and auto git-commit, with 100+ model support and no vendor lock-in. Its signature is an automatic commit per change, forming a safe loop with --test-cmd/--lint-cmd where a bad edit is one /undo away. This sheet covers file context, chat-mode switching, and architect mode.

AI CLI·53 commands·Last updated 2026-08-05
aideraipair-programmingcliagentPair Programming

Typical Use Case

For developers who want controlled edits inside a real local repository, especially teams that value being able to undo. Aider differs most in its git integration: every change is committed automatically, and with --test-cmd and --lint-cmd that becomes an edit, test, commit loop, so a broken line is one /undo away from reverted. Four lines are covered: model and reasoning configuration, including the two-model split with --architect, a cheaper --weak-model for trivial subtasks, and --map-tokens to control repository map cost; file and context management through /add, /drop and /read-only; the four chat modes; and /save with /load to turn a session into a reproducible script.

Install & Start 5

pip install aider-chat
Install via pip (or pipx for isolation)
aider
Start interactive pair programming in a git repo
aider src/main.py tests/test_main.py
Start and add specific files to the chat
aider --model claude-sonnet-4-6
Set the main model
export ANTHROPIC_API_KEY="sk-ant-..."
Set the Anthropic key (OpenAI/DeepSeek/local also supported)

Model & Reasoning 7

aider --model ollama/codellama
Use a local Ollama model
aider --architect --model claude-opus --editor-model claude-sonnet
Architect mode: planner + editor dual models
aider --weak-model gpt-4o-mini
Set the weak model (for cheap subtasks)
aider --reasoning-effort high
Set reasoning effort (compatible models)
aider /think-tokens 4096
Set the per-turn thinking-token budget
/model
Switch the main model on the fly
/models
Search the available models list

Files & Context 9

/add src/auth/*.py
Add files to the chat (Aider can edit them)
/drop tests/auth/test_login.py
Remove files from the chat to save context
/read-only docs/api-spec.md
Read-only reference, edits blocked
/ls
List files known to the chat
/reset
Drop all files and clear history
/clear
Clear the visible chat history
aider --map-tokens 2048
Set the repo-map token budget
aider --show-repo-map
Print the current repo map and exit
/map-refresh
Force a repo-map refresh now

Chat Modes 5

/code
Code mode: edit code directly (default)
/ask
Ask mode: discuss without editing files
/architect
Architect mode: planner + editor dual-model flow
/chat-mode
Generic mode switcher
/context
Enter context browsing mode

Git & Run 10

/git status
Run a git command inside the session
/commit "Implement JWT auth"
Commit dirty changes manually
/undo
Revert the last git commit Aider made
/diff
Show the diff of recent changes
/run pytest tests/
Run a shell command, feed output to chat (alias !)
/test
Run the configured test command
/lint
Run the configured lint command
aider --auto-commits
Auto git-commit after each change
aider --lint-cmd "ruff check"
Auto-lint after edits
aider --test-cmd "pytest"
Auto-run tests after edits

Session & Tools 11

/voice
Voice input via Whisper (requires portaudio)
/web https://docs.site
Fetch a webpage as rendered text into chat
/paste
Paste image or text from the clipboard
/copy
Copy the last assistant reply to the clipboard
/copy-context
Copy chat context as markdown
/save /path/script.md
Save the session as a replayable script
/load /path/script.md
Load and run commands from a file
/settings
Print effective settings
/report
Open a pre-filled GitHub issue with diagnostics
/help
Aider answers questions about itself
/exit
Quit cleanly

Advanced 6

aider --message "/ask where is this bug"
Send a single non-interactive message (--message/-m)
aider --edit-format whole
Whole-file edits (more reliable for small files)
aider --cache-prompts
Enable prompt caching to cut cost and latency
/multiline-mode
Toggle multiline input mode
/vim
Toggle Vim key bindings
/editor
Open $EDITOR to write a long prompt

Parameter matrix

ParameterEffectExample
--model <m>Specify the main modelaider --model claude-sonnet-4-6
--editor-model <m>Specify the editor model, used together with --architectaider --architect --model claude-opus --editor-model claude-sonnet
--weak-model <m>Specify a cheap weak model for sub-tasksaider --weak-model gpt-4o-mini
--architectArchitect mode: the planning model produces the plan, the editor model produces the diffaider --architect
--reasoning-effort <lvl>Set reasoning effort (when the model supports it)aider --reasoning-effort high
/think-tokens <n>Set the thinking token budget per turn/think-tokens 4096
--map-tokens <n>Set the repo map token budgetaider --map-tokens 2048
--show-repo-mapPrint the current repo map and exitaider --show-repo-map
--auto-commitsAuto git-commit on every changeaider --auto-commits
--test-cmd <cmd>Run the test command automatically after a changeaider --test-cmd "pytest"
--lint-cmd <cmd>Run lint automatically after a changeaider --lint-cmd "ruff check"
--edit-format wholeWhole-file editing, suited to small filesaider --edit-format whole
--message / -m <s>Send a single non-interactive messageaider --message "/ask where is this bug"
--cache-promptsEnable prompt caching to cut cost and speed upaider --cache-prompts
/add / /dropAdd files to the session / remove them to save context/add src/auth/*.py
/read-only <f>Read-only reference; editing forbidden/read-only docs/api-spec.md
/ask / /code / /architectAsk / edit code / two-model mode/ask where is this bug
/run <cmd> and /test / /lintRun a shell command and feed its output back into the session/run pytest tests/
/commit / /undo / /diffCommit dirty changes / undo the last commit / view the latest diff/undo
/save / /load <file>Save the session as a reproducible script / load and run from a script/save /path/script.md

Common pitfalls

SymptomSessions get slower and more expensive, and the model starts editing unrelated files.

CauseToo many files pile up in the session, and the repo map plus file contents together eat up the context budget.

FixKeep only 3-5 relevant files per task and /drop them when done; if needed use --map-tokens to shrink the repo map budget.

SymptomAider edits files it should not, or rewrites read-only docs.

CauseThe file was added to the editable set with /add; read-only files should use /read-only rather than /add.

FixSwitch reference material from /add to /read-only, and use /ls to check which files are actually editable in the current session.

SymptomQuality on complex refactors is unstable, and the plan goes off track halfway.

CauseA single model handles both design and editing, so it easily loses the overall intent in the details.

FixUse /architect to switch to two models: the planning model produces the plan, and the editing model only lands the diff.

SymptomTests break after a change, but you do not know which change introduced it.

CauseTests are not wired into the loop, separating change from verification.

FixStart with --test-cmd "pytest" --lint-cmd "ruff check" so they run automatically before every commit.

SymptomAfter one big change you want to revert it all, but undo will not do it.

Cause/undo only undoes the most recent git commit made by Aider; earlier changes need manual handling.

FixFor important tasks, start on a dedicated branch or keep --auto-commits on, then locate the commit with git log and revert as needed.

SymptomAsking in Chinese gets a generic English answer, or one that does not match the actual project structure.

CauseThe repo map token budget is too small, so the model does not get enough structural information.

FixFirst run aider --show-repo-map to see whether the map covers the relevant directories, then raise --map-tokens.

SymptomWhen reporting a problem you cannot explain the config clearly, and you pasted the key along with it.

Cause/report pre-fills diagnostic info, so sending the content directly risks a leak.

FixBefore submitting, print the effective config with /settings for a self-check, and if needed delete the secret lines from the /copy-context output by hand before sending.

Troubleshooting

  1. 1Confirm which files are actually included in the session

    /ls

    The output should contain only the files the current task needs; remove any extra ones with /drop.

  2. 2Check whether the repo map covers the target directory

    aider --show-repo-map

    It prints and exits, used to confirm the token budget is sufficient; if not, raise --map-tokens.

  3. 3Ask before acting, without making changes

    /ask where is this bug

    Ask mode does not change files, good for locating a problem before deciding how to fix it.

  4. 4View the full diff of the most recent change

    /diff

    Confirm the scope of the change matches expectations; on anything abnormal, immediately /undo back to the previous commit.

  5. 5Feed test output back into the session as evidence

    /run pytest tests/

    The command output is fed to the model, which is faster and more complete than copy-pasting errors by hand.

  6. 6Print the effective config and check the model settings

    /settings

    Focus on checking whether the main model, editor model, test/lint commands and auto-commit toggle match expectations.

Command Examples

Ask read-only first, then decide whether to let it edit

/read-only docs/api-spec.md /add src/main.py /ask what are the possible causes of this endpoint returning 500

/ask discusses without touching files. Keeping the spec read-only and the code in context lets it reason about the failure first, which is the safest way in: confirm the direction, then switch to /code.

Verify right after the edit, revert the whole batch if it fails

/code /run pytest tests/ /diff /undo

Each Aider edit lands as a git commit and /undo rolls back the commits it made itself. When tests fail, read /diff to see which files moved, then /undo the whole batch — far cleaner than undoing file by file.

Plan with the architect, let the editor model implement

/architect split rate limiting into middleware and config layers; give the plan first, do not change code /code

Large refactors drift when the main model goes straight to code. /architect produces the structure first, you review it, then /code implements — mistakes caught at the plan stage are the cheapest to undo.

Drop test files as context grows, keep production code

/add src/auth/*.py /drop tests/auth/test_login.py /ls

Context is finite and test files often eat a large share while contributing little to the patch. /drop only removes them from context (the files are untouched), and /ls confirms what is actually loaded so the model never "assumes" it has seen a file.

One-shot question without entering the interactive UI

aider --message "/ask where is this bug"

Useful in scripts and CI for a one-off "explain this code" pass. Feed files in with /add first; -m handles the single message then exits instead of sitting at the terminal waiting for input.

Common Pitfalls

  • Starting Aider with a dirty worktree lets generated commits swallow your half-finished changes. Check /git status first, or work on a clean branch.
  • --auto-commits commits after every edit; on a protected CI branch those commits fail halfway, leaving half-applied history that is painful to untangle. Leave it off at first.
  • export ANTHROPIC_API_KEY="sk-..." stays in your shell history on disk forever. Use read -s or a .env plus environment management instead.
  • Adding a .env or any file containing tokens via /add pushes that content into the model context and on to the remote API. /read-only prevents edits but still sends the text.
  • /undo only rolls back commits Aider itself created. Hand-made commits you made outside the session are untouched, so using it at the wrong moment loses your own work.
  • Closing the terminal without /exit leaves the session without a clean finish: uncommitted edits remain. Open /diff next time before deciding to commit or revert.
  • Text fetched by /web enters the context and can be treated as instructions (prompt injection). Do not /web untrusted URLs into a session where code will be edited.

Tips

  • Auto git-commit per change is Aider's killer feature: pair it with --test-cmd and --lint-cmd, and a bad edit is one /undo away.
  • For complex refactors use /architect dual models: a planner proposes, an editor emits diffs — higher quality than single-model end-to-end and usually cheaper.
  • Add only relevant files (3-5 per task), then /drop when done; smaller chats are faster, cheaper, and edit more precisely.
  • Use /ask first to let Aider plan before editing — figuring it out upfront avoids detours on complex tasks.

FAQ

When should I use /ask versus /code?

/ask discusses without touching files — ideal for explaining code or evaluating approaches — while /code edits files and is the default mode. In an unfamiliar repository, ask first and switch to code once the direction is agreed; this avoids sweeping edits before you have confirmed the plan. If a change goes wrong, /undo reverts the last git commit Aider made.

Why do I need to /add a file before it can be edited?

Aider only edits files you explicitly add to the session — /add src/auth/*.py makes it editable, while /read-only docs/api-spec.md brings it in as reference only and forbids modification. This is deliberate, so it never touches files you had not planned to change. Use /drop to remove files you no longer need and keep the context small.

What problem does --architect mode solve?

It splits the work across two models: a planning model produces the design first, then an editing model implements it. Compared with a single model editing directly, you get a reviewable plan before large changes land, which cuts wasted effort when the direction was wrong. The cost is roughly double in tokens and time, so reserve it for cross-module refactors and use the default mode for small edits.

How does Aider interact with git?

Aider is built around git: it commits automatically after each change and you can always /undo the last one. To verify, use /run pytest tests/ so it runs the command and feeds the output back into the conversation — faster than pasting errors by hand. Use /diff to review the most recent change before deciding to keep it.

How do I run Aider with a local model?

Prefix the model name with ollama/, for example aider --model ollama/codellama, with ollama serve already running. Architect mode works with local models too: --architect sets the planning model and --editor-model the editing one, and both can be local — though planning quality on complex tasks will drop.

Official References

Each command links to its official documentation below, so you can verify the latest usage and read deeper.

Maintained by LaoHand

Publicly updated on Aug 5, 2026, continuously proofread against official docs.

Contact Us

Wrong command or description? Send us corrections, business inquiries or product feedback by email.

Contact Us