跳到正文
DEV Community· nexus ai·· 2 天前AI 評分54

按任務而非項目選擇模型:Aider 成本控制規則

Pick the Model Per Task, Not Per Project: My Aider Cost-Control Rules

AI 導讀

作者分享 Aider 的按任務選模與控費規則,指出每次訊息都會附帶 repo map、已加入檔案及聊天記錄,因此成本管理重點在模型分工和上下文控制。建議用弱模型處理提交訊息和摘要,按工作難度選擇主模型,並以 `/add`、`/read-only`、`/drop`、`/tokens` 和 `/clear` 管理上下文;同一修改需超過約 3 次修正提示時便升級主模型。

正文

nexus ai

Aider is free. The model isn't. Every message you send carries the repo map, your added files, and the chat history — so cost control in Aider is mostly context control. These are the rules that keep my bill boring.

Pick by role, not by brand

Aider has three model roles: the main editor, a weak model (commit messages, summaries), and — in architect mode — an architect plus an editor. My simplified matrix:

  • Learning / small projects: a mid-tier frontier model as main, a mini/Haiku-class model as weak. Mid-tier edits reliably at a fraction of flagship prices.
  • Hard, multi-file features: flagship model, or architect mode — flagship architect planning, mid-tier editor executing. Planning tokens are cheaper than wrong-edit tokens.
  • Bulk mechanical edits (renames, format migrations): a low-cost model is fine. Review the diffs closely.
  • Private / offline code: a local model via Ollama. $0 marginal cost; slower and weaker — know the trade you're making.
  • Huge repo, mostly questions: a large-context model in /ask mode. Questions need context room, not editing reliability.

The five habits that actually move the bill

  1. Set a weak model. Commit messages and history summaries run constantly. On a flagship main model, they quietly tax every single edit. One config line removes that tax.
  2. Curate context like it's metered — because it is. /add only what will be edited, /read-only for reference, /drop when done. /tokens shows what you're carrying. A file left in chat "just in case" is paid for on every message.
  3. Size the repo map. On large repos, a smaller map-tokens setting trims what Aider sends each turn.
  4. Turn on prompt caching once your workflow is stable (--cache-prompts, notably effective with Claude models). It cuts the cost of re-sent context in long sessions.
  5. Start fresh between tasks. History accumulates tokens. /clear or a new session per task.

When cheap is expensive

Cheap models fail predictably: mangled edit formats, ignored instructions, loops that burn 10 turns doing what a strong model does in one. My rule: if a session needs more than ~3 corrective prompts on the same edit, I switch the main model up a tier mid-session (/model). My time is the scarcest token in the system.

And one honesty note: Aider's in-session cost figures are estimates. Your provider's usage dashboard is the bill of record — check it, and check current prices before a long session, because they change too often to print.


These rules are the summary of the cost-control guide in a $10 pack I put together — six workflow playbooks, the full Git safety guide, and my templates (model-selection matrix, checklists, full .aider.conf.yml): https://whop.com/checkout/plan_Qnb9d21JZ7LEa

Start of the series: https://dev.to/workflownexus/6-repeatable-aider-workflows-and-the-git-routine-that-makes-them-safe-3ffl — new to Aider? The free Starter Kit covers installation and your first session: https://whop.com/checkout/plan_diZ6ymgxjRMz2

What's your model setup for AI coding — one model for everything, or do you switch per task?

來源:DEV Community · dev.to