Specification-driven development for AI coding
How AIS used a constitution, selective context, automated code review and reproducible agent setup with Spec Kit, plus where GSD and the B-Method fit.
Specification-driven development (SDD) makes expected behaviour and its evidence explicit before implementation. A useful specification defines the outcome, examples, constraints, edge cases and observable acceptance criteria. Version it alongside the code, review material changes and link requirements to the checks or proofs that support them.
The constitution in the AIS monorepo
In the AIS monorepo, we used the AI Coding Tools constitution, built with GitHub Spec Kit, to turn engineering standards into an agreement that applies to engineers and coding agents. The constitution covers test-first development, type safety, compatibility and observability. It also defines how a change moves from a Jira issue through a branch, a pull request and verification, and how the team records the outcome. A feature specification describes what that feature must do. The constitution defines the obligations that travel with every feature.
The root AGENTS.md carries the rules the agent needs at the outset, including how to find authoritative guidance, what evidence it owes the reviewer and where it needs authorisation to act. The full constitution remains versioned and available. We kept detailed review, publication, frontend and backend guidance in smaller documents that a task can load when it reaches the relevant phase. We tied implementation claims to checks on the relevant revision. An engineer can see what was verified, which files or behaviours it covers and where evidence is still missing.
Load the instructions the task needs
We replaced a large bundle of always-loaded instructions with a small mandatory baseline and a deterministic context planner. It selects guidance by task intent, paths and phase. A request to review a Python change loads the relevant repository and review guidance. A specification edit selects the Spec Kit templates and authoring rules. A governance change can ask for the wider policy and publication material. Language-specific references are added when applicable, and shared references are counted once. The plan exposes what it selected, what it deferred and which rules matched.
We measured the content the planner actually resolves. For each of four representative scenarios we counted non-whitespace characters in the deduplicated references, divided by four and rounded up. We compared those estimates with a fixed pre-routing baseline of 79,107 estimated tokens. A fixed baseline prevented changes to the current manifest from moving the yardstick. The scoring weights reflect the benchmark’s intended task mix.
| Scenario | Weight | Selected context | Reduction |
|---|---|---|---|
| AI coding workflow change | 50% | 4,821 | 93.91% |
| Specification change | 20% | 17,984 | 77.27% |
| Governance documentation | 10% | 30,022 | 62.05% |
| Backend change using code-memory tools | 20% | 4,548 | 94.25% |
| Weighted reduction | 87.46% | ||
The benchmark requires an 80% weighted reduction, at least 60% in every scenario and a 3,500-token ceiling for the mandatory baseline. Testing only the weighted result would have hidden regressions in the less frequent but more context-heavy governance scenario. The figures describe estimated instruction volume. To measure spend or latency, use telemetry from actual sessions and record the model, task and caching conditions.
Automate review before the queue overwhelms the team
Agents can produce more pull requests and more review comments than a team can triage by hand. Without automation, that volume consumes the same engineering time the agents were meant to free up. In AIS, a dedicated review agent examines the implementation and affected tests before merge. GitHub Copilot also leaves inline findings. Review handling turns those findings into decisions. Accept a finding and fix its root cause, reject it with an evidence-backed explanation, or mark it outdated and cite the change that superseded it. Duplicate findings can point to the original decision.
A separate GitHub Actions job, the Agentic Workflow Gate, collects the PR description, changed files, commits and review comments. For covered automated comments on the current diff, it checks that the thread contains a disposition and a clickable evidence link. It also checks the PR’s review log and its Jira reference. Updating the PR description can rerun this job without rerunning the full CI/CD pipeline. The review protocol calls for resolving threads after a substantive reply, and peer approval remains a separate requirement. The gate can verify that the evidence was recorded. Reviewers still decide whether the evidence supports the conclusion.
Leave a trace from Jira to the review thread
A reviewer returning after a handover should be able to follow a decision from the requirement to the change and its verification. In AIS, the PR summary states what changed, which Jira issue owns the work and what checks were run against the current revision. Its review log records successive rounds. Each inline reply explains the decision at the point where it was raised and links to a fix, test run, specification or design decision. When a later revision supersedes a finding or its evidence, the next review round records that change.
The Jira issue carries the progress and scope changes, with links to the PR and CI evidence. Confluence carries durable decisions or engineering guidance when the task changes how later work should be done. For example, on the order retry problem below, the PR would show the new retry test, the inline reply would link to the fix, the Jira update would record the revised acceptance evidence, and a Confluence decision would record the rule if other services also needed to follow it. Those links make the work reconstructible without asking someone to replay the agent’s chat.
Choose a method by the strength of the claim
- GitHub Spec Kit
- A workflow and toolset that takes a feature through specification, planning, task decomposition, implementation and convergence. It gives teams reviewable Markdown artefacts and works with multiple coding agents.
- GSD (Get Shit Done)
- A project workflow that records requirements and decisions, divides work into phases, and carries each phase through planning, execution and verification. Use it when the challenge is keeping context and progress coherent over several sessions.
- B-Method
- A formal method implemented in tools such as Atelier B. Model state, operations and invariants, refine the model and discharge proof obligations. A proof establishes properties of the model under its assumptions. Humans still check that the model captures the requirements and that the delivered system behaves correctly in its environment.
Take idempotent order submission. A Spec Kit or GSD workflow can record what happens when the same request is retried and turn that behaviour into acceptance tests. If the order must never be charged twice across a defined set of state transitions, a B model can express that invariant and require proof that each modelled operation preserves it.
Standardise the setup at two levels
Dev Containers describe the development environment in devcontainer.json and the image or build it references. Pin the runtime and system tooling, supply standard build and test commands, and use the same definition in CI where practical. Create a small set of versioned templates for common stacks. Bake in stable dependencies and cache dependency downloads to reduce setup time.
AI package management standardises what the coding agent loads. Microsoft’s APM (Agent Package Manager) declares dependencies such as instructions, skills, prompts and MCP integrations in apm.yml and pins resolved packages in apm.lock.yaml. Review agent dependencies as you would build dependencies, keep credentials outside the package, and use explicit permissions for integrations. The container describes where the work runs. APM describes which agent context and capabilities are installed there.
Write a specification an implementer can disagree with
Start with a user outcome and a few examples. A specification that says ‘build a robust order endpoint’ leaves the central decisions implicit. An example in which a customer loses their connection after submitting an order gives the team something concrete to work through. A retry should show what happened to the original order, and the business needs to decide whether there are circumstances in which the user is allowed to create another. That decision belongs in the specification before someone chooses a storage mechanism.
The next useful cases usually look similar on the surface and then diverge. What should happen when the initial response is lost but the order was accepted? What about two tabs submitting the same basket, or a retry with a different address? How long is the system expected to remember earlier requests? Each question surfaces a boundary between policy and implementation. When the product owner cannot answer, record the uncertainty and how the team will resolve it. A small investigation or an explicit temporary decision makes progress visible.
Give observable requirements stable names. For example, ‘ORD-04: when the same customer retries a request with the same identifier and unchanged contents within the accepted interval, show the original order’. Connect each name to examples and evidence. This is especially helpful during review because the test and the written requirement can be inspected side by side. If someone proposes a scope change along the way, the stable identifier gives reviewers a way to ask which code and checks need to change.
Constraints should be written at the point where they matter. Preserving compatibility with an existing client may rule out a new mandatory field. A deadline might call for a smaller set of billing flows in the first release. If user-visible response time must stay below a target, add the workload, environment and measurement unit needed to test it. Keep genuine trade-offs in the plan or design so the specification remains a description of the result people have agreed to build.
Work the order example from specification to evidence
Consider three acceptance examples. In the first, the server records the order before the response is lost. A retry with the same identifier and payload returns the recorded outcome. In the second, the payload changes. The test should expect the conflict response that the team agrees to, including the guidance the client needs. In the third, two requests are processed concurrently. The externally visible result must still correspond to one accepted order and its original payment outcome. These examples help implementers ask about a state that might otherwise be missed.
Now write the plan. It can propose how to scope an identifier to the right customer and operation, where to store the decision, and how to observe retries in production. Review the recovery path if the payment provider responds after the server’s timeout. Verify behaviour with representative dependencies before judging the design from unit tests. Give the plan enough detail to identify a safe rollout and a migration that can be reversed or paused. The same plan may need a small spike to verify an assumption about a provider’s contract.
Connect implementation tasks to the claims they fulfil. A database migration alone may implement retention of request identifiers. The concurrency requirement needs evidence across storage, API and provider boundaries. Ask the implementer to state how each check was run and where the result can be seen. A review of the test should ask whether it would fail if the order were duplicated and whether the fixture preserves the failure conditions. This catches the common pattern where generated tests mirror the new code’s assumptions and therefore accept the wrong behaviour.
After release, the team can compare subsequent order and payment records, inspect retry counts and check whether customers still need support for interrupted orders. Choose those signals while defining acceptance. A staging test proves a path can work in a controlled setting. Observation after launch helps verify that customers encounter the expected behaviour under real traffic. Each stage provides a different kind of evidence. Say what you verified and which assumptions still need testing.
Use different tools for different kinds of evidence
Spec Kit is useful when a team wants a common sequence and shareable artefacts for a feature. Start with the user’s problem, resolve ambiguities that affect the outcome, then create a plan and break it into tasks that people can review. When reviewing an agent’s work, open the spec and tests alongside the diff. The workflow’s templates make it easier to find a missing decision, and teams can adapt them to existing pull-request and release conventions. Engineers still decide which changes deserve a full specification. A documented repair to an established rule may need a short issue and a regression test.
GSD is a good fit when work spans several sessions and coordination depends on the state of a roadmap. In the order example, the team can put API behaviour in an initial phase, provider validation in a second phase and rollout in a third. Each phase should leave verifiable output and a short record of assumptions for the next one. If the sequence changes, record the revised dependencies rather than relying on a chat session to remember them. Context management is part of the workflow’s value and works best when the roadmap stays small enough to maintain.
The B-Method asks a different question about state. A B machine can describe abstract state, allowed operations and an invariant such as ‘each accepted identifier refers to at most one payment outcome’. Model operations like accepting and retrying an order, including their preconditions. Refinement connects the abstract account of the operation to more concrete behaviour. Proof obligations require evidence that operations preserve the invariant and that refinements respect the properties they inherit. A versioned acceptance example and a proof can both support the same requirement—each with its own claims and assumptions.
A formal model earns its cost when the property is important, the state space is intricate and the relevant boundary can be stated clearly. Check model assumptions against the deployed design. If the abstract model treats a provider call as atomic, someone has to account for network failure, retries and unknown outcomes in the real service. Product review, formal reasoning, concurrency tests and production monitoring can all provide evidence here. Choose methods based on the consequences of failure, the team’s experience and the scope you can verify.
Make the setup reviewable as part of the change
Start with one environment definition a new engineer can use without deciphering a series of installation notes. The dev container should describe the runtime, system tools, mounted paths where needed, and standard entry points for building and testing. Run a small setup check from a fresh workspace and record how long it takes. Compare an actual first run with steady-state runs that benefit from caches. Match core dependencies with CI so contributors can reproduce failures from the normal feedback path.
Keep heavyweight development setup separate from production credentials and infrastructure. Seed local data with representative examples rather than requiring access to live accounts. Where agents operate inside containers, give the runner a narrowly scoped workspace and review which host resources it can reach. Containerising a development setup improves consistency. The environment also needs explicit access controls and an execution policy where the work is sensitive.
In AIS, the Dev Container provisions the runtime and system tooling, then bootstraps the same repository tasks that a developer can run from a fresh checkout. For the AI coding layer we used Microsoft’s Agent Package Manager (APM). The repo commits apm.yml and apm.lock.yaml, pins the APM executable with Mise and targets GitHub Copilot. The APM-Sync task materialises the reviewed skills, hooks and MCP declarations for the target. The generated files are recreated locally. The container and the hosted Copilot setup invoke the sync task, and a separate check detects drift. Credentials and machine-specific access stay outside the package.
We tested a clean environment and measured setup stages separately. The optimisation work compared dependency and hook caches by time spent in setup, hook installation counts and downloads. In the recorded hosted sample, custom setup fell from 311 s in the fresh pre-change window to 243 s in the first post-change cold run. That run missed both new caches. The warm-cache median target of 120 s remained open in the measurement record. A pinned setup makes those comparisons possible because toolchain or manifest changes can be accounted for explicitly.
Review the APM manifest and lockfile alongside the environment. The packages an agent loads can change its instructions and the tools it is able to use. Check what changed when updating a shared skill, and validate it with a small number of representative tasks. Record which revisions the agent used for consequential work. In a team with several coding assistants, the package description gives reviewers a shared view of the intended inputs even when the editor or CLI differs. Make local overrides explicit so a clean run can be reproduced.
For a team getting started, setup can be modest. Create one dev container template, one standard check command and one approved set of agent instructions. Ask a second person to work through a fresh checkout. Every manual step they discover is a candidate for either explicit documentation or automation. A template used by three people weekly can be easier to keep current than a broad platform rollout whose assumptions have yet to meet a real project.
Keep the specification alive when reality changes
A product review may reveal that two use cases previously thought equivalent must behave differently. Update the requirements explicitly, compare the affected examples and go through the design and tests that depend on the distinction. The cost of this rework is part of delivery. Capturing it makes it possible to see which questions the team should ask earlier on the next project. An obsolete spec that still looks authoritative creates more risk with agents because it can be copied into a plan without being challenged.
Decide what needs a version change. Improving the wording of an example can be reviewed as a clarification. Allowing a different payment outcome for an existing class of retries is a behaviour change, and the team should be able to identify which release first contained it. Make it easy to ask whether a deployed version conforms to a particular specification or whether a feature flag changes behaviour under certain conditions. Scope this traceability to the decisions where the cost of guessing is high.
Measure adoption with delivery questions. How often do acceptance criteria change after implementation? How much review is spent discovering missing policy? Do defects reveal misunderstood requirements or weaknesses in verification? A short record of these cases over several deliveries is enough to guide improvements. If a method adds documents but leaves the same questions unanswered, use a smaller template and better examples. If the same invariant repeatedly fails despite better examples, consider whether stronger modelling or runtime evidence will help.
A practical starting point is one feature with a meaningful edge case, a named decision owner, a few precise examples and a clear test or observation for every high-risk claim. Have the responsible engineer and an agent work from the same material. Review the change against the agreement and compare what remained ambiguous after release. That conversation tells you more about the value of specification-driven development than whether a template was filled out in full.
Further reading GitHub Spec Kit, GSD, Atelier B, Dev Container Specification and Microsoft APM.