How to break down a spec for AI coding agents

To break down a specification (spec) for an AI coding agent, answer the open questions about the whole feature, split it by what a user can do, and split again only where a part is too big for one agent session. Then write down which parts depend on which. The result is a tree of small specs, each with its own check, in an order you can follow yourself or hand to the agent.

Why a spec for a whole feature is too much for one session

An agent works inside a context window that holds the spec, every file it reads and the output of every command. Anthropic's best practices for Claude Code state the consequence: "LLM performance degrades as context fills." An agent near the limit loses track of earlier instructions, so the requirements at the top of a long spec compete with the thirtieth file the agent opened.

The other cost falls on you as the reviewer. A feature-sized spec produces a feature-sized diff, and a diff of thirty files can't be read against its spec criterion by criterion.

How to tell that a spec needs splitting

A spec is ready for one session when you can name the single check that proves it works. It needs splitting when any of these is true:

  • it describes several things a user can do;
  • its acceptance criteria fall into groups;
  • parts of it could be built and tested without the others;
  • one part has to exist before another can start.

A checkout flow for an online shop meets all of them. A cart, a payment step and a shipping step are each something a shopper does, each has its own edge cases, and nobody can pay before there is a cart.

Settle the questions about the whole feature first

Questions about the whole feature change where the cuts go, so they come before the first cut. For the checkout flow:

Question Answer Effect on the split
Can a guest check out without an account? Yes, with an optional account at the end Checkout has no sign-in part
Are shipping and billing addresses one form? No, two steps Shipping becomes a part of its own
Does the shop store cards for returning shoppers? No, one-time card entry Saved cards drop out of the feature

Write the answers into the top spec, because every spec below it inherits them. How to write a spec for an AI coding agent shows how to get an agent to ask such questions.

Split by what the user can do

A split by layer gives you a database part, an API part and an interface part. Each is tidy, none does anything a shopper can see, and nothing can be checked end to end until the last one lands.

A split by capability gives you a cart, a payment step and a shipping step. Each is a vertical slice through every layer it needs, and each can be tried, tested and reviewed alone.

Checkout flow
├── Cart
├── Payment
└── Shipping

Each part then gets questions of its own. For the cart, do totals update as the quantity changes, or on an "Update cart" button? For payment, does a declined card keep the shopper on the payment step? At the level of the whole feature these questions would have been noise, and for one part they decide what gets built.

Split again only where a part is too big

Apply the same signals to each part and split only the ones that fail:

Checkout flow
├── Cart
├── Payment
│   ├── Card entry and validation
│   ├── Declined-card handling
│   └── Order confirmation
└── Shipping

Cart and Shipping pass as they are. Payment has error paths and a confirmation, so it gets one more level. Branches of different depth are what to expect, because the parts of a feature are not equally complicated. Forcing every branch to the same depth produces trivial specs in the simple areas and oversized ones in the hard areas.

Write each leaf so that one session can finish it

A leaf spec is a spec with no sub-specifications. Leaves are what an AI agent implements. Each needs one outcome, criteria that can be checked, a line for what it depends on and a way to verify it.

# Declined-card handling

## Outcome
A shopper whose card is declined can correct it and pay, with the cart intact.

## From the specs above
- Guests can check out. There may be no account to attach anything to.
- Cards are entered once and never stored.

## Acceptance criteria
- Given a declined payment, when the decline comes back, then the payment
  step stays open with the card form and a message that names the problem.
- Given a declined payment, then the cart, both addresses and the shipping
  choice are unchanged.
- Given three declines in a row, then the shopper is offered another
  payment method.

## Out of scope
- Retrying a payment in the background.
- The wording of emails.

## Depends on
- Card entry and validation.

## Verify
- The payment integration tests pass, with three new decline cases.

Record which leaf depends on which

Declined-card handling needs Card entry and validation. Order confirmation needs a successful payment. Payment as a whole needs a cart to pay for. Write each of these as a line in the spec that depends on the other. A dependency that exists only as the order of a list is lost the first time the list is re-sorted.

The dependencies give you the build order, because the next leaf to build is one whose dependencies are all done. They also show which leaves share nothing. Shipping and Card entry and validation are independent, so two agent sessions can build them at the same time. Give each session its own branch or its own git worktree, which Anthropic's guide describes as running sessions "in isolated git checkouts so edits don't collide".

Give each leaf the decisions it inherits

An agent that implements a leaf needs the leaf itself, the decisions from the specs above that affect it, and what the specs it depends on produced. The "From the specs above" section in the example carries the decisions. For Declined-card handling that is the guest checkout and the absence of stored cards. The rest of the tree stays out of the session, where it would only fill the context window.

A leaf with a boundary still needs an agent that respects it. How to stop an AI coding agent's scope creep covers what to do when the agent reaches past the leaf.

Where to keep the tree of specs

The tree needs a home that the agent can read and you can change. A folder of Markdown files in the repository works with any agent: one file per spec, the folders following the tree and a "Depends on" line in each leaf. Breaking work down is also a step of spec-driven development (SDD), which the SDD guide describes in full, and the SDD tools compared each store the result in their own way.

Athenode, which I make, is a local console for AI coding agents that keeps the tree in a project outside the repository. To decompose a spec in Athenode is to break it down into one level of stages, each a spec of its own with its own questions, and any stage can be decomposed again. Dependencies are recorded as blockers. To apply a spec is to have your AI agent plan and implement each leaf under it in the order the blockers allow, and the run stops only when something falls outside the spec and needs you. How each leaf is tested, reviewed and committed, up to a pull request, is set once for the project. The docs describe how a spec is decomposed, and the quickstart starts from an empty project.

When a spec should stay in one piece

A breakdown has a cost. Every spec in the tree has to be written, read and kept true, and a small change doesn't repay that. Anthropic's test for planning applies to splitting as well: "If you could describe the diff in one sentence, skip the plan."

So a fix gets one short spec or none, and a feature gets a tree only as deep as its hardest part.

Sources

Start with one mind map

Install Athenode, run athenode init in your repository and answer your agent's questions about the next thing you want to build.

Install for free

Free on your machine, with no account.