Skip to main content

A task that called for a spec, and I just started coding on instinct

PhaseRequirementsRolesProject Manager ยท Architect ยท EngineerSeverityMediumApplies toAll coding agentsEvidenceOfficial docs

In one sentence: For complex work I may implement before recording a reviewable behavior and acceptance contract; reuse existing specs, fill consequential gaps, and scale detail to risk rather than turning small fixes into repeated approval.

Symptomโ€‹

You hand me a weighty task: "Change the order state machine to support partial refunds." This touches several modules, there's historical data to migrate, and getting it wrong costs real money. An experienced person would start by writing down: which state transitions to support, how the interface contract is defined, which cases count as "not supported," and what "done and correct" looks like.

I won't. I usually read two files and start editing OrderStateMachine, tack on an enum, touch the migration script, and twenty minutes later throw you a pile of "working" diff. You want to review it, but there's no handleโ€”because nothing up front states what I intended to do and what I deliberately left out. I skipped the spec and went straight to implementation.

Why this happensโ€‹

I may let implementation stand in for requirements, discovering only after the diff that state, compatibility, and acceptance criteria were never aligned. The problem is a missing reviewable contract, not proof that I am reluctant to write specifications or trained most strongly to edit immediately.

Addy Osmani's spec-writing guide draws on engineering practice and emphasizes sufficient, evolving specifications with incremental verification. Current official guidance also distinguishes planning complex work from directly handling small changes. Neither requires a long document every time or guarantees first-try correctness.

Read existing specifications and user decisions first, filling gaps that affect behavior and acceptance. When information and authorization are sufficient, record the necessary contract and continue rather than turning a spec into repeated approval.

Consequencesโ€‹

  • Nothing to align on. There's no shared "here's what we're building" document between us, so disagreements are deferred until the diff existsโ€”when rework is most expensive.
  • No handle for review. Reviewing a spec takes a few minutes; reviewing a pile of implementation means reading it line by line. By skipping the former, I push the whole cost onto you.
  • Drift surfaces late. The more complex the task, the more room I have to improvise; with no acceptance criteria as a backstop, a wrong direction gives no early signalโ€”exactly the "trust-then-verify gap" failure pattern the official guide calls out.
  • Decisions buried in code. I write key trade-offs like "partial refunds don't support cross-currency" straight into the implementation. You may never see them, and you certainly don't get to veto them before they become code.

What to do insteadโ€‹

  1. Reuse existing specifications. Inspect requirements, interfaces, and previous decisions rather than interviewing again for settled facts.
  2. Write a minimum reviewable contract for consequential changes. Include goals/non-goals, inputs/outputs/errors, state invariants, compatibility/migration, and acceptance evidence. Expand only what this task needs.
  3. Clarify consequential open decisions. Resolve choices changing design, authorization, money movement, or irreversible migration. Continue settled authorized work and disclose low-cost reversible assumptions.
  4. Evolve specification with implementation. A written spec is not automatically true. Update it with evidence when validation or assumptions change; a small fix need not create SPEC.md.

Exampleโ€‹

Before: I add PARTIALLY_REFUNDED without specifying balances, duplicate requests, or historical data.

After:

Me: Reuse existing refund authorization and currency contracts. Add to the spec:
Goal: partial refunds for paid orders permitted by existing rules.
Invariants: 0 < amount โ‰ค current refundable balance; concurrency/retries cannot over-refund.
Contract: currency, authorization, idempotency key, and failure/pending/success states.
Compatibility: historical full refunds and recovery/forward-repair plan.
Acceptance: success, failure, retries, concurrency, and balance consistency.
Open: whether shipped orders qualify, only if existing business rules do not answer it.

This is a spec outline, not a substitute for the payment service's real protocol, security, and integration validation. Settled decisions need no repeated approval.

Version notesโ€‹

Applicable versions

Rechecked current official guidance and O'Reilly's author-authorized republication on 2026-10-29. Retained goals/non-goals, contracts, acceptance criteria, and open questions as engineering guidance rather than a formal correctness guarantee. Scale depth to risk and verify plan-mode capabilities/permissions in the actual client.

Further reading and sourcesโ€‹