Aglio blog

November 13, 2026 · Aglio team · 3 min read

Write a spec an agent can actually follow

Most agent failures start in the card, not the code. How to state done, draw the edges, and write a spec that survives contact with a builder.

Most agent failures start before a single line of code exists. The card was a wish, not a spec. The agent filled the gaps with plausible guesses, wrote something that worked for the happy path, and handed back a pull request nobody asked for.

Aglio treats the card as the contract. The planning chat turns a rough idea into agreed text, and only accepted content reaches the builder. That constraint is not bureaucracy. It is the cheapest place to catch a misunderstanding, because prose costs minutes and a wrong pull request costs an afternoon.

Here is what a spec that survives contact with an agent looks like.

Say what done means

"It should work" is not a definition. Name the observable outcome, then name how someone confirms it. A user can sign in with a magic link. A failed upload shows an inline error and keeps the file selected. The digest email arrives at most once per day per user.

If you cannot write the check, the task is not ready. Half of spec writing is discovering that the requirement is two requirements wearing one title.

Draw the edges

Agents are literal in the wrong places and creative in the wrong places. Spell out what is out of scope. No database migration. Do not touch the billing code. Keep the existing API response shape. Leave the footer alone.

A non-goal line saves more review time than any positive requirement, because it is the only thing standing between a narrow fix and a refactor nobody requested.

Ground it in the current code

Point at the file, the component, the table, the endpoint. "The header in apps/web/src/components/marketing-header.tsx" beats "the header". Reference the existing pattern you want copied: the dialog wrapper, the table wrapper, the way validation errors are returned. Imitation is a reliable instruction. Invention is not.

If the codebase has two ways to do the same thing, say which one wins. Otherwise the agent picks the newest, or the oldest, or a third thing.

Include the ugly cases

Empty state. Long names. A user with no projects. A network call that times out. A permission check that fails. The agent will handle the middle of the happy path without help. The edges are where the questions are, so ask them yourself on the card instead of letting the run stall.

Attach the evidence you already have

A screenshot of the broken layout, a log line, a Figma frame, a sample payload. Attachments stay in the planning thread next to the discussion that produced them, so nothing is described twice and nothing drifts.

Ask for proof in the same breath

State the checks you expect: unit tests for the parser, lint clean, production build. Aglio records verification evidence on the card, and a run cannot call itself done without it. Naming the evidence up front means the agent plans for tests instead of bolting them on.

Keep one decision per card

A card that renames a column, adds an endpoint and redesigns a page is three cards pretending to be one. Small cards produce small diffs, small diffs get reviewed properly, and a failure costs one card rather than a sprint.

Questions are part of the process

When something in the spec is genuinely ambiguous, the agent should ask and then resume the same session with your answer. Silence never becomes a wrong assumption. If your spec provokes no questions at all, check that it was specific enough to be wrong somewhere.

A spec is a review tool

The approved card tells the reviewer what the change was supposed to do. Without it, review becomes archaeology: reconstruct the intent from the diff, then guess whether the diff matches. With it, review is a checklist against agreed text, and a missing requirement is obvious.

Write the card as if it will be quoted back at you during review. It will be, by an agent that only knows what you approved.