You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .agents/skills/writing-spec/SKILL.md
+23-21Lines changed: 23 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
1
---
2
2
name: writing-spec
3
-
description: Collaboratively write a feature spec with the developer. Trigger when a task involves 5+ unconstrained decisions, spans 5+ files, or the developer explicitly asks for a spec. Do NOT trigger for config edits, CSS fixes, helper functions, exploratory prototyping, presentation-only changes, or when the developer explicitly opts out.
3
+
description: Collaboratively write a feature spec with the developer. Trigger when a task involves 5+ unconstrained decisions, spans 10+ files, or the developer explicitly asks for a spec. Do NOT trigger for config edits, CSS fixes, helper functions, exploratory prototyping, presentation-only changes, or when the developer explicitly opts out.
4
4
---
5
5
6
6
## Purpose
7
7
8
-
Guide the developer through writing a feature spec before any code is written. The spec constrains intent and approach so implementation decisions are explicit, reviewed, and traceable. This skill produces a single `spec.md` file in `specs/NNN-feature-name/` using the project template at `@docs/spec-template.md`.
8
+
Guide the developer through writing a feature spec before any code is written. The spec constrains intent and approach so implementation decisions are explicit, reviewed, and traceable. This skill produces three files in `specs/NNN-feature-name/`— `requirements.md`, `design.md`, `tasks.md` — using the templates in `./templates/`.
9
9
10
10
## Prerequisites
11
11
12
-
- Read `@docs/spec-template.md`before starting — it defines the section structure
12
+
- Read `./templates/requirements-template.md`, `./templates/design-template.md`, and `./templates/tasks-template.md`before starting — they define the section structure
13
13
- Read `@docs/architecture.md` to understand current building block types and project structure
14
14
- Determine the next available sequence number by checking both `specs/` directory listings AND `git log` for prior spec-related commits — use the higher of the two
15
15
@@ -19,43 +19,45 @@ Each phase ends with a human review gate. Do NOT advance to the next phase witho
19
19
20
20
### Phase 1 — Goal & Scope (Intent)
21
21
22
-
Collaborate with the developer to fill sections 1-3 of the template.
22
+
Collaborate with the developer to fill `requirements.md`.
23
23
24
24
1. Ask the developer to describe the feature in 2-5 sentences (or accept what they've already provided)
25
25
2. Before drafting, ask 3-5 clarifying questions about scope boundaries, error scenarios, and unstated assumptions — only where the answer would change the spec. Skip obvious ones.
26
+
-**If the feature introduces new API calls (queries or mutations):** explicitly ask which server-side error responses each call must handle, and how the UI should react to each.
26
27
3. Draft the **Goal & Context** section — focus on the problem, not the solution
27
28
4. Draft **Requirements** using EARS notation: `WHEN [condition] THE SYSTEM SHALL [behavior]`. Assign stable IDs (R1, R2, …)
28
29
5. Draft **Non-Goals** — ask: "What should this feature explicitly NOT do?"
29
-
6. Present all three sections for review
30
+
6. Present `requirements.md` for review
30
31
31
32
**What to ask if unclear:** "What's the observable user behavior when this works correctly?" Never invent requirements — if the developer hasn't specified a behavior, ask about it.
32
33
33
34
### Phase 2 — Design (Approach)
34
35
35
-
Collaborate on sections 4-6 of the template.
36
+
Collaborate on `design.md`.
36
37
37
38
1. Propose a **Building Blocks Diff** — list every block that is ADDED, MODIFIED, or DELETED. Use the project's building block taxonomy from `.agents/skills/building-blocks/SKILL.md`. Reference by **name and type only** — do not define internals. Implementation details belong in coding standards and per-type skills, not specs. For changes that don't map to a typed building block, use the target file path + a short description instead.
38
-
2. For non-trivial features, propose **two plausible designs** with tradeoffs. Let the developer choose. Capture the winner and rationale in **Design Decisions**
39
-
3. Draft the **Boundaries** section using the three-tier system:
39
+
2.**Cross-slice concerns** — ask whether any new block needs to interact with another feature or sub-feature slice. If yes, decide the wiring point (parent feature or page) and injection mechanism (callback, render prop, slot) in the design — don't defer to implementation.
40
+
3. For non-trivial features, propose **two plausible designs** with tradeoffs. Let the developer choose. Capture the winner and rationale in **Design Decisions**
41
+
4. Draft the **Boundaries** section using the three-tier system:
40
42
- ✅ **Always** — proceed without asking (e.g., create files in the feature directory)
**Critical rule for building blocks:** Reference names and types. Do NOT define contracts, interfaces, or implementation — those live in separate coding-standards skills and existing code. The spec describes a CHANGE to the status quo. The agent reads relevant code to see the current status quo.
46
48
47
49
### Phase 3 — Spec (Sequencing)
48
50
49
-
Fill sections 7-10 of the template.
51
+
Fill `tasks.md`.
50
52
51
53
1. Break work into a **Task Breakdown** — ordered, independently testable tasks. Each task:
52
-
- References building blocks from section 4 if any are involved
54
+
- References building blocks from `design.md` if any are involved
53
55
- Traces to requirement IDs (R1, R2, …)
54
56
- Includes target file paths
55
57
- Is marked `[P]` (parallelizable) or `[S]` (sequential)
3. Add **Open Questions** for anything unresolved that blocks a specific task
58
-
4. Present for review
60
+
4. Present `tasks.md`for review
59
61
60
62
### Phase 4 — Review & Finalize
61
63
@@ -64,17 +66,17 @@ Fill sections 7-10 of the template.
64
66
-**Orphan tasks**: flag any task that doesn't trace back to a requirement ID
65
67
-**EARS compliance**: flag any requirement missing WHEN/THE SYSTEM SHALL or using vague language ("handle properly", "work correctly")
66
68
-**Boundary specificity**: flag any boundary item (✅/⚠️/🚫) that references a vague category instead of a file path or module name
67
-
-**Building block references**: flag any block in Section 4 that doesn't exist in the building-blocks catalog
68
-
-**Line count**: report total. If >150, identify which section to compress or extract
69
+
-**Building block references**: flag any block in `design.md` that doesn't exist in the building-blocks catalog
70
+
-**Line count**: report each file's count and the combined total. Caps: `requirements.md` ≤50, `design.md` ≤80, `tasks.md` ≤70, combined ≤200. If any cap is exceeded, identify which section to compress or extract
69
71
2. Fix any issues found in step 1 before proceeding
70
-
3. Set status to `review` in the Meta table
72
+
3. Set status to `review` in each Meta table
71
73
4. Present the audit results and the final spec for developer sign-off
72
74
73
75
## Rules & Constraints
74
76
75
77
### What the agent MUST do
76
78
77
-
- ALWAYS read `@docs/spec-template.md` before drafting
79
+
- ALWAYS read the three template files in `./templates/` before drafting
78
80
- ALWAYS use EARS notation for requirements and GIVEN/WHEN/THEN for edge cases
79
81
- ALWAYS assign stable IDs to requirements (R1, R2, …) — tasks reference these for traceability
80
82
- ALWAYS include the three-tier boundary system (✅ / ⚠️ / 🚫) with specific paths
@@ -89,7 +91,7 @@ Fill sections 7-10 of the template.
89
91
90
92
### Prefer
91
93
92
-
- Prefer concise specs (~80-120 lines) over exhaustive ones — the curse of instructions means longer specs get followed less reliably
94
+
- Prefer concise specs (combined ~200 lines: requirements ≤50, design ≤80, tasks ≤70) over exhaustive ones — the curse of instructions means longer specs get followed less reliably
93
95
- Prefer mechanical enforcement (lint, tests, schemas) over prose rules — if a constraint can be a linter rule, it doesn't belong in the spec
94
96
- Prefer two design options with tradeoffs over a single "obvious" choice — this surfaces assumptions
95
97
- Prefer specific file paths in boundaries over vague module names
@@ -100,7 +102,7 @@ Fill sections 7-10 of the template.
100
102
-**Over-specification that becomes code** — if the spec includes TypeScript interfaces, database DDL, or code snippets, it has crossed from "what" into "how." Move those to design docs or coding standards
101
103
-**Under-specification that forces guessing** — if a requirement says "handle errors gracefully" without specifying which errors and what "gracefully" means, the agent will guess. Fix: use GIVEN/WHEN/THEN for every error scenario
102
104
-**Auto-generated specs** — LLM-generated context files have been shown to reduce task success rates. The developer drives content; the agent structures and challenges it
103
-
-**Markdown review trap** — if the spec exceeds ~150 lines or spans multiple files, the review cost may exceed the value. Split the feature or compress the spec
105
+
-**Markdown review trap** — if any file exceeds its cap (requirements 50 / design 80 / tasks 70) or the combined spec exceeds ~200 lines, the review cost may exceed the value. Split the feature or compress the spec
104
106
105
107
## Examples
106
108
@@ -149,17 +151,17 @@ Why wrong: "properly" is undefined — the agent will guess what validations to
149
151
150
152
The spec is ready for implementation when:
151
153
152
-
-[ ] Every section marked REQUIRED in the template is filled
154
+
-[ ] Every section marked REQUIRED in each template is filled
153
155
-[ ] Every requirement has a stable ID and uses EARS notation
154
156
-[ ] Every task traces to ≥1 requirement ID
155
157
-[ ] Building blocks reference name + type only, no implementation details
156
158
-[ ] Boundaries use specific file paths, not vague categories
157
159
-[ ] Open questions are either resolved or explicitly block named tasks
158
160
-[ ] Developer has approved the final spec (status set to `approved`)
<!-- This file is the APPROACH layer: which building blocks change, key decisions, and the agent's lane. Do NOT define building block internals — reference name + type only. -->
14
+
15
+
## 1. Building Blocks Diff
16
+
17
+
<!-- REQUIRED. The core of the design. List every building block that is ADDED, MODIFIED, or DELETED. Reference by name and type — do NOT define implementation internals. Internals live in the building-blocks catalog (`.agents/skills/building-blocks/rules/{name}.md`) and existing code. -->
18
+
19
+
<!-- Use building block types from the catalog (e.g., queryOptions, mutation, component, store, machine, route, hook, service, type). For changes that don't map to a typed building block, use the target file path + a short description instead. -->
20
+
21
+
### Added
22
+
23
+
<!-- Example:
24
+
- `loginMutation` (mutation) — handles POST /auth/login
25
+
- `LoginForm` (component) — form with email/password fields
26
+
- `useAuthRedirect` (hook) — redirects authenticated users away from login
27
+
- `src/app/routes/login.tsx` — route entry for /login
28
+
-->
29
+
30
+
### Modified
31
+
32
+
<!-- Example:
33
+
- `AppRouter` (route) — add /login route
34
+
- `authStore` (store) — add `isAuthenticated` derived state
35
+
- `src/i18n/en/auth.json` — add login form translation keys
36
+
-->
37
+
38
+
### Deleted
39
+
40
+
<!-- Example:
41
+
- `legacyLoginPage` (component) — replaced by LoginForm
<!-- REQUIRED for non-trivial features. Document key choices with brief rationale. For each decision, state what you chose, what you rejected, and why. If the agent proposed alternatives during the design phase, capture the winner here. -->
48
+
49
+
<!-- OPINIONATED CALL: Keep this section short — 2-4 decisions max. If you need more, the feature should probably be split. -->
50
+
51
+
<!-- Example:
52
+
- **Auth strategy**: Use httpOnly cookies over localStorage tokens — XSS mitigation outweighs the convenience tradeoff.
53
+
- **Form library**: Use native controlled inputs, not react-hook-form — form is simple enough that a dependency isn't justified.
54
+
-->
55
+
56
+
## 3. Boundaries
57
+
58
+
<!-- REQUIRED. Three-tier classification. Be specific — file paths, module names, not vague categories. -->
<!-- Replace [Feature Name] with a short, descriptive title. This file is the INTENT layer: what the feature must do, not how. -->
14
+
15
+
## 1. Goal & Context
16
+
17
+
<!-- REQUIRED. 2-5 sentences. What problem does this solve and why now? Link to any prior art, issues, or conversations that motivated this work. This section constrains INTENT — not approach. -->
18
+
19
+
## 2. Requirements
20
+
21
+
<!-- REQUIRED. Behavioral requirements using EARS notation: "WHEN [condition] THE SYSTEM SHALL [behavior]." Each requirement gets a stable ID (R1, R2, …) for traceability in tasks.md. Focus on observable behavior, not implementation. -->
22
+
23
+
<!-- Example:
24
+
- **R1**: WHEN a user submits the login form with valid credentials, THE SYSTEM SHALL redirect to the dashboard within 2 seconds.
25
+
- **R2**: WHEN the API returns a 401, THE SYSTEM SHALL display an inline error message and preserve form input.
26
+
-->
27
+
28
+
## 3. Non-Goals / Out of Scope
29
+
30
+
<!-- REQUIRED. Explicitly list what this feature will NOT do. Prevents scope creep and stops the agent from "helpfully" adding unrequested capabilities. -->
<!-- This file is the SEQUENCING layer: ordered work, edge cases, acceptance, and unresolved questions. Every task must trace back to a requirement ID from requirements.md. -->
14
+
15
+
## 1. Task Breakdown
16
+
17
+
<!-- REQUIRED. Ordered list of independently testable tasks. Each task references one or more building blocks from design.md (section 1) and traces back to requirements via IDs. Include target file paths. -->
18
+
19
+
<!-- Mark parallelizable tasks with [P]. Mark tasks requiring sequential execution with [S]. -->
20
+
21
+
<!-- Example:
22
+
1. [S] Create `authStore` with `isAuthenticated` state — `src/features/auth/model/auth.store.ts` (R1, R2)
4. [S] Wire `/login` route into `AppRouter` — `src/app/router.tsx` (R1)
26
+
5. [S] Add E2E test for login flow — `e2e/auth/login.spec.ts` (R1, R2)
27
+
-->
28
+
29
+
## 2. Error & Edge Cases
30
+
31
+
<!-- OPTIONAL but recommended. Use GIVEN/WHEN/THEN format for precision. Cover failure modes, boundary conditions, and concurrent scenarios. If you skip this section, expect the agent to guess — and guess wrong. -->
32
+
33
+
<!-- Example:
34
+
- GIVEN the user is already authenticated, WHEN they navigate to /login, THEN redirect to dashboard.
35
+
- GIVEN the API is unreachable, WHEN the user submits login, THEN display a network error with a retry button.
36
+
-->
37
+
38
+
## 3. Acceptance Criteria
39
+
40
+
<!-- OPTIONAL. High-level "done" checklist. Useful for review gates. If your requirements (requirements.md, section 2) are precise enough, this section may be redundant — skip it. -->
41
+
42
+
## 4. Open Questions
43
+
44
+
<!-- OPTIONAL. Unresolved decisions that need human input before implementation can proceed. Each question should block a specific task from section 1. Remove questions as they're resolved and update the relevant sections. -->
45
+
46
+
<!-- Example:
47
+
- [ ] Q1: Should we support "remember me" functionality? (blocks task 3)
48
+
- [ ] Q2: Rate limiting strategy for login attempts — server-side only or client-side throttle too? (blocks task 2)
49
+
-->
50
+
51
+
## 5. References
52
+
53
+
<!-- OPTIONAL. Links to related specs, architecture docs, design mockups, API documentation, or external resources. Keep it to things the agent should read before implementation. -->
54
+
55
+
<!-- REQUIRED if design.md lists building blocks. Add this line verbatim: -->
56
+
<!-- Before implementing each building block, read `.claude/skills/building-blocks/rules/{type}.md` for its type. -->
0 commit comments