Skip to content

Commit ecf6da8

Browse files
committed
docs: add best practices guide
1 parent f02260e commit ecf6da8

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Best Practices
2+
3+
Guidelines for getting the most out of spec-driven development.
4+
5+
## When to use each workflow
6+
7+
| Situation | Command | Mode |
8+
|-----------|---------|------|
9+
| You know the behavior but not the architecture | `/spec <name>` | Requirements-First (default) |
10+
| You have an existing design or architecture | `/spec <name>` | Design-First (auto-detected) |
11+
| You have a vague idea that needs exploration | `/spec-brainstorm` | Idea-first |
12+
| You have exploratory code that needs formalizing | `/spec-brainstorm` | Code-first (vibe-to-spec) |
13+
| You are fixing a complex bug with regression risk | `/spec-bugfix <name>` | Bug Analysis → Design → Tasks |
14+
15+
## Spec organization
16+
17+
- **One spec per feature** — keep specs focused. A spec that tries to redesign your entire app will be unwieldy.
18+
- **Multiple specs per repo**`.claude/specs/` can hold many specs. Use cross-spec dependencies when features build on each other.
19+
- **Version control everything** — commit specs to git. They are living documents that evolve with the code.
20+
- **Name specs clearly** — use kebab-case feature names (`user-authentication`, not `auth stuff`).
21+
22+
## Requirements
23+
24+
- **Be specific** — vague terms like "fast" or "easy" make acceptance criteria untestable. Use numbers: "page loads in under 200ms."
25+
- **Cover the unhappy path** — every happy path requirement should have a corresponding error-handling criterion.
26+
- **Document out-of-scope explicitly** — stating what you are NOT doing prevents scope creep later.
27+
28+
## Design
29+
30+
- **Let requirements drive design** — in Requirements-First mode, review every requirement before designing. In Design-First mode, ensure every design decision maps to a requirement.
31+
- **Reference the project profile** — the spec-planner uses `_project-profile.md` to align new code with existing patterns and registration points.
32+
- **Document alternatives** — briefly note designs you rejected and why. Future readers will thank you.
33+
34+
## Tasks
35+
36+
- **Run the loop for long specs**`spec-loop.sh` with `--max-iterations` is safer and faster than running `/spec-exec` repeatedly for specs with 10+ tasks.
37+
- **Validate before executing** — run `/spec-validate` after task generation. It catches traceability gaps and circular dependencies before you start coding.
38+
- **Keep tasks traceable** — every task should link back to at least one requirement or design component.
39+
40+
## Iteration
41+
42+
- **Refine early** — if you discover a gap during implementation, use `/spec-refine` to update requirements or design, then `/spec-tasks` to regenerate affected tasks.
43+
- **Do not hand-edit tasks.md during execution** — let `/spec-exec` and `spec-loop.sh` update statuses. Manual edits create drift between the spec and the agent's view.
44+
- **Update tasks after design changes** — changing `design.md` without regenerating `tasks.md` leaves stale task descriptions.
45+
46+
## Bugfix specs
47+
48+
- **Be explicit about constraints** — what code must NOT be modified? Constraints prevent over-fixing.
49+
- **Document unchanged behavior carefully** — the `SHALL CONTINUE TO` clause is your regression shield. If you skip it, you will break something.
50+
- **Write the reproduction test first** — it must fail before the fix and pass after. If it passes before the fix, you have not reproduced the bug.
51+
52+
## Post-implementation
53+
54+
- **Accept before releasing**`/spec-accept` traces every EARS criterion to a verified task. Do not skip this for production features.
55+
- **Run retrospectives**`/spec-retro` captures lessons learned. Review them before starting the next spec.
56+
57+
## What to avoid
58+
59+
- **Specs for trivial changes** — one-line fixes do not need a spec. Use your judgment.
60+
- **Refactoring during bugfixes** — keep bugfix specs surgical. Refactor in a separate feature spec.
61+
- **Letting specs go stale** — if the code diverges significantly from the spec, either update the spec or archive it.

0 commit comments

Comments
 (0)