All posts

Spec First: How We Get Reliable Code from AI Coding Agents

AI coding tools produce a lot of code quickly. Whether it is the right code depends on what happens before and after the agent writes it. This is the process we use on our own projects.

21 November 2026Creative Square Agency

Introduction

Most teams that try AI coding tools get the same mixed result.

Some developers love them and others don't trust the output. More code gets merged, and nobody is sure it is better code. In our experience the tools are rarely the problem. The way of working around them is.

Our approach rests on one rule: nothing gets built until it is written down.

Why prompts alone don't scale

A coding agent given a one-line ticket has to guess. It guesses the edge cases, the naming, what "done" means. Sometimes it guesses well. A reviewer then has to work out what was intended from the code itself, which is slow and easy to get wrong.

The fix isn't a better prompt. It is giving the agent, the tests and the reviewer the same written definition of the work.

The spec is the contract

Every ticket becomes a short spec with acceptance criteria before anyone, human or agent, writes code. Small changes take a lighter route with just a plan. Bigger features get a full spec, a plan and a task list.

The agent builds from the spec, the tests check against it, and the review asks one question: does this do what the spec says?

Writing it takes minutes. It saves the hours that go into building the wrong thing well.

What every ticket goes through

  1. Read and ask. The agent reads the ticket, the design, the docs and related tickets. If something is unclear it asks before it starts, not halfway through.
  2. Plan, then a second opinion. It writes a plan. A second agent, starting with a clean slate, tries to find the holes. An engineer approves the plan before any code exists.
  3. Build and test. The work happens on its own branch. The project's own tests and checks run on that exact commit.
  4. Review. A separate agent reviews the change against the spec, and each acceptance criterion is checked end to end.
  5. A person merges. The pull request and the merge happen only after someone says yes. The technical docs are updated in the same step.

Guardrails that don't rely on good intentions

Telling an agent "please don't push to main" in a prompt is a request. We prefer rules the setup enforces.

  • Hard limits. Agents can't push to protected branches, run risky commands or close tickets.
  • Loops that stop. If a ticket keeps failing tests or review, the agent stops after a set number of tries and a person decides what happens next.
  • Rules and checks that agree. Complexity limits, test coverage on changed code, security and accessibility rules are written down once, and the automated checks enforce the same numbers.
  • Secrets stay out of the chat. Tokens live on each developer's machine and never pass through the conversation.

A record you can look back on

Each ticket's spec, plan and test results are kept together. Months later you can still see why something was built the way it was. That is useful for new team members, and for agents: the next task starts with real context instead of a guess.

What it looks like on a real project

This is how we build our own work. HoopsHub, a recruitment network for professional basketball, went from its first commit to a working product in about six months, with 76 written specs and 341 automated test files.

The specs were not overhead. They are why the pace held up as the product grew.

We have since built the process into a product. ProjectKeel is a project tracker where an agent takes a ticket, reports each of these stages on it, and waits for a person to approve the plan and the review.

How to start

You don't need to change everything at once.

  • Pick one team and one real feature. Run it through the full process.
  • Write down the rules you already have. Most teams have unwritten standards. Make them checks.
  • Keep people on the decisions. A person approves the plan and a person merges.
  • Review after a month. Look at what was merged and how much of it needed rework.

Closing

AI agents write code quickly. A spec makes sure it is the code you asked for, and a human merge makes sure someone still owns it.

Read about AI-assisted delivery

Got a process that eats your team's time?

Tell us about it. We'll give you an honest view of whether AI can help, and what it would take to build.