
When you ask a coding agent to build a whole feature in one long session, it guesses product decisions instead of asking, bundles unrelated changes into one large pull request, and reviews its own code with the same assumptions it had while writing it.
A single session ends up holding raw source files, design decisions, test output, git diffs, and review comments in one context window.
Instead of running a feature from idea to pull request in a single session, I split the work across a thin orchestrator, six specialized subagents, a small external state note, and explicit human checkpoints. I wanted small, reviewable pull requests without babysitting every command, while keeping product decisions and merges in my hands.
One thin orchestrator and six narrow roles
Every file read and compiler error in a single session lingers in the transcript as stale output. Giving each role its own context window avoids that.
The main session acts only as a thin orchestrator. It interviews me when a product choice is open, pauses at checkpoints, tracks lightweight metadata (current stage, branch name, round number, PR number), and routes work to subagents. It never reads source files, never inspects diffs or PR comments directly, and never writes code or reviews inline, so its context stays small across the whole task.
Six specialized subagents do the actual work, each with narrow permissions:
| Role | What it does | What it cannot do |
|---|---|---|
| Researcher | Explores the codebase, existing specs, and closed dependency PRs. | Never writes specs, plans, or production code. |
| Spec Writer | Turns resolved decisions and research into numbered spec sections or acceptance criteria. | Never writes implementation plans or code. |
| Planner | Splits an approved spec into ordered GitHub issues, or checks a single issue's scope before coding. | Never edits production code. |
| Implementer | Writes code and tests, commits locally, triages review feedback, and opens or updates PRs. | Never verifies or reviews its own code. |
| Verifier | Runs the repo's exact format, lint, build, test, and diff-size checks. | Never edits code, never reviews style, never touches GitHub. |
| Reviewer | Reads repo rules, the spec, the diff, and full changed files to write a structured review. | Never edits code and never merges PRs. |
Only the implementer can modify repository source files. Because the verifier and reviewer stay read-only on source code, the implementer can never sign off on its own work.
Figure 1: The thin orchestrator coordinates six specialized roles across two flows, storing specs and run state in an external note.
Keeping specs and run state out of the repo
Six separate subagents still need a shared place to hand off decisions and outputs. Early on, I kept plans and work logs in a docs/ folder inside the repository, which got noisy fast: markdown plans inflated PR diffs, stale design docs lingered after merges, and switching branches meant juggling untracked notes.
Now, specs and per-issue work notes live in an external note store (I use my own notes app, though any structured markdown store with a CLI works). Each issue gets a single work note with a small header at the top:
STAGE: research | spec | plan | implement | gate | review | ready | needs-human | merged TRACK: fast-track | full ROUND: 1 FEATURE_SPEC_UUID: <spec-id> BRANCH: feat/comments/spam-threshold PR: none
Subagents read the sections they need and append their output (## Research, ## Spec, ## Plan, ## Implementation round 1, ## Gate round 1, ## Review round 1) to the same note. Because the state lives outside the conversation, I can stop at any stage and resume later from the recorded STAGE and ROUND without re-running earlier steps. Once a PR merges, the work note moves to an archive folder.
Flow 1: From rough idea to ordered GitHub issues
New features start with a design flow that ends at filed GitHub issues rather than code.
On an existing repository, the researcher first runs a quick recon pass over project conventions, manifests, entrypoints, and existing specs. That gives the orchestrator a short list of what is already settled in code and what is genuinely open, so I never get asked questions the codebase already answers. The orchestrator then asks 2 to 4 grouped trade-off questions, each leading with a recommended option, its benefit and downside, and an alternative. Once I answer, those decisions become the opening section of the feature note.
Next, the researcher inspects the relevant modules and constraints, and the spec writer turns the decisions into numbered sections (§1, §2, and so on) covering flows, non-goals, types, error handling, and verification. The spec writer justifies every new mechanism against a stated requirement, treats exploratory questions as open questions with their cost rather than automatic requirements, and closes the spec with a ### Size line estimating the capabilities and rough PR count. The workflow stops here for Checkpoint 1: I read the spec and its size estimate, push back on anything off, and approve it before any planning happens. If a single feature looks like more than about five PRs, the orchestrator leads with a cut that shrinks the first version before moving on.
After spec approval, the planner breaks the work into ordered GitHub issues and pauses again for Checkpoint 2, showing the breakdown, labels, and dependency order. For multi-issue batches, it never guesses future GitHub issue numbers: it uses symbolic placeholders (#<ISSUE_01>, #<ISSUE_02>), runs a dry-run check to verify that every dependency points strictly backward with no cycles, and records each created issue in a local JSON mapping file as it files them so a failed CLI call can resume without creating duplicates. Once I confirm and the issues are filed, the workflow stops without creating a branch or editing code.
Keeping pull requests reviewable: small specs and capability-sized slices
Filing issues up front only helps if the spec stays lean and each issue lands a coherent slice of work. Both oversized pull requests and dozens of tiny per-layer PRs slow a feature down, because every extra issue adds another branch, check run, review loop, and merge.
The planner (and the implementer's pre-flight scope check) aims for the fewest PRs that each deliver one working capability and stay easy to review:
- Keep each capability's layers together: A capability is something a user or caller can actually do once the PR merges. Its entity, view DTO, storage query, service method, route, and UI travel together in one PR rather than being split by layer or type. Two capabilities a user could use separately still become two PRs, even when each is small.
- Work in vertical end-to-end waves: Wave 1 delivers the primary resource or capability end-to-end (including its own client or UI pieces) before Wave 2 starts a secondary resource, even when the spec organizes headings by layer.
- Size by production diff, not line-count dogma: Typical PRs land around 150 to 400 lines of production code (excluding tests and lockfiles), with a 500-line hard ceiling. Smaller is fine for a small capability without padding or splitting it further. Past ~400 lines, the first check is whether the spec is overbuilt; if the capability truly needs a split, it splits into smaller working capabilities (such as read-only before editing, or the main path before edge cases), never into horizontal layers. Move-only refactors, heavy shared setup, and risky behavior changes can still earn their own PR when isolating them makes review safer.
- Keep tests in proportion and let the maintainer override: Tests focus on acceptance criteria and risky boundaries (auth, data loss, leaks) rather than redundant permutations. Explicit maintainer scope calls ("keep this in one PR", "fewer issues") override the defaults and are passed verbatim to every subagent.
Because Wave 1 has to compile and pass tests on main without breaking when Wave 2 lands, Wave 1 constructors stay minimal and later waves extend them additively:
// Wave 1: compiles and tests cleanly without Wave 2 collaborators let service = CatalogService::new(book_repo); // Wave 2: additive builder extends cleanly without breaking Wave 1 callers let service = CatalogService::new(book_repo).with_loan_lookup(loan_repo);
View DTOs follow the same rule: Wave 1 constructors take only Wave 1 fields and initialize deferred fields with clean defaults (None, Vec::new(), or Default::default()), leaving additive builders or setters to populate them in Wave 2.
Flow 2: From GitHub issue to pull request
When I pick up a filed issue, the orchestrator starts with a lightweight preflight. It checks every Depends on #<M> link first, stopping immediately if any prerequisite is still open. When dependencies are closed, it records their closing PR numbers and summaries in the work note so the first subagent inherits the exact file paths, types, and signatures that actually landed.
Issues with an approved spec section, a clear acceptance checklist, and one working capability under the 500-line production ceiling take the fast track straight to the implementer. Fast track skips research, spec writing, and planning, while still running dependency checks, a scope sanity check, verification, and local review. Raw features or bugs that lack a spec, have an unverified root cause, or look oversized take the full track through researcher -> spec-writer -> planner, pausing if product ambiguities or an oversized scope turn up.
The local verification and review loop
The biggest day-to-day improvement came from keeping broken builds and obvious review comments off GitHub. Nothing gets pushed until it survives an independent verification gate and a local code review.
Figure 2: Every change passes an independent verifier gate and local reviewer before anything is pushed to GitHub.
- Local build: The implementer checks that existing code matches the spec (stopping with
NEEDS-HUMANif it spots a contradiction instead of guessing), implements the slice on a feature branch, runs the repo's documented checks, and commits locally without pushing or opening a PR. - Independent verification gate: A separate verifier subagent runs only the format, lint, build, and test commands listed in the repo's instructions (no ad-hoc local servers, smoke scripts, or live accounts), plus a production diff-size check against the base branch. Anything that can only be verified live is noted as not yet manually tested in the PR. If anything fails, the reviewer is skipped and the same implementer instance is resumed to fix the failure.
- Independent local review: Only after
GATE: PASSdoes an independent reviewer (fresh from the implementer on round 1, then reused across follow-up rounds in the same cycle) inspect the local git diff, the full modified files, the repo rules, and the spec. It appends## Review round Nto the work note with exact file paths, line numbers, severity (Critical:/Required:vsNit:/Optional:), and concrete fixes, with zero GitHub comments posted. - Evidence-based triage before editing: If the reviewer returns
VERDICT: CHANGES, the orchestrator resumes the same implementer (so it keeps its working context) and requires it to classify every finding before touching any source file. Confirmed bugs or rule breaks are markedAccept; claims refuted by the code, spec, repo rules, or library docs are markedRejectwith exact evidence; and items where the spec and docs are silent on a product or data choice (what users see, public API or data semantics) are markedNeeds human review. Implementation choices settleable from the code and repo rules are decided directly by the implementer with a short note explaining why, and fixes the maintainer already asked for are implemented without re-asking. If any item needs human review, the implementer stops before editing even the accepted items, so a human decision does not collide with half-applied changes. - Hard cap at 3 rounds: Accepted fixes go back through the verifier gate and then to the reviewer, which reads the implementer's point-by-point responses so it does not repeat settled items. If round 3 still returns
CHANGES, the loop stops and escalates to me instead of spinning indefinitely. - Open PR, leave merge to a human: Once the reviewer returns
VERDICT: PASS(non-blocking nits do not trigger another round), the implementer pushes the branch and opens the PR. Once the PR is open, the workflow stops and leaves merging to me.
Post-PR GitHub review comments go through the exact same local loop. When a human (or an automated PR reviewer) leaves comments on an open PR, the implementer reads inline threads, review bodies, and conversation comments, triages them locally, commits fixes without pushing, passes the verifier gate, and lets the local reviewer inspect both the diff and the planned thread replies. Only after a local pass does it push and reply to every triaged comment in one step (re-checking for newly added comments before wrapping up).
Encoding engineering habits as on-demand skills
To share engineering standards across roles without copying a long prompt into every repository, I package recurring instructions into small skills that agents load on demand. Process skills cover workflow steps like interviewing for trade-offs, breaking a spec into capability-sized issues, triaging PR comments, structuring a code review, or auditing bloated test suites. Domain skills cover stack habits like error handling, module layout, lean deterministic tests, dependency management, or frontend state.
On disk, each skill is just a small folder with a short entrypoint file (SKILL.md) and optional reference files (references/*.md) loaded only when needed. The multi-agent workflow uses the same layout: SKILL.md holds only the orchestrator's routing rules and checkpoints, while each role's instructions live in a separate file (references/roles/implementer.md, references/roles/reviewer.md, and so on). When the orchestrator spawns a subagent, it passes the path to that role file without reading it itself, which keeps role-specific instructions out of the orchestrator's context.
Because each role loads only the skills relevant to the task in front of it, the orchestrator never pulls in testing or framework rules, and an implementer editing backend code does not carry frontend conventions in its context. The implementer and the reviewer also read the same domain skills. When a local review round flags a problem, it checks the diff against the exact conventions the implementer was expected to follow, which keeps feedback concrete and cuts down on back-and-forth rounds.
Skills also pay off outside the multi-agent pipeline. When I skip the full workflow for a small fix in a single chat, the same domain skills still shape the code and tests. Whenever a PR review turns up a mistake an agent keeps repeating, I add that rule (along with the reason behind it) to the right skill once so future sessions stop making it. Over time, I also started turning real session transcripts into automated evals to verify that a new rule actually changes agent behavior without breaking existing habits (a topic worth its own follow-up post).
Token efficiency
Splitting a feature across six roles sounds like it should burn far more tokens than a single chat, but on multi-file features the opposite is often true.
First, every role runs in a short, fresh conversation. In a long single session, each new turn re-sends the whole transcript: old file reads, earlier diffs, failed test logs, and abandoned approaches. Handing off through an external work note lets each subagent start fresh with only the context it needs. Second, upfront scoping produces fewer back-and-forth retries. Because the researcher checks existing code first, the interview settles open trade-offs up front, and the planner keeps the spec lean and scopes each issue to one working capability, the implementer can usually land a step in one shot instead of spending ten turns steering out of misunderstandings. Third, narrow roles unlock per-role model routing. Design, planning, and code review (spec writer, planner, reviewer) run on higher-reasoning models, while codebase recon, scoped implementation, and running verification commands (researcher, implementer, verifier) run on faster, cheaper models because the spec and check commands are already concrete.
A few built-in guards also keep token usage from creeping up: the orchestrator passes pointers (§N, closing PR numbers, work note IDs) instead of pasting file dumps; fast-track routing skips redundant design stages on spec-backed issues; a failing verifier gate skips the reviewer and resumes the same implementer so it reuses its working context; follow-up local review rounds reuse the same reviewer; and non-blocking nits plus the 3-round cap prevent runaway loops.
For a typo fix or a one-line change, spawning multiple roles still costs more tokens than a single prompt. The savings show up once a single chat would otherwise grow long and start repeating itself.
The trade-offs
- Slower wall-clock turnaround on small edits: Even when token usage stays reasonable on larger features, spawning separate roles and running a local verification and review loop takes more wall-clock time than a single prompt. For a typo fix, a quick experiment, or a one-line tweak, I skip the whole pipeline and edit directly.
- Keeping the orchestrator thin takes discipline: Models naturally want to be helpful by reading a source file or fixing a small bug themselves. Without explicit boundaries, the orchestrator slowly turns back into a single bloated session.
- Tooling and sandbox friction: Subagents need working shell access for git, build tools, test runners, and CLIs like
ghor a notes client. Overly restrictive read-only sandboxes break the handoffs, and the verifier has to treat an unexecutable check asBLOCKEDrather than faking a pass. - Upfront design friction: Pausing for an interview, spec approval, and issue confirmation feels slower than watching code stream onto the screen right away. It pays off on multi-file features, and feels heavy when you are just prototyping to learn how a library behaves.
Where to start
You do not need all six roles or a custom note store to get most of the benefit. If you want to borrow pieces of this for your own setup, start by separating implementation from verification and review: even with just two agents, having a fresh session run your exact test suite and review the local diff against your repo rules before pushing catches issues that a single session misses. Adding a 3-round cap and an explicit Accept / Reject / Needs human review triage step before edits keeps that loop honest and stops an agent from blindly applying bad feedback or silently inventing product behavior.
For tiny fixes, a single prompt is still faster. Once a feature spans multiple files, trading one crowded session for narrow roles, a shared work note, and a local review loop is what keeps pull requests small enough to actually read.
Comments
No comments yet. Be the first to comment!
Leave a comment
Comments are moderated and may take some time to appear.