# Ship a feature with a coding agent: spec, tests first, then review the diff

> The loop experienced developers describe on r/ExperiencedDevs: write the spec, plan the smallest steps, have tests written from the spec, implement, then review against the spec before anything merges.

- **Category:** [Coding](https://stepgleam.com/categories/coding)
- **Difficulty:** Intermediate
- **Time:** ~60 minutes
- **Tools:** Claude Code, Codex CLI, Cursor, GitHub, Git
- **Reliability score:** 78/100
- **Steps:** 6
- **Last updated:** 2026-10-26
- **Published:** 2026-10-26

## Tools used

- [Claude Code](https://code.claude.com/docs) — Coding agent that reads, edits and tests the repo
- [Codex CLI](https://developers.openai.com/codex/cli/features) — Terminal agent with /plan and /review
- [Cursor](https://cursor.com/docs) — Editor agent with Plan Mode
- [GitHub](https://github.com) — Pull requests and CI
- [Git](https://git-scm.com) — Checkpoints and small commits

## What you'll get

A merged feature with a written spec, a saved implementation plan, tests that came from the spec, and a diff you reviewed yourself.

## Who this is for

Working developers using Claude Code, Codex or Cursor on a real codebase who want fewer "it compiles but it's not what we meant" merges.

## Before you start

In a thread about heavy agentic engineering, one developer who leads an AI platform team said *"Half the effort is in writing the spec. The other half is in ensuring the agent follows the spec."* This guide follows that loop, plus a ticket-driven version from another thread, using any of Claude Code, Codex or Cursor.

## Steps

### Step 1: Write a ticket with background and acceptance criteria

**Tool:** GitHub

Before opening the agent, write the ticket: background, business value, acceptance criteria and links to relevant docs. One commenter describes exactly this as step 1 of their team's workflow (they use Linear). OpenAI's Codex guidance boils it down to four parts: Goal, Context, Constraints and *Done when*.

**Why this works:** The agent can only check its work against criteria that are written down.

[Open step 1](https://stepgleam.com/guides/ship-a-feature-with-an-agent-spec-tests-review#step-1)

### Step 2: Discuss the design with the agent and save the plan

**Tool:** Claude Code

Feed the ticket to the agent in plan mode and talk through whatever is still ambiguous. Claude Code: Shift+Tab to plan mode. Codex: `/plan`. Cursor: Shift+Tab to Plan Mode. Get an implementation plan, then **save it with the ticket**. The commenter says *"future agent sessions will see the implementation plan and immediately have much more context"*.

**Why this works:** A saved plan anchors later sessions and makes debugging easier.

**Prompt:**

```
Here is the ticket: <paste>. Ask me about anything ambiguous, then write an implementation plan broken into the smallest steps that can each be tested.
```

[Open step 2](https://stepgleam.com/guides/ship-a-feature-with-an-agent-spec-tests-review#step-2)

### Step 3: Have tests written from the spec before the implementation

**Tool:** Claude Code

Ask for tests that encode the acceptance criteria first, and confirm they fail. One developer runs this as separate steps: a subagent writes tests from the spec, then an implementation agent writes the code, then a review agent checks spec adherence. Anthropic's docs make the same point: give the agent *"a check it can run"* so it can iterate until it passes.

**Why this works:** Tests written before the code can't quietly be bent to match whatever the code ended up doing.

**Prompt:**

```
Write tests for the acceptance criteria in the plan. Don't implement the feature yet. Run them and show me that they fail for the right reason.
```

[Open step 3](https://stepgleam.com/guides/ship-a-feature-with-an-agent-spec-tests-review#step-3)

### Step 4: Implement against the plan and the tests

**Tool:** Cursor

Now let the agent implement, run the suite and fix failures. Watch the diff as it works. Cursor's docs suggest clicking Stop and redirecting as soon as it heads the wrong way rather than waiting until it finishes. If it drifts badly, revert, tighten the plan and rerun. That is usually faster than patching.

**Why this works:** Early correction is cheap; untangling a finished wrong implementation is not.

[Open step 4](https://stepgleam.com/guides/ship-a-feature-with-an-agent-spec-tests-review#step-4)

### Step 5: Open the PR and run review bots, CI and your own QA together

**Tool:** GitHub Copilot code review

Push a PR. Let review bots do a first pass (the commenter's team uses CodeRabbit; GitHub Copilot code review works the same way via **Reviewers → Copilot → Request**). At the same time, manually QA the change in your local environment while CI runs unit and integration tests. Feed review comments and QA findings back to the agent until the change is acceptable.

**Why this works:** Bots catch obvious issues quickly, but only your QA tells you whether it behaves as intended.

[Open step 5](https://stepgleam.com/guides/ship-a-feature-with-an-agent-spec-tests-review#step-5)

### Step 6: Review the diff yourself before merging

**Tool:** VS Code

Final review gets human eyes. One developer has the agent wait for them to review the diff in their IDE, where they *"inevitably make changes and fix things"*, and recommends manual reviews *"early and often"* because catching a spec mistake early is much cheaper. Merge only after that.

**Why this works:** Most AI slop comes from letting the agent run unchecked, according to the same commenter.

[Open step 6](https://stepgleam.com/guides/ship-a-feature-with-an-agent-spec-tests-review#step-6)

## Pro tips

- If you could describe the diff in one sentence, skip plan mode. Anthropic says planning adds overhead for small, clear changes.
- After two failed corrections in one session, clear the context and restart with a better prompt.
- Ask for evidence: the test command and its output, not "done".

## Common mistakes

- Letting the agent change the acceptance criteria as it goes.
- Reviewing only the final diff of a long session instead of checking in early.
- Treating passing tests as proof that the feature matches the ticket.

## FAQ

### Which agent should I use?

The thread participants used Claude Code mainly, but the loop is tool-agnostic. Plan mode exists in Claude Code, Codex and Cursor.

### Do I need subagents?

No. Separate sessions work too. Anthropic's docs note that a fresh context improves review because it isn't biased toward code it just wrote.

### What if the team has no ticket system?

Write the spec as a markdown file in the repo and reference it in every prompt.

---

Canonical guide: https://stepgleam.com/guides/ship-a-feature-with-an-agent-spec-tests-review
Read this guide as Markdown: https://stepgleam.com/guides/ship-a-feature-with-an-agent-spec-tests-review.md
