Skip to content

Writing a feature spec for AI coding agents

Write a feature spec for AI coding agents with clear scope, access rules, worked acceptance examples and a reusable outline before implementation.

Two people inspect a specification at a shared table beside an abstract mechanism assembling software blocks.
Agree the feature behaviour before implementation begins. AI-generated conceptual illustration, not a product interface.

“Add an export for the morning dispatch meeting” leaves several decisions open. Which orders belong in the file? Can a warehouse lead download another warehouse's records? Does a partly shipped order show the original quantity or the amount still to send? A feature spec for AI coding agents should answer these questions before implementation starts.

Use the worked example below to turn a request into agreed behaviour, representative cases and a small implementation plan. It extends the fictional warehouse export in our brief-to-release workflow guide. This is a teaching example, rather than a feature delivered in this repository.

Start with the user's decision

For this example, the warehouse lead needs a list of remaining items to prepare for dispatch. That purpose determines the file's contents. An order-value report or a customer address book would answer a different question.

Write a short problem statement: “Before the morning dispatch meeting, a warehouse lead needs to download approved order lines still awaiting shipment from one warehouse they manage.” Then identify who can settle the details. The operations owner decides which lines belong on the list. The engineering lead checks the access boundary and how the existing application represents those lines.

A useful spec gives the agent relevant context and examples. Anthropic's context-engineering guidance recommends curating the information an agent needs and choosing representative examples. The structure below applies that principle to one bounded software change. A document still needs implementation checks and human review.

Record what exists today

Ask the agent to inspect repository conventions, relevant feature designs, current permissions and an existing export. Have it report the files it actually found. A plausible class name in a generated spec needs checking against the codebase.

For the fictional application, assume this inspection establishes the following starting point:

  • Order lines already record their allocated warehouse, ordered quantity and shipped quantity.
  • The application already knows which warehouses each lead may manage.
  • An existing download uses the application's CSV writer and spreadsheet-safe text encoding.
  • There is no scheduled dispatch export. This change adds an on-demand file.

These are assumptions for the example. In a real spec, replace them with verified findings and repository paths. If an order line can be allocated across several warehouses, the quantity rule below needs a different data model. Discover that before approving it.

A feature spec for AI coding agents

The following sections form the core of the illustrative spec. They describe observable behaviour and the decisions behind it. Include implementation details when they constrain correctness or compatibility. Routine class and method choices can stay in the plan.

Purpose and scope

Add an on-demand CSV download for one selected warehouse. A signed-in warehouse lead with export permission may request a warehouse they are authorised to manage. The file helps that lead prepare outstanding items for dispatch. Downloading it makes no changes to orders or inventory.

The first release excludes scheduled emails, bulk downloads across warehouses, customer contact details and changes to dispatch allocation. Reuse existing role management and CSV generation. A new reporting platform is outside the agreed work.

Settled decisions

QuestionAgreed behaviour
Which warehouse?One explicitly selected warehouse; validate the user's access on the server for every download.
Which lines?Approved, non-cancelled lines allocated to that warehouse, with a positive outstanding quantity.
What quantity?Ordered minus shipped. The example assumes whole units, no returns and cancellation of an entire line.
Which columns?Order reference, SKU, outstanding quantity and warehouse code, in that order. Use an explicit field list.
How are rows ordered?Order reference ascending, then SKU, then stable line identifier. Separate order lines remain separate rows, even when their SKUs match.
What if nothing matches?Return a valid CSV containing the column headings and no data rows.
What if access is denied?A signed-in user lacking export permission receives the application's standard 403. A permitted exporter requesting an inaccessible or nonexistent warehouse receives the same non-disclosing 404.
When is the data read?Use one consistent read of committed data for the file. Later changes appear in the next download.

The quantity assumptions deserve a business review. If partial cancellations or returns affect the dispatch balance, write their meaning and examples into the spec. Asking the agent to infer them from field names would leave a business decision inside the implementation.

Testable examples

All records below are invented. The requesting lead has export permission and manages warehouse A only. Each row represents a separate line. These are expected outcomes, not reported test results.

LineStarting stateExpected file content
ORD-101 / BRACKETA; approved; 10 ordered, 4 shippedOne row with outstanding quantity 6
ORD-102 / SENSORA; approved; 5 ordered, 5 shippedAbsent
ORD-103 / CABLEA; cancelled; 8 ordered, 0 shippedAbsent
ORD-104 / SWITCHA; awaiting approval; 3 ordered, 0 shippedAbsent
ORD-105 / BRACKETB; approved; 7 ordered, 0 shippedAbsent from the A file; requesting B directly returns 404

Checking the downloaded content matters. Hiding warehouse B in the selector leaves the direct request untested. Include a request for B using its valid identifier, and inspect the authorised A file for B's reference and records.

A warehouse lead checks a dispatch sheet beside remaining cartons, separated from cartons on a departing trolley.
The fictional spec distinguishes shipped items from the quantity still to send. AI-generated conceptual illustration; exact quantities are defined in the table above.

Failures and trade-offs

Agree how a failed download is reported and whether the chosen export path can finish for the expected data volume. For this example, generate the complete CSV before sending a successful response. If generation fails, use the application's standard error response rather than returning a partial file as a successful export. Preserve the existing CSV writer's protection for spreadsheet-sensitive text and verify the resulting cell content.

The trade-off is freshness. An on-demand file is a snapshot for a meeting, so a later shipment can make its quantities stale. Accept that limitation for this release. A live dispatch board or automatic refresh would require another scope decision.

Before approving a real version, confirm the supported row volume and the database's consistent-read approach. If the existing synchronous export cannot handle that volume, revise the design and recovery behaviour. This example supplies no benchmark or universal row limit.

Reuse a short spec outline

Copy this outline into your repository and fill it with the evidence for your feature. Add data or interface details where the change needs them.

# Feature name
Revision / owner / review state

## User problem and intended outcome
Who does what, and which task does it support?

## What exists today
Verified behaviour, relevant files and current constraints.

## Scope and exclusions
Included change; work explicitly deferred.

## Decisions
Agreed rules, access boundaries and error behaviour.

## Data and interfaces
Changed fields, allowed output and consistency.

## Acceptance examples
Input, actor and observable expected result.

## Trade-offs and operational limits
Accepted limitation, recovery and capacity assumptions.

## Open decisions
Question, responsible person and approval dependency.

## Approval record
Approved revision, approver, date and findings.

A typo fix may only need a few lines. A change to payments, shared data or irreversible actions needs more detail about failures and recovery. Scale the document to the decisions and consequences.

Settle questions before handover

An open question should name a decision-maker and its consequence. “Confirm whether a lead may export every warehouse” blocks approval of the access rule. “Confirm the button label” can usually be settled without redesigning the query. Distinguish those cases in the review record.

In our AI-assisted development process, a person approves the exact specification revision, then reviews the implementation plan. If the scope changes, the affected documents need renewed approval. Keep that record beside the spec so a later session can find it.

Split the plan into small tasks

The implementation plan names the actual files and verification commands found in the repository. For the fictional export, split the work by the behaviour a reviewer can assess:

  1. Access and selection: verify the permission boundary, warehouse scope and outstanding-line rules through the application's existing request and query seams.
  2. File generation: verify the allowed columns, quantity values, ordering, empty file, safe cell content and failure response.
  3. Download interaction: connect the existing warehouse screen, show meaningful failure feedback and verify that downloading leaves operational data unchanged.
  4. Whole-change review: compare the resulting diff and actual check output with the approved spec, including a direct request for an inaccessible warehouse.

Each task should carry its relevant acceptance cases and dependencies. The agent can propose implementation choices, but a task that discovers a missing quantity rule must return that decision to the owner. Do not let a convenient implementation silently redefine dispatch behaviour.

Before starting your next feature, ask a reviewer to trace one normal example and one denied or failed action from the spec into the plan. If either path requires guessing, finish that part of the spec. For a broader project whose scope is still unclear, our guide to software discovery deliverables explains the decisions a Product & System Blueprint should establish first.

Working on something like this?

Start with a paid Blueprint, not a guess

One to two weeks to agree the scope, the risks and the measure of success — then a fixed price for the Build.

A human engineer inspects software blocks at a desk while a small AI assistant offers a block beside an inspection gate.
AI workflow Engineering Delivery

AI-generated code review checklist before merge

Use an AI-generated code review checklist to inspect scope, access, failure paths and test evidence, with a worked diff before merging.

7 min read
A note clipped to a notebook sits beside an open laptop and an empty desk chair.
AI workflow Engineering

Resume an AI coding task after a session ends

Resume an AI coding task with a handoff template, read-only Git checks and an example of testing an old completion claim against a new requirement.

4 min read