Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .claude/commands/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ Begin by understanding what the user wants to build. Ask clarifying questions ab
Then generate a structured spec covering all six core areas: objective, commands, project structure, code style, testing strategy, and boundaries.

Save the spec as SPEC.md in the project root and confirm with the user before proceeding.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider: Would it be clearer to express this as an explicit new-spec/delta-spec branch? The preceding instructions are written unconditionally for a full SPEC.md, while this line introduces the exception for an existing shipped spec.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, clearer as a branch. 5971d80 restructures all three /spec twins to decide the flow up front: New spec (no SPEC.md, or unrelated request) runs the full six-area flow; Delta spec (SPEC.md exists and the request changes it) writes SPEC-.md per Spec Evolution. No behavior change, just the structure you suggested.

If SPEC.md already exists and this request is a change to what it describes, do not overwrite it: write a delta spec (e.g. SPEC-<change-slug>.md) covering only the change, per the skill's Spec Evolution section.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we mirror this guard in commands/spec.toml too? Antigravity still instructs the agent to always overwrite SPEC.md; validate-commands does not compare prompt bodies.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — I'd missed that commands/ is a third twin and that validate-commands only diffs presence/descriptions, not bodies. Added the same guard line to commands/spec.toml in ce60dbc.

2 changes: 2 additions & 0 deletions .gemini/commands/spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ Begin by understanding what the user wants to build. Ask clarifying questions ab
Then generate a structured spec covering all six core areas: objective, commands, project structure, code style, testing strategy, and boundaries.

Save the spec as SPEC.md in the project root and confirm with the user before proceeding.

If SPEC.md already exists and this request is a change to what it describes, do not overwrite it: write a delta spec (e.g. SPEC-<change-slug>.md) covering only the change, per the skill's Spec Evolution section.
"""
8 changes: 8 additions & 0 deletions evals/cases/spec-driven-development.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
{
"prompt": "We are starting a new service, define the requirements first",
"top_k": 3
},
{
"prompt": "We shipped the V1 we specced — how do I spec the V2 features we deferred?",
"top_k": 3
},
{
"prompt": "This feature already has a spec, but now we want OCR instead of the manual step — spec that change before building",
"top_k": 3
}
],
"negative": [
Expand Down
46 changes: 45 additions & 1 deletion skills/spec-driven-development/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: spec-driven-development
description: Creates specs before coding. Use when starting a new project, feature, or significant change and no specification exists yet. Use when requirements are unclear, ambiguous, or only exist as a vague idea.
description: Creates specs before coding. Use when starting a new project, feature, or significant change and no specification exists yet. Use when requirements are unclear, ambiguous, or only exist as a vague idea. Use when evolving a shipped spec — scoping a V1, deferring ideas to a V2 backlog, or writing a follow-up spec for a change to an existing feature.
---

# Spec-Driven Development
Expand Down Expand Up @@ -110,6 +110,9 @@ Don't silently fill in ambiguous requirements. The spec's entire purpose is to s
## Success Criteria
[How we'll know this is done — specific, testable conditions]

## Out of Scope (Deferred)
[Ideas explicitly excluded from this version — the V2 backlog. One line each: what, and why it's deferred.]

## Open Questions
[Anything unresolved that needs human input]
```
Expand Down Expand Up @@ -177,6 +180,41 @@ The spec is a living document, not a one-time artifact:
- **Commit the spec** — The spec belongs in version control alongside the code.
- **Reference the spec in PRs** — Link back to the spec section that each PR implements.

## Spec Evolution: V1 Scoping and Follow-Up Changes

A spec describes one version of the work. New ideas and post-ship changes don't expand it — they queue behind it.

### Scope each version explicitly

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we explicitly answer whether the spec itself should be labeled V1? The Deferred section explains how to capture the V2 backlog, but the version-labeling part of #150 remains ambiguous.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it explicit in ce60dbc: the spec template title is now # Spec: [Name] — V[N], and Spec Evolution says to label the version in the title and bump it when a shipped delta is folded back in, so the V1/V2 boundary is stated in the artifact itself rather than implied.


During Specify, ideas that won't make this version go under **Out of Scope (Deferred)** — captured, not lost. This makes the V1 boundary enforceable: during implementation, anything not in the spec's requirements is out, even if it's written in the same file under Deferred. When an idea arrives mid-build, park it in the Deferred list and keep going; re-scoping happens between versions, not during one.

### Follow-up changes get a delta spec

Once a spec has shipped, a new requirement — swapping the storage engine, replacing a manual step with OCR, promoting a deferred V2 item — gets its own small spec rather than a hand-edit of the shipped one. A delta spec covers only what changes:

```markdown
# Spec Delta: [Change Name]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should a delta spec satisfy the existing “covers all six core areas” verification? This template intentionally omits Commands, Project Structure, Code Style, and Testing Strategy. Could the verification distinguish full specs from delta specs and require only the affected core areas?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the checklist item contradicted the delta template. In ce60dbc it now distinguishes the two: full specs cover all six areas; delta specs cover only the areas the change affects (at minimum objective, success criteria, and boundary deltas) and inherit the rest from the original.


## Objective
[The change and why. Which deferred item or new requirement this implements.]

## Current Behavior
[What exists today — link the relevant section of the original spec.]

## New Behavior
[What will be true after the change.]

## Success Criteria
[Specific, testable conditions — including what must NOT change.]

## Boundaries
[Only deltas from the original spec's boundaries; everything else inherits.]
```

Save it alongside the original (e.g. `SPEC-postgres-migration.md` next to `SPEC.md`) and run it through the same gated workflow: human review, then plan, tasks, implement. Keep one change per delta spec — that keeps each plan/build cycle small and reviewable.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we align this filename with the downstream workflow? /build auto only recognizes SPEC.md, docs/SPEC.md, or files under spec/, and does not allow root-level SPEC-*.md files as uncommitted planning artifacts. It may therefore select the old spec or stop at the clean-baseline check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed on both counts: discovery wouldn't select a root-level delta spec, and the clean-baseline check would stop on it. Rather than move delta specs into spec/ (which would drift into #73's storage-convention territory), ce60dbc updates all three /build twins: a root-level SPEC-<change>.md is now an accepted spec path (taking precedence over SPEC.md when the run is building that follow-up change) and SPEC-*.md is included in the planning-artifact exclusions. SKILL.md now states the convention is recognized downstream.


After the change ships, fold the outcome into the original spec (per Keeping the Spec Alive) so it stays the source of truth for what exists, and mark the delta implemented. The original spec always describes the current system; delta specs describe transitions.

## Common Rationalizations

| Rationalization | Reality |
Expand All @@ -186,6 +224,8 @@ The spec is a living document, not a one-time artifact:
| "The spec will slow us down" | A 15-minute spec prevents hours of rework. Waterfall in 15 minutes beats debugging in 15 hours. |
| "Requirements will change anyway" | That's why the spec is a living document. An outdated spec is still better than no spec. |
| "The user knows what they want" | Even clear requests have implicit assumptions. The spec surfaces those assumptions. |
| "This idea is good, I'll fold it into the current spec" | Mid-build scope growth is how V1 slips. Park it under Out of Scope (Deferred) — captured without expanding the current cycle. |
| "The feature already has a spec, I'll just edit it for the change" | A shipped spec describes what exists. A delta spec keeps the change reviewable on its own; the original gets updated after the change ships, not before. |

## Red Flags

Expand All @@ -194,6 +234,8 @@ The spec is a living document, not a one-time artifact:
- Implementing features not mentioned in any spec or task list
- Making architectural decisions without documenting them
- Skipping the spec because "it's obvious what to build"
- V1 requirements growing mid-implementation as new ideas get written straight into the spec
- Changing a shipped feature with no spec for the change because "the feature already has one"

## Verification

Expand All @@ -204,3 +246,5 @@ Before proceeding to implementation, confirm:
- [ ] Success criteria are specific and testable
- [ ] Boundaries (Always/Ask First/Never) are defined
- [ ] The spec is saved to a file in the repository
- [ ] Ideas cut from this version are captured under Out of Scope (Deferred), not silently dropped or silently included
- [ ] If this is a change to a shipped spec, it is a delta spec referencing the original, not a rewrite of it