Coding-Agent Architectures

Software is the best environment agents have: a verifier (tests) that is objective, fast and free. Every serious coding agent is built around that gift — the architectures differ mainly in how they explore, how they parallelize, how they survive long tasks and how their work gets reviewed, and the mechanics underneath decide whether any of it works.

G-01The Test / Diagnose Loop

/coding-agents/test-loop

Understand, explore, plan, edit — then let the test suite verify, and diagnose real failures instead of guessing.

Step-by-step walkthrough8 steps
  1. Before touching anything: read the code that’s actually there.
  2. Plan the smallest change that could work.
  3. Edit.
  4. The test suite is the verifier — objective and free.
  5. Fail. The traceback names the exact line.
  6. Diagnose against the real error, not a guess.
  7. Edit again — narrowly.
  8. Green. Commit. The loop, not the model, produced the reliability.
Key insight

The traceback is the highest-signal context a coding agent ever receives. Architectures that route it back into the edit step outperform ones that just retry.

Failure mode

Skipping exploration: an agent that edits before reading the codebase produces plausible patches against an imagined repo.

G-02Single Agent vs Multi-Agent

/coding-agents/single-vs-multi

One agent with full context and no coordination — or several specialists working in parallel, plus the overhead of keeping them coherent.

Step-by-step walkthrough2 variants · 8 steps

One agent

  1. One agent, one context: everything it learned exploring is still there while editing.
  2. Serial, so wall-clock bound — but every step sees full history.
  3. Done. Slower, simpler, often more correct.

Multi-agent

  1. The orchestrator splits the feature across four specialists.
  2. They run in parallel — each in its own context, blind to the others.
  3. The hidden tax: agents must sync assumptions they no longer share.
  4. Integration reconciles four partial views — real merge conflicts, real re-work.
  5. Faster wall-clock only if the task splits cleanly. More agents ≠ better.
Key insight

Multi-agent buys wall-clock speed on cleanly-splittable work and nothing else. Coordination cost grows with coupling, and most features are more coupled than they look.

Failure mode

Splitting a coupled task: four agents each holding a quarter of the picture will confidently build four incompatible quarters.

Further reading

G-03CI Feedback Loop

/coding-agents/ci-loop

Push, let CI verify remotely, and let failure events — with logs — wake the agent to fix and push again.

Step-by-step walkthrough4 steps
  1. The agent pushes; CI is the verifier it doesn’t control.
  2. Red. The failure event — with logs — wakes the agent.
  3. Fix, push, repeat. Event-driven, not polling.
  4. Green → merge.
Key insight

CI extends the verifier beyond the agent’s machine: same loop as test/diagnose, but event-driven and running against the team’s real gates.

Failure mode

Poll-and-pray: agents that sleep-loop on CI status burn tokens and miss context that the failure event would have carried for free.

G-04Plan-first Coding

/coding-agents/plan-first

Produce a reviewable plan before any edit; humans veto cheaply at the plan stage.

Step-by-step walkthrough4 steps
  1. The agent plans before touching a single file.
  2. The plan is the review surface: cheap to read, cheap to veto.
  3. Or sent back — a plan revision costs minutes; a diff revert costs hours.
  4. Approved → the edits execute a design a human already agreed to.
Key insight

The plan is the highest-leverage review surface in the loop: minutes to redirect there, hours to unwind a wrong diff.

Failure mode

Plans that are vibes: if the plan doesn’t name files and steps, approval is meaningless and drift is guaranteed.

Further reading

G-05Test-driven Agent

/coding-agents/test-driven

Write the failing test first; the test then defines “done” unambiguously.

Step-by-step walkthrough4 steps
  1. The spec becomes a test before it becomes code.
  2. Red first — and failing for the right reason, or the test is wrong.
  3. The failing test is an unambiguous definition of done.
  4. Green. The agent can’t declare victory early — the test won’t let it.
Key insight

TDD fixes the coding agent’s worst habit — declaring victory early. The agent cannot argue with a red test.

Failure mode

The agent writes a test that asserts its implementation rather than the spec: green, and wrong.

G-06Reviewer Agent

/coding-agents/reviewer-agent

A separate agent reviews the diff with fresh context, catching what the author’s context normalized.

Step-by-step walkthrough4 steps
  1. The author’s context has normalized its own mistakes — hours of it.
  2. The reviewer sees only the diff and the repo. No sunk reasoning to defend.
  3. Findings — the bugs the author literally could not see.
  4. Fixes flow back; review repeats until clean. Same model, different context, different blind spots.
Key insight

Author blindness is a context problem, so the fix is a context boundary — the reviewer’s power is precisely what it hasn’t seen.

Failure mode

Sharing the author’s conversation with the reviewer “for context”: you’ve rebuilt the same blind spots and doubled the cost.

Further reading

G-07Worktree Parallelism

/coding-agents/worktrees

Each agent works in its own git worktree; merge conflicts are surfaced by git, not by luck.

Step-by-step walkthrough4 steps
  1. Each agent gets a real checkout — no shared files, no stepping on edits.
  2. True filesystem isolation: each can run its own tests, its own builds.
  3. B and C touched the same module — and git says so, loudly, at merge.
  4. Conflicts surfaced by tooling beat conflicts discovered in production.
Key insight

Filesystem isolation makes parallel agents boring in the best way — and routes their disagreements through tooling built to resolve them.

Failure mode

Parallel agents in one working directory: silent overwrites, corrupted builds, and no record of who changed what.

Further reading

G-08Researcher + Implementer

/coding-agents/researcher-implementer

One agent reads the codebase and produces a digest; a second implements against it with a clean context.

Step-by-step walkthrough4 steps
  1. Exploring a huge repo fills a context window with mostly-irrelevant reading.
  2. The researcher’s whole job is compression: which files, which conventions, which traps.
  3. The implementer starts fresh with only the 2k tokens that matter.
  4. The digest is a contract: anything the researcher missed, the implementer can’t know.
Key insight

Splitting read-heavy from write-heavy work means the implementer never pays the exploration tax — its whole window is for the change.

Failure mode

A digest that omits one convention or trap: the implementer can’t know what the researcher didn’t write down.

Further reading

G-09Checkpointing

/coding-agents/checkpointing

Commit at every good state; a bad direction becomes a reset, not a restart.

Step-by-step walkthrough4 steps
  1. Every good state becomes a commit. Git is the agent’s durable memory.
  2. From safety, the agent can afford to try the risky approach.
  3. It doesn’t work out. Without a checkpoint this means untangling by hand.
  4. With one: reset, and the failed branch cost nothing but tokens.
Key insight

Cheap recovery changes what the agent can afford to attempt — risky refactors are rational when undo is free.

Failure mode

One giant commit at the end: when step 14 of 15 goes wrong, all fifteen are tangled together.

Further reading

G-10Repo Indexing & Code Search

/coding-agents/repo-indexing

Symbol maps and semantic search turn ten rounds of grep into one hop.

Step-by-step walkthrough4 steps
  1. Navigation is most of a coding agent’s token bill.
  2. Without an index: grep, read, grep again — 16 tool calls of guessing.
  3. With one: the question maps to the file in a single hop.
  4. Same destination — a fraction of the context spent getting there.
Key insight

Navigation is most of a coding agent’s token bill; an index converts that recurring cost into a one-time build.

Failure mode

A stale index: confidently wrong answers about code that moved is worse than grep’s slow honesty.

G-11Computer-use Coding

/coding-agents/computer-use

The agent drives a real browser to verify UI changes — closing the loop unit tests can’t see.

Step-by-step walkthrough4 steps
  1. The change is to something a test can’t see: layout, color, flow.
  2. The agent drives the actual app the way a user would.
  3. The screenshot goes back into the model — vision closes the loop.
  4. “Looks right” becomes a verifiable step, not a hope.
Key insight

A screenshot in the loop makes “looks right” a checkable claim: vision extends the verifier to layout, styling, and flow.

Failure mode

Verifying single frames only: the bug that needs a hover, a scroll, or a second click stays invisible.

G-12Diff Application Strategies

/coding-agents/diff-application

How an edit actually reaches the file — reprint the whole thing, or emit an anchored block the harness has to match.

Step-by-step walkthrough2 variants · 12 steps

Whole file

  1. The simplest strategy: ask for the whole file back.
  2. It always applies. There is no matching step, so there is nothing to fail.
  3. The write is a plain overwrite.
  4. But a three-line fix costs nine hundred lines of output — every time, on every retry.
  5. And whatever the model quietly failed to reprint is now gone — no conflict, no error, just missing code.
  1. The model emits only what changes, wrapped in enough surrounding lines to locate it.
  2. Output is proportional to the edit, not to the file. A three-line fix costs three lines.
  3. The harness has to find that anchor in the real file, byte for byte.
  4. Matched → applied in place, and everything the model never mentioned is untouched by construction.
  5. No match. The file moved on, or the model reproduced the whitespace wrong.
  6. This is the good failure: it stops, says so, and nothing was written.
  7. Re-read the file, re-anchor, retry. A loud failure beats a silent overwrite every time.
Key insight

This is the most consequential mechanism in coding agents and the least discussed. Whole-file rewrites can never fail to apply and can silently delete; anchored edits can fail to apply and never silently delete. Prefer the failure you can see.

Failure mode

Treating a failed match as a bug in the strategy. A no-match is the mechanism doing its job — the file moved, and the right response is to re-read and re-anchor, not to fall back to overwriting.

G-13The Verifier Ladder

/coding-agents/verifier-ladder

Format, lint, typecheck, unit, integration, CI — ordered by seconds to signal, cheapest first.

Step-by-step walkthrough7 steps
  1. The agent makes an edit. Something has to tell it whether that edit was any good.
  2. Not one check — a ladder, ordered by how fast each rung can answer.
  3. The cheap rungs run first and catch the most common mistakes in seconds.
  4. A type error at rung three — and the ladder stops. The four-minute suite is never started.
  5. Failure goes straight back to the edit, with the traceback, seconds after the mistake.
  6. Fix and climb again. Most iterations never leave the first three rungs.
  7. Only a change that has cleared every cheap rung is allowed to spend twenty-two minutes of CI.
Key insight

The test loop draws one verifier; in practice it is a ladder, and the ordering is the design. Most iterations never leave the bottom three rungs, which is what makes an agent that edits fifty times an hour affordable.

Failure mode

One monolithic “run the tests” step. The agent waits four minutes to be told about a syntax error, and every retry costs the full suite again.

G-14Repo Conventions as Context

/coding-agents/repo-conventions

A checked-in instructions file that loads every session — how a codebase tells an agent its rules.

Step-by-step walkthrough7 steps
  1. A repository knows things no model can infer: which script to run, which directory is generated, which pattern is banned.
  2. So write them down in the tree, where they version with the code that made them true.
  3. Every session loads it. Nobody has to remember to paste the conventions in.
  4. Commands and traps earn their place — the things that are expensive to discover and cheap to state.
  5. Restating what the code already says does not. It goes stale on the first refactor and misleads every session after.
  6. Because it is a checked-in file, it changes through review — the same gate as the code it describes.
  7. The agent follows the house style without being told, and the file is how the house says what its style is.
Key insight

Put in it what is expensive to discover and cheap to state: the build command, the generated directory, the pattern that looks fine and breaks production. Because it is in the tree, it changes through review, like the code it describes.

Failure mode

Restating what the code already says. Those lines go stale on the first refactor and then actively mislead every session, which is worse than never having written them.

Further reading

G-15Integrating Parallel Work

/coding-agents/integrating-parallel-work

Where two isolated agents’ branches meet — and who holds both intentions well enough to resolve them.

Step-by-step walkthrough8 steps
  1. Two agents, two worktrees, no shared filesystem. That part works.
  2. Each commits to its own branch, unaware of the other.
  3. Both happened to touch the same config file. Neither had any way to know.
  4. The first branch merges cleanly. Parallelism looks like it worked.
  5. The second lands on a file that no longer looks the way its author left it.
  6. Git surfaces the conflict — which is the good outcome. Silent overwriting was the alternative.
  7. Resolving it needs both intentions at once, and neither agent has ever seen the other’s.
  8. So integration is its own role — one place that holds both changes, not a ping-pong between authors.
Key insight

Worktrees make isolation cheap, which is the easy half. The merge is the hard half, and it needs a role: one integrator holding both changes, rather than a conflict bounced between authors who have each seen only their own.

Failure mode

Handing a conflict back to the agent that wrote one side. It resolves in favour of its own branch, because its context contains no reason not to.

Further reading

G-16Environment Bootstrap

/coding-agents/environment-bootstrap

Clone, install, build, seed, green — everything that has to work before an agent can begin.

Step-by-step walkthrough7 steps
  1. A background agent wakes up in a container with nothing in it.
  2. Before a single line can be read, five things have to work.
  3. Fixtures and a green baseline included — an agent that cannot run the tests has no verifier at all.
  4. This is where autonomous runs die. Not on the task — on a native dependency that needed a system package.
  5. The fix is to make setup a script in the repo, not lore in someone’s shell history.
  6. Run it in CI as well, so it breaks in a pull request instead of in an agent session at 3am.
  7. Only then does the agent start — on a baseline that is known-good rather than assumed.
Key insight

Autonomous coding runs fail here more than anywhere else, and never on the interesting part. A setup script in the repo, exercised by CI, turns the most common failure into one that breaks in a pull request instead of at 3am.

Failure mode

Setup that lives in someone’s shell history. It works on the machine it was written on and nowhere else, and the agent’s transcript is forty minutes of dependency errors.

G-17Background Agents

/coding-agents/background-agents

Dispatch a task to a remote sandbox, walk away, and come back to a branch and a pull request.

Step-by-step walkthrough8 steps
  1. A developer hands off a task and closes the laptop. Nothing about the run needs them present.
  2. The task lands in a remote sandbox: a fresh clone and the repo’s own setup script, not someone’s machine.
  3. The agent works unattended — explore, edit, and run the checks itself, because nobody else is there to.
  4. The output is not a chat reply. It is a branch and a pull request, and pushing it starts CI.
  5. CI goes red. The failure event, logs included, wakes the agent — nothing polls.
  6. Once the PR is ready, the developer is notified and reviews it when they choose. Hours later is fine.
  7. Review comments are events too: they wake the same agent, on the same branch, to push a fix.
  8. Green, comments resolved. The human spent minutes reviewing instead of hours supervising.
Key insight

The unit of work changes from a conversation to a pull request. The human stops supervising steps and starts reviewing results, and CI failures and review comments, not a watching person, are what wake the agent back up.

Failure mode

Dispatching work the sandbox can’t verify. With nobody watching and no runnable tests, the agent’s only signal is its own confidence, and the PR arrives looking finished.

Further reading

G-18Hooks & Lifecycle Events

/coding-agents/hooks

Scripts the harness runs at fixed moments in a session — session start, before a tool call, after it, at the stop — regardless of what the model decides.

Step-by-step walkthrough7 steps
  1. A session has fixed moments: it starts, it is about to call a tool, the call returns, it declares itself done.
  2. Instructions can ask for the same things — but the model weighs them against everything else, and forgets.
  3. A hook is a script the harness runs at the moment itself. At session start: put the branch and open task in context.
  4. Before a tool call, a guard sees the exact command — and can refuse it, returning the reason as context.
  5. After every edit, the formatter and linter run. Not when the model remembers — every time.
  6. When the agent says it is done, the tests run first. Red means the turn cannot end.
  7. Instructions shape what the model tries to do; hooks decide what happens regardless.
Key insight

An instruction is a request the model weighs against everything else in its window; a hook is code that runs at the moment itself. Anything that must happen every time, such as formatting, a blocked path or tests before “done”, belongs in a hook.

Failure mode

Slow or noisy hooks. A thirty-second check after every edit, or a hook that pours a thousand lines of lint back into context, taxes every step of every session.

Further reading

G-19Language-server Integration

/coding-agents/language-server

The agent asks the same type engine an editor uses for definitions, references and diagnostics, instead of searching text.

Step-by-step walkthrough7 steps
  1. The agent needs to change save(). First question: who calls it?
  2. Grep answers a different question — where does the text “save(” appear — and returns comments, strings and three unrelated save methods.
  3. A language server answers the real one: it already knows the project’s symbols and types.
  4. The definition and every true reference, exact — one call, nothing to read through and discard.
  5. Now the agent edits. The server re-checks the changed file the moment it is written.
  6. A new type error — the second argument is now a string — pushed back in seconds.
  7. Fixed before any test runs. The cheapest rung of the verifier ladder, attached to every edit.
Key insight

Grep answers “where does this string appear”; a language server answers “what refers to this symbol”. Diagnostics pushed after every edit add a type check to each change, seconds before any test could run.

Failure mode

Trusting a server that is still indexing or misconfigured for the repo layout. It reports stale or false errors, and the agent spends its turns chasing imports that were never broken.

G-20Reviewing Agent-authored PRs

/coding-agents/reviewing-agent-prs

What a reviewer, human or bot, checks in an agent’s pull request that green CI does not: scope, tests, real APIs and evidence.

Step-by-step walkthrough9 steps
  1. Agents open pull requests faster than any team has ever received them.
  2. Each arrives green, with a summary and the trajectory: every command the agent ran and what came back.
  3. They all converge on one scarce resource — a person’s attention. Review, not generation, is now the bottleneck.
  4. Scope creep: files the task never mentioned, “tidied” along the way. Green CI does not care.
  5. Existing tests weakened in the same diff — an assertion loosened until it passed.
  6. An API that does not exist, called confidently, behind a mock that makes the test pass.
  7. The trajectory is the evidence: did it run the tests and read the output, or only say it did?
  8. Any “no” goes back with its reason, as a narrower task — not quietly fixed by the reviewer.
  9. Four yeses → merge. Small, scoped PRs with evidence attached are what keep each review cheap.
Key insight

Once agents write most of the diffs, review is the bottleneck, so the design goal is a cheap review: small scoped PRs, a summary with evidence attached, and a reviewer bot for the first pass. The trajectory is the cheapest evidence there is.

Failure mode

Reviewing an agent PR like a trusted colleague’s. A confident, tidy, green diff invites a skim, and a skim misses the loosened assertion and the helper that doesn’t exist.

Further reading

Elsewhere in the atlas