# Plan and specify: the contract before the code

URL: https://developertoolkit.ai/en/workflows/plan/
Description: Plan with Claude Code, Codex, and Cursor using specs, executable acceptance criteria, and enforceable ADRs approved before any agent writes code.

Planning and specifying for coding agents means writing and approving a verifiable contract before implementation starts: `intent.md`, a living `spec.md` with stable requirement IDs, executable acceptance criteria that begin as failing tests, and enforceable architecture decision records (ADRs). Developers and tech leads use this hub to move design ambiguity out of pull-request review and into cheap pre-code gates.

An agent opens a 1,200-line pull request that compiles, passes its own unit tests, and solves a slightly different problem than the ticket intended. Review degrades into reverse-engineering requirements from the diff. Shifting human approval to a compact specification contract reverses that cost.

## Which planning guide fits your bottleneck?

| Situation in your workflow | Start here |
| --- | --- |
| Specs go stale a week after shipping, or agents "fix" code back to old docs | [Spec-driven development](/en/workflows/plan/spec-driven-development/) |
| "Done" gets debated during PR review instead of decided up front | [Executable acceptance criteria](/en/workflows/plan/acceptance-criteria/) |
| Agents violate module boundaries or introduce unapproved libraries | [Architecture decisions agents can follow](/en/workflows/plan/architecture-decisions/) |
| Tickets arrive too vague or oversized for autonomous execution | [Shaping an agent-ready backlog](/en/teams/agent-ready-backlog/) |
| You need the full handoff sequence from intent through release | [The artifact chain](/en/method/lifecycle/artifact-chain/) |

## Scale the contract to the risk

Match specification ceremony to blast radius. A narrow bug fix needs a reproducing failing test, whereas a customer-facing flow or cross-module change earns the full contract sequence:

1. **Capture intent.** Record the problem, target users, and non-goals in `intent.md` ([lifecycle Plan stage](/en/method/lifecycle/plan/)).
2. **Write the spec delta.** Translate accepted intent into numbered, observable requirements in `spec.md` ([lifecycle Design stage](/en/method/lifecycle/design/)).
3. **Make acceptance executable.** Turn each requirement into a failing test at a public boundary and lock those tests outside the implementing agent's edit scope.
4. **Constrain architecture.** Capture hard-to-reverse trade-offs in one-page ADRs linked directly to CI checks.

All three tools provide a dedicated read-and-propose planning phase—Claude Code's plan mode, Codex's planning mode, and Cursor's Plan Mode—so the agent maps the repository and drafts the contract before modifying application code. Check current commands and modes in the official documentation: [Claude Code docs](https://code.claude.com/docs), [OpenAI Codex docs](https://developers.openai.com/codex), and [Cursor docs](https://cursor.com/docs), or see tool-specific patterns in [Claude Code feature planning](/en/claude-code/plan/feature-planning/), [Codex architecture planning](/en/codex/plan/architecture/), and [Cursor agent modes](/en/cursor-ide/build/agent-modes-deep-dive/).

## Verify a plan before implementation starts

Check contract structure mechanically so humans judge only product and architectural decisions:

- **Requirement traceability:** CI verifies that every numbered requirement or criterion ID maps to an automated test.
- **Honest red runs:** Acceptance tests fail for missing behaviour rather than syntax, import, or fixture errors.
- **Independent critique:** A fresh read-only session audits `spec.md` for ambiguity and missing edge cases before approval.
- **Named sign-off:** Product owners approve behaviour and acceptance criteria; tech leads approve ADRs and non-functional bounds. Run `npx @wondelai/harness-audit` to inspect Station 1 (Intent) readiness across your repository ([harness audit guide](/en/workflows/harness/harness-audit-guide/)).

## When agent planning breaks down

| Failure | Early signal | Recovery |
| --- | --- | --- |
| Plan rubber-stamped on a skim | PR review reopens product scope | Approve numbered criteria and examples, never loose prose plans |
| Agent edits acceptance tests to pass | Test files change in an implementation PR | Lock test paths with CI guards and `CODEOWNERS` ([protecting the oracle](/en/workflows/test/protect-the-oracle/)) |
| Spec drifts from production code | Behaviour changes ship with no spec diff | Gate behaviour directories on a spec delta in CI |
| Ceremony outweighs change size | One-line fixes stall waiting for specs | Scale artifacts to risk; use a failing regression test alone for trivial fixes |

## Next steps from the planning hub

- [Spec-driven development](/en/workflows/plan/spec-driven-development/) — Keep spec.md authoritative across pull requests with CI traceability and drift audits.
- [Executable acceptance criteria](/en/workflows/plan/acceptance-criteria/) — Convert stories into locked, failing boundary tests before the agent codes.
- [Architecture decisions](/en/workflows/plan/architecture-decisions/) — Write one-page ADRs backed by lint, dependency rules, and CI verification.
- [Level 4: write the specs](/en/ladder/level-4-write-specs/) — See how specification ownership moves developers up the Autonomy Ladder.
