OpenSpec in Practice: Write the Spec First, Then Let AI Write the Code
Multi-day AI coding sessions lose requirements to chat history; OpenSpec makes alignment a commit you can review, diff, and archive. Teams that let agents run unattended get a deterministic read/write contract instead of hoping the model remembers the last ten turns.
OpenSpec is an open-source tool (MIT) that formalizes spec-driven development for AI coding assistants. Instead of letting requirements live in dozens of chat turns, it puts "what to build" into Markdown files under `openspec/specs/` (current state) and `openspec/changes/` (in-flight changes). A CLI scaffolds changes, validates deltas, and archives them back into the main specs. The core design: each change holds only a delta (ADDED/MODIFIED/REMOVED requirements) plus proposal, design, and tasks files, so parallel changes don't clash.
The CLI's `instructions` command generates tagged directives that tell the agent exactly which file to write, which sections are mandatory, and what project constraints are non-negotiable. Real output from SimpleBase shows `<project_context>` injected from `config.yaml`, `<dependencies>` forcing re-reads of completed artifacts, and `<instruction>` banning implementation details in specs. `openspec instructions apply --json` returns `contextFiles`, a task list with progress counts, so agents never guess the next step.
SimpleBase, a Go + Vue serverless database, uses OpenSpec in production: 12 capability baselines split by bounded context, 7 archived changes, 7 in-flight. A six-step loop covers open -> generate -> validate -> implement -> archive, with code-side gates (architecture tests, build, test) catching behavior errors that spec validation can't. `config.yaml` injects constraints that can't be inferred from code, while `skip_specs: true` lets pure refactors skip deltas without faking requirements.
The delta-and-archive mechanism is what separates OpenSpec from a design-doc prompt: parallel changes never overwrite baselines, and archived specs accumulate as a readable history.
Injecting `context` from `config.yaml` into every instruction is a stronger alignment tool than relying on `AGENTS.md`, because it reaches the agent at the moment of artifact generation rather than as a general preamble.
OpenSpec's explicit limitation (structure-only validation) forces teams to keep human review and code-side gates, which is probably why SimpleBase can run 7 concurrent changes without the spec library rotting.
The tool's success depends on a team actually reading specs; for solo exploration or one-off scripts, the overhead of writing a proposal outweighs the benefit.