Five-principle framework, distilled from Addy Osmani’s synthesis of GitHub’s 2,500-AGENTS.md study, the GitHub Spec Kit, and Simon Willison’s vibe-engineering posts. The core problem: throwing a giant document at an agent doesn’t work — context windows fill, the Curse of Instructions kicks in, and the agent loses focus. The solution: write smart, structured specs and feed them in pieces.

Key

“Aim for a clear spec covering just enough nuance (structure, style, testing, boundaries) to guide the AI without overwhelming it. Break large tasks into smaller ones. Plan first in read-only mode, then execute and iterate continuously.”

The five principles

1. Start high-level; let the AI draft the details

Begin with a product brief, not an RFC. A clear goal + a few core requirements. Have the agent expand it into a detailed SPEC.md, then refine that draft together. The spec is “the first artifact you and the AI build together.”

Plan Mode as enforcement. Tools like Claude Code offer a Plan Mode (Shift+Tab) that restricts the agent to read-only operations: it can analyse the codebase and draft plans but cannot write code until you exit. This is the cleanest way to enforce planning-first: the agent literally cannot start coding before the spec is settled. Pair with: “Ask me clarifying questions; review the plan for architecture, security, and testing strategy.”

Once approved, the spec persists across sessions as the source of truth — the same role a PRD plays on a human team. Compare with Anthropic’s feature_list.json in the Long-Running Agents - Initializer + Coding Pattern and Cursor’s planner task spec in Cursor Planner Worker Judge: external file with explicit, testable completion criteria, written before code, that the agent can’t quietly redefine mid-run.

2. Structure it like a PRD/SRS — cover six areas

The most effective specs cover six concrete areas (from GitHub’s 2,500-file study): commands, testing, project structure, code style, git workflow, boundaries. See the dedicated page for the checklist and worked examples.

Use Markdown headings or XML-like tags (<background>, <instructions>, <output_format>). “Minimal does not necessarily mean short.” Be specific about your stack: “React 18 with TypeScript, Vite, Tailwind CSS” — not “React project.” Vague specs produce vague code.

Treat specs as executable artifacts: version-controlled, integrated into CI/CD. The Spec-Driven Development workflow makes the spec the centre of the engineering process, not a one-time document.

3. Modular prompts, not one giant prompt

The Curse of Instructions is the load-bearing reason for this principle: as you pile on directives, adherence drops. Solutions:

  • Split the spec by phase or component — backend vs. frontend; never feed both when working on one.
  • Extended TOC / hierarchical summaries — a short outline of section headings + key points lives in the prompt; full sections come in on demand.
  • Sub-agents (skills) with their own context windows — Anthropic’s pattern: “Each subagent has a specific purpose and expertise area, uses its own context window separate from the main conversation, and has a custom system prompt.”
  • Parallel agents for independent work — “surprisingly effective, if mentally exhausting” (Willison). 2–3 agents max to start; tasks must be truly independent.
  • Refresh sessions between major features — “Start fresh.”

The bottom line: small focused context beats one giant prompt. This is the same logic as just-in-time retrieval — the model should see only what’s needed for the current task.

4. Self-checks, constraints, and your expertise

Three concrete moves:

  • Three-tier boundaries (Always ✅ / Ask first ⚠️ / Never 🚫) — see AGENTS.md Six Core Areas for the full pattern. More nuanced than a flat list of rules.
  • Self-verification prompt suffixes — “After implementing, compare the result with the spec; list any items not addressed.”
  • LLM-as-a-judge — a second agent (or a separate prompt) reviews the first’s output against quality criteria. Effective for things hard to test automatically (style, readability, architectural patterns).
  • Conformance testing (Willison) — language-independent test suites (often YAML) that any implementation must pass. More rigorous than ad-hoc unit tests because derived directly from the spec.
  • Pour your mentorship into the spec — known pitfalls, library quirks, style preferences. “If using library X, watch out for memory leak in version Y.”

The judge layer is the same architectural commitment as Cursor’s judge role and Anthropic’s planner/generator/evaluator triad: separate the role that decides done from the role that does the work.

Note

Willison: working with coding agents feels “uncomfortably close to managing a human intern” — “a weird digital intern who will absolutely cheat if you give them a chance.” The spec is how you prevent the cheating.

5. Test, iterate, evolve

The spec is not write-once. The cycle is:

  1. Continuous testing — code → test → fix → repeat. Always define what done means via tests/criteria.
  2. Iterate the spec itself — when the spec proves incomplete, update it and re-sync the agent: “I have updated the spec as follows… adjust the plan accordingly.”
  3. Tooling — RAG/MCP/Context7 for automated context retrieval; cheaper models for drafts, top-tier for critical reasoning; logs to debug misinterpretations.
  4. Version control — commit the spec; models are “fiercely competent at Git” and can use git diff and blame to reason about changes.

This is the spec-side analogue of the eval-driven cycle: instrument early, read the transcripts, refine.

Common pitfalls

GitHub’s study summary: “Most agent files fail because they’re too vague.”

  • Vague prompts. “You are a helpful coding assistant” fails. “You are a test engineer who writes tests for React components, follows these examples, and never modifies source code” works.
  • Overlong context without summarisation. Length is not quality.
  • Skipping human review. Willison’s rule: “I won’t commit code I couldn’t explain to someone else.”
  • Conflating vibe coding with production engineering. Vibe coding is great for exploration; shipping requires the discipline above. Know which mode you’re in.
  • Ignoring the lethal trifecta. Willison: speed (faster than you can review), non-determinism (same input, different outputs), cost (encouraging corner-cutting on verification). Your spec and review process must account for all three.
  • Missing the six core areas. Use AGENTS.md Six Core Areas as a sanity check.

How this connects to other patterns in the wiki

Spec principlePattern it implements
High-level vision + Plan Mode draftEvaluation-First Prompting — define done before code
PRD structure with six areasWriting Conflict-Free Instructions — structure as conflict avoidance
Modular prompts / sub-agentsContext Engineering — just-in-time retrieval; Multi-Agent Systems
Three-tier boundariesAgentic Coding - Risks and Discipline — guardrails as discipline
LLM-as-a-judgeCursor Planner Worker Judge; Eval-Driven Agent Development
Spec as living artifactLong-Running Agents - Initializer + Coding Pattern — feature_list.json is this idea in JSON
Conformance testingCapability vs Regression Evals — spec-derived tests as regression suite

The boundary: a spec is not a shortcut around engineering

Gabriella Gonzalez’s A Sufficiently Detailed Spec Is Code challenges two assumptions this framework must not inherit: that specification is necessarily simpler than implementation, and that a specification stage is necessarily more thoughtful. A document containing state schemas, retry formulas, and startup algorithms is already doing engineering. A rushed or generated document can also preserve confused thinking behind tidy headings.

Keep the five principles, but judge the spec by the decisions it clarifies, not its length or formatting. Record intent, constraints, tradeoffs, and observable success criteria. Where exactness matters, use enforceable schemas, contracts, or tests rather than relying only on prose interpretation. Leave incidental implementation choices open where appropriate, and surface consequential choices in a Decision Ledger.

An agent-drafted spec still needs independent human judgment. “The first artifact we build together” does not mean the agent can supply unstated domain intent, and approval is not proof of correctness. Comprehension Debt already identifies this ceiling; Gonzalez adds a concrete Symphony case and a sharper critique of the claimed cost savings. Her experiment is a reported case, not a controlled productivity comparison.

Where to start

  • If you’re starting a project: the four-phase spec-driven workflow (Specify → Plan → Tasks → Implement) is the cleanest entry point.
  • If you have an existing repo: write an AGENTS.md covering the six areas and three-tier boundaries.
  • If you’re stitching together a long-running run: pair this with Long-Running Agents - Initializer + Coding Pattern — the initializer expands your high-level vision into the spec; the coding agent works one feature at a time.

Sources

  • Writing Effective Specs for AI Coding Agents — Addy Osmani, “Writing Effective Specs for AI Coding Agents” (2026); the five principles, integration of GitHub Spec Kit + 2,500-file study + Willison’s vibe-engineering posts
  • A sufficiently detailed spec is code: Gabriella Gonzalez, A sufficiently detailed spec is code (2026-03-17); the counter-position on specification effort and the limits of spec-to-code generation.