specdacular 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -74
- package/commands/specd/continue.md +59 -0
- package/commands/specd/new.md +65 -0
- package/commands/specd/status.md +1 -1
- package/commands/specd/toolbox.md +59 -0
- package/package.json +1 -1
- package/specdacular/HELP.md +19 -16
- package/specdacular/agents/feature-researcher.md +4 -4
- package/specdacular/references/load-context.md +83 -0
- package/specdacular/references/record-decision.md +61 -0
- package/specdacular/references/select-feature.md +20 -20
- package/specdacular/references/select-phase.md +3 -3
- package/specdacular/references/spawn-research-agents.md +180 -0
- package/specdacular/references/synthesize-research.md +127 -0
- package/specdacular/references/validate-task.md +64 -0
- package/specdacular/templates/{features → tasks}/CHANGELOG.md +2 -8
- package/specdacular/templates/{features → tasks}/CONTEXT.md +6 -17
- package/specdacular/templates/tasks/DECISIONS.md +46 -0
- package/specdacular/templates/{features → tasks}/FEATURE.md +3 -3
- package/specdacular/templates/tasks/PLAN.md +91 -0
- package/specdacular/templates/tasks/RESEARCH.md +121 -0
- package/specdacular/templates/{features → tasks}/ROADMAP.md +6 -43
- package/specdacular/templates/tasks/STATE.md +93 -0
- package/specdacular/templates/tasks/config.json +15 -0
- package/specdacular/workflows/continue.md +275 -0
- package/specdacular/workflows/discuss.md +184 -0
- package/specdacular/workflows/execute.md +174 -0
- package/specdacular/workflows/new.md +299 -0
- package/specdacular/workflows/orchestrator/new.md +265 -0
- package/specdacular/workflows/orchestrator/plan.md +169 -0
- package/specdacular/workflows/plan.md +201 -0
- package/specdacular/workflows/research.md +166 -0
- package/specdacular/workflows/review.md +289 -0
- package/specdacular/workflows/status.md +17 -17
- package/commands/specd/blueprint.md +0 -64
- package/commands/specd/feature/continue.md +0 -84
- package/commands/specd/feature/new.md +0 -67
- package/commands/specd/feature/toolbox.md +0 -49
- package/specdacular/templates/blueprint/index.html +0 -110
- package/specdacular/templates/blueprint/scripts.js +0 -71
- package/specdacular/templates/blueprint/styles.css +0 -429
- package/specdacular/templates/features/DECISIONS.md +0 -109
- package/specdacular/templates/features/DEPENDENCIES.md +0 -47
- package/specdacular/templates/features/PLAN.md +0 -180
- package/specdacular/templates/features/RESEARCH.md +0 -183
- package/specdacular/templates/features/STATE.md +0 -110
- package/specdacular/templates/features/config.json +0 -20
- package/specdacular/workflows/blueprint-diagrams.md +0 -273
- package/specdacular/workflows/blueprint-wireframes.md +0 -312
- package/specdacular/workflows/blueprint.md +0 -372
- package/specdacular/workflows/continue-feature.md +0 -621
- package/specdacular/workflows/discuss-feature.md +0 -382
- package/specdacular/workflows/execute-plan.md +0 -636
- package/specdacular/workflows/insert-phase.md +0 -246
- package/specdacular/workflows/new-feature.md +0 -760
- package/specdacular/workflows/plan-feature.md +0 -691
- package/specdacular/workflows/plan-phase.md +0 -355
- package/specdacular/workflows/prepare-phase.md +0 -745
- package/specdacular/workflows/renumber-phases.md +0 -273
- package/specdacular/workflows/research-feature.md +0 -252
- package/specdacular/workflows/research-phase.md +0 -576
- package/specdacular/workflows/review-feature.md +0 -316
- package/specdacular/workflows/review-phase.md +0 -545
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
<purpose>
|
|
2
|
-
Renumber all phases to a clean integer sequence after decimal phases have been inserted.
|
|
3
|
-
|
|
4
|
-
**Key principles:**
|
|
5
|
-
- Always preview and confirm before renaming anything
|
|
6
|
-
- Rename directories highest-to-lowest to avoid collisions
|
|
7
|
-
- Update ALL references: directories, plan frontmatter, ROADMAP.md, STATE.md
|
|
8
|
-
- Remove `(INSERTED)` markers after renumbering
|
|
9
|
-
|
|
10
|
-
**Output:** Renamed phase directories, updated ROADMAP.md, STATE.md, config.json, plan frontmatter
|
|
11
|
-
</purpose>
|
|
12
|
-
|
|
13
|
-
<process>
|
|
14
|
-
|
|
15
|
-
<step name="validate">
|
|
16
|
-
Validate the feature exists and has the required structure.
|
|
17
|
-
|
|
18
|
-
1. Check feature directory exists:
|
|
19
|
-
```bash
|
|
20
|
-
[ -d ".specd/features/$feature" ] || { echo "Feature not found"; exit 1; }
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
2. Check plans directory exists:
|
|
24
|
-
```bash
|
|
25
|
-
[ -d ".specd/features/$feature/plans" ] || { echo "No plans directory"; exit 1; }
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
3. Check ROADMAP.md exists:
|
|
29
|
-
```bash
|
|
30
|
-
[ -f ".specd/features/$feature/ROADMAP.md" ] || { echo "No ROADMAP.md"; exit 1; }
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**If feature not found:**
|
|
34
|
-
```
|
|
35
|
-
Feature '{name}' not found.
|
|
36
|
-
|
|
37
|
-
Available features:
|
|
38
|
-
{list .specd/features/*/}
|
|
39
|
-
```
|
|
40
|
-
</step>
|
|
41
|
-
|
|
42
|
-
<step name="collect_phases">
|
|
43
|
-
List all phase directories and build the renumbering mapping.
|
|
44
|
-
|
|
45
|
-
1. List all `phase-*` directories under `plans/`:
|
|
46
|
-
```bash
|
|
47
|
-
ls -d .specd/features/$feature/plans/phase-* 2>/dev/null | sort -V
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
2. Sort numerically — integers first, then decimals in order:
|
|
51
|
-
- phase-01, phase-02, phase-03, phase-03.1, phase-03.2, phase-04, phase-05
|
|
52
|
-
- Use version sort (`sort -V`) to get correct ordering
|
|
53
|
-
|
|
54
|
-
3. Build mapping: assign sequential integers starting from 01:
|
|
55
|
-
```
|
|
56
|
-
phase-01 → phase-01 (unchanged)
|
|
57
|
-
phase-02 → phase-02 (unchanged)
|
|
58
|
-
phase-03 → phase-03 (unchanged)
|
|
59
|
-
phase-03.1 → phase-04 (renumbered)
|
|
60
|
-
phase-03.2 → phase-05 (renumbered)
|
|
61
|
-
phase-04 → phase-06 (renumbered)
|
|
62
|
-
phase-05 → phase-07 (renumbered)
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
4. Identify which directories actually need renaming (skip unchanged ones)
|
|
66
|
-
|
|
67
|
-
**If no decimal phases found:**
|
|
68
|
-
```
|
|
69
|
-
No decimal phases found — nothing to renumber.
|
|
70
|
-
|
|
71
|
-
All phases are already clean integers:
|
|
72
|
-
{list phases}
|
|
73
|
-
```
|
|
74
|
-
Exit workflow.
|
|
75
|
-
</step>
|
|
76
|
-
|
|
77
|
-
<step name="preview">
|
|
78
|
-
Show the user the renumbering mapping and ask for confirmation.
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
82
|
-
PHASE RENUMBERING PREVIEW
|
|
83
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
84
|
-
|
|
85
|
-
Feature: {feature}
|
|
86
|
-
|
|
87
|
-
| Current | New | Status |
|
|
88
|
-
|---------|-----|--------|
|
|
89
|
-
| phase-01/ | phase-01/ | unchanged |
|
|
90
|
-
| phase-02/ | phase-02/ | unchanged |
|
|
91
|
-
| phase-03/ | phase-03/ | unchanged |
|
|
92
|
-
| phase-03.1/ | phase-04/ | renumbered |
|
|
93
|
-
| phase-04/ | phase-05/ | renumbered |
|
|
94
|
-
|
|
95
|
-
Directories to rename: {count}
|
|
96
|
-
Files to update: ROADMAP.md, STATE.md, config.json, plan frontmatter
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Use AskUserQuestion:
|
|
100
|
-
- header: "Renumber"
|
|
101
|
-
- question: "Proceed with phase renumbering?"
|
|
102
|
-
- options:
|
|
103
|
-
- "Yes, renumber" — Continue to rename_directories
|
|
104
|
-
- "Cancel" — Exit workflow
|
|
105
|
-
|
|
106
|
-
**If user cancels:** Exit with "Renumbering cancelled. No changes made."
|
|
107
|
-
</step>
|
|
108
|
-
|
|
109
|
-
<step name="rename_directories">
|
|
110
|
-
Rename phase directories, processing from highest target number down to avoid collisions.
|
|
111
|
-
|
|
112
|
-
**Why highest-to-lowest?** If we rename phase-03.1 → phase-04 first, it would collide with the existing phase-04. By starting from the highest target number and working down, we avoid this:
|
|
113
|
-
|
|
114
|
-
1. Build list of renames needed, sorted by target number descending
|
|
115
|
-
2. For each rename (highest first):
|
|
116
|
-
```bash
|
|
117
|
-
mv ".specd/features/$feature/plans/phase-{old}" ".specd/features/$feature/plans/phase-{new}"
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Example order:
|
|
121
|
-
```bash
|
|
122
|
-
# Process highest target first to avoid collisions
|
|
123
|
-
mv plans/phase-04/ plans/phase-05/ # 04 → 05 (no collision, 05 doesn't exist)
|
|
124
|
-
mv plans/phase-03.1/ plans/phase-04/ # 03.1 → 04 (no collision, 04 just moved)
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
3. Skip directories that don't change (e.g., phase-01 → phase-01)
|
|
128
|
-
|
|
129
|
-
4. Confirm each rename:
|
|
130
|
-
```
|
|
131
|
-
Renamed: phase-{old}/ → phase-{new}/
|
|
132
|
-
```
|
|
133
|
-
</step>
|
|
134
|
-
|
|
135
|
-
<step name="update_plan_frontmatter">
|
|
136
|
-
Update YAML frontmatter in every plan file under the renamed phases.
|
|
137
|
-
|
|
138
|
-
1. Find all plan files (`*.md`) in renamed phase directories:
|
|
139
|
-
```bash
|
|
140
|
-
find .specd/features/$feature/plans/ -name "*.md" -type f
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
2. For each plan file, read and update:
|
|
144
|
-
- `phase:` field in YAML frontmatter — update to new integer phase number
|
|
145
|
-
- `depends_on:` paths that reference renamed phases — update phase directory names
|
|
146
|
-
(e.g., `phase-03.1/01-PLAN.md` → `phase-04/01-PLAN.md`)
|
|
147
|
-
|
|
148
|
-
3. Only modify files that actually contain references to renamed phases
|
|
149
|
-
|
|
150
|
-
**Example frontmatter update:**
|
|
151
|
-
```yaml
|
|
152
|
-
# Before:
|
|
153
|
-
phase: "03.1"
|
|
154
|
-
depends_on:
|
|
155
|
-
- "phase-03/02-PLAN.md"
|
|
156
|
-
|
|
157
|
-
# After:
|
|
158
|
-
phase: "04"
|
|
159
|
-
depends_on:
|
|
160
|
-
- "phase-03/02-PLAN.md" # unchanged — phase-03 didn't move
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Also scan plan files in phases that weren't renamed, in case they reference a renamed phase in their `depends_on`.
|
|
164
|
-
</step>
|
|
165
|
-
|
|
166
|
-
<step name="update_roadmap">
|
|
167
|
-
Rewrite phase headers and references in ROADMAP.md.
|
|
168
|
-
|
|
169
|
-
1. Read ROADMAP.md
|
|
170
|
-
|
|
171
|
-
2. For each phase in the mapping that changed:
|
|
172
|
-
- Update phase headings: `## Phase {old}:` → `## Phase {new}:`
|
|
173
|
-
- Remove `(INSERTED)` markers from renumbered phases
|
|
174
|
-
- Update plan references within phase sections (e.g., "Plan 3.1.01" → "Plan 4.01")
|
|
175
|
-
- Update cross-references to other phases that were renumbered
|
|
176
|
-
|
|
177
|
-
3. Preserve all other content exactly (descriptions, goals, plan details)
|
|
178
|
-
|
|
179
|
-
4. Write updated ROADMAP.md
|
|
180
|
-
|
|
181
|
-
**Example:**
|
|
182
|
-
```markdown
|
|
183
|
-
# Before:
|
|
184
|
-
## Phase 03.1: Architecture Update (INSERTED)
|
|
185
|
-
|
|
186
|
-
# After:
|
|
187
|
-
## Phase 04: Architecture Update
|
|
188
|
-
```
|
|
189
|
-
</step>
|
|
190
|
-
|
|
191
|
-
<step name="update_state">
|
|
192
|
-
Rewrite all phase references in STATE.md.
|
|
193
|
-
|
|
194
|
-
1. Read STATE.md
|
|
195
|
-
|
|
196
|
-
2. Update ALL phase references throughout the file:
|
|
197
|
-
- **Stage Progress checkboxes:** `Phase {old}` → `Phase {new}`
|
|
198
|
-
- **Plan Status table:** Phase column values
|
|
199
|
-
- **Completed Plans table:** Plan paths containing phase directories
|
|
200
|
-
- **Current Plan section:** If referencing a renamed phase
|
|
201
|
-
- **Roadmap Evolution notes:** Update phase numbers in evolution history
|
|
202
|
-
- **Session Notes:** Any phase references
|
|
203
|
-
|
|
204
|
-
3. For roadmap evolution, add a note about renumbering:
|
|
205
|
-
```markdown
|
|
206
|
-
- Phases renumbered to clean integer sequence: {mapping summary}
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
4. Write updated STATE.md
|
|
210
|
-
</step>
|
|
211
|
-
|
|
212
|
-
<step name="update_config">
|
|
213
|
-
Update config.json with the new phase count.
|
|
214
|
-
|
|
215
|
-
1. Read config.json
|
|
216
|
-
2. Set `phases_count` to the total number of integer phases (the final count after renumbering)
|
|
217
|
-
3. Write updated config.json
|
|
218
|
-
</step>
|
|
219
|
-
|
|
220
|
-
<step name="completion">
|
|
221
|
-
Present completion summary:
|
|
222
|
-
|
|
223
|
-
```
|
|
224
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
225
|
-
PHASES RENUMBERED
|
|
226
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
227
|
-
|
|
228
|
-
Feature: {feature}
|
|
229
|
-
|
|
230
|
-
**Renames:**
|
|
231
|
-
{For each rename:}
|
|
232
|
-
- phase-{old}/ → phase-{new}/
|
|
233
|
-
|
|
234
|
-
**Updated files:**
|
|
235
|
-
- ROADMAP.md — Phase headers and references updated
|
|
236
|
-
- STATE.md — All phase references updated
|
|
237
|
-
- config.json — phases_count = {new count}
|
|
238
|
-
- {N} plan files — Frontmatter updated
|
|
239
|
-
|
|
240
|
-
**Removed markers:** (INSERTED) tags cleaned up
|
|
241
|
-
|
|
242
|
-
───────────────────────────────────────────────────────
|
|
243
|
-
|
|
244
|
-
All phases now use clean integer numbering.
|
|
245
|
-
`/specd:phase:execute {feature}` to continue execution.
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
End workflow.
|
|
249
|
-
</step>
|
|
250
|
-
|
|
251
|
-
</process>
|
|
252
|
-
|
|
253
|
-
<safety>
|
|
254
|
-
- Always preview and confirm before any renames
|
|
255
|
-
- Process renames highest-to-lowest to avoid directory collisions
|
|
256
|
-
- Skip directories that don't change
|
|
257
|
-
- Update ALL references across all files before finishing
|
|
258
|
-
- If any rename fails, stop and report — don't leave partial state
|
|
259
|
-
</safety>
|
|
260
|
-
|
|
261
|
-
<success_criteria>
|
|
262
|
-
Renumbering is complete when:
|
|
263
|
-
|
|
264
|
-
- [ ] Feature validated with plans and ROADMAP.md
|
|
265
|
-
- [ ] All phase directories collected and sorted correctly
|
|
266
|
-
- [ ] Renumbering mapping previewed and confirmed by user
|
|
267
|
-
- [ ] Directories renamed without collisions (highest-to-lowest)
|
|
268
|
-
- [ ] Plan file frontmatter updated (phase, depends_on references)
|
|
269
|
-
- [ ] ROADMAP.md headers updated, `(INSERTED)` markers removed
|
|
270
|
-
- [ ] STATE.md phase references updated everywhere
|
|
271
|
-
- [ ] config.json `phases_count` set to final integer count
|
|
272
|
-
- [ ] Summary shown to user
|
|
273
|
-
</success_criteria>
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
<purpose>
|
|
2
|
-
Research how to implement a feature by spawning parallel agents for different research dimensions.
|
|
3
|
-
|
|
4
|
-
Uses three parallel research tracks:
|
|
5
|
-
1. **Codebase Integration** - Claude Code Explore agent investigates existing code
|
|
6
|
-
2. **External Patterns** - General-purpose agent researches libraries, patterns, approaches
|
|
7
|
-
3. **Pitfalls** - General-purpose agent researches what goes wrong
|
|
8
|
-
|
|
9
|
-
Output: Single synthesized RESEARCH.md that the planner consumes.
|
|
10
|
-
</purpose>
|
|
11
|
-
|
|
12
|
-
<philosophy>
|
|
13
|
-
|
|
14
|
-
## Research Serves Planning
|
|
15
|
-
|
|
16
|
-
Every finding must be actionable. "Use Zustand" is useless. "Use Zustand 4.5+, create store in src/store/{feature}.ts following pattern from src/store/user.ts" is actionable.
|
|
17
|
-
|
|
18
|
-
## Codebase First
|
|
19
|
-
|
|
20
|
-
The most valuable research is understanding how this fits with existing code. External patterns matter, but integration patterns matter more.
|
|
21
|
-
|
|
22
|
-
## Verification Required
|
|
23
|
-
|
|
24
|
-
Don't trust Claude's training data for library versions or APIs. Verify with Context7 or official docs. Mark unverified findings as LOW confidence.
|
|
25
|
-
|
|
26
|
-
## Decisions Get Recorded
|
|
27
|
-
|
|
28
|
-
Any choice made during research (library selection, pattern choice, architecture decision) goes into DECISIONS.md with rationale.
|
|
29
|
-
|
|
30
|
-
</philosophy>
|
|
31
|
-
|
|
32
|
-
<research_dimensions>
|
|
33
|
-
|
|
34
|
-
## Dimension 1: Codebase Integration
|
|
35
|
-
|
|
36
|
-
**Agent:** Claude Code Explore (subagent_type="Explore")
|
|
37
|
-
**Purpose:** Understand how feature integrates with existing code
|
|
38
|
-
|
|
39
|
-
**Investigates:**
|
|
40
|
-
- What modules/files to import from
|
|
41
|
-
- What patterns similar features follow
|
|
42
|
-
- Where new files should be created
|
|
43
|
-
- What types/interfaces to reuse
|
|
44
|
-
- What utilities/hooks already exist
|
|
45
|
-
|
|
46
|
-
**Output format:**
|
|
47
|
-
```markdown
|
|
48
|
-
## Codebase Integration Findings
|
|
49
|
-
|
|
50
|
-
### Import Dependencies
|
|
51
|
-
- `src/lib/auth.ts` — provides `getSession()`, needed for user context
|
|
52
|
-
- `src/types/user.ts` — provides `User` type, needed for type safety
|
|
53
|
-
|
|
54
|
-
### Patterns to Follow
|
|
55
|
-
- **API routes:** Follow pattern in `src/app/api/users/route.ts`
|
|
56
|
-
- Use `getServerSession` for auth
|
|
57
|
-
- Return `Response.json()` with proper status codes
|
|
58
|
-
- Validate input with zod
|
|
59
|
-
|
|
60
|
-
### File Locations
|
|
61
|
-
New files:
|
|
62
|
-
- `src/app/api/{feature}/route.ts` — API endpoint
|
|
63
|
-
- `src/components/{Feature}/index.tsx` — Main component
|
|
64
|
-
- `src/hooks/use{Feature}.ts` — Data hook
|
|
65
|
-
- `src/types/{feature}.ts` — Type definitions
|
|
66
|
-
|
|
67
|
-
Modify:
|
|
68
|
-
- `src/app/layout.tsx` — Add provider if needed
|
|
69
|
-
|
|
70
|
-
### Reusable Code
|
|
71
|
-
Types:
|
|
72
|
-
- @src/types/common.ts — `ApiResponse<T>`, `PaginatedResponse<T>`
|
|
73
|
-
|
|
74
|
-
Utilities:
|
|
75
|
-
- @src/lib/fetcher.ts — `fetcher()` for SWR
|
|
76
|
-
- @src/lib/validation.ts — zod schemas
|
|
77
|
-
|
|
78
|
-
Components:
|
|
79
|
-
- @src/components/ui/Button — existing button component
|
|
80
|
-
- @src/components/ui/Input — existing input component
|
|
81
|
-
|
|
82
|
-
### Integration Points
|
|
83
|
-
- Auth: Use `getServerSession` from `@/lib/auth`
|
|
84
|
-
- Database: Use `db` from `@/lib/db`
|
|
85
|
-
- State: Create store in `src/store/` following existing pattern
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Dimension 2: External Patterns
|
|
89
|
-
|
|
90
|
-
**Agent:** general-purpose with feature-researcher instructions
|
|
91
|
-
**Purpose:** Research standard approaches, libraries, patterns
|
|
92
|
-
|
|
93
|
-
**Investigates:**
|
|
94
|
-
- Standard libraries for this feature type
|
|
95
|
-
- Architecture patterns that work well
|
|
96
|
-
- Code patterns and examples
|
|
97
|
-
- What NOT to hand-roll
|
|
98
|
-
|
|
99
|
-
**Tool strategy:**
|
|
100
|
-
1. Context7 first for any library
|
|
101
|
-
2. Official docs via WebFetch
|
|
102
|
-
3. WebSearch with current year
|
|
103
|
-
4. Verify everything
|
|
104
|
-
|
|
105
|
-
**Output format:**
|
|
106
|
-
```markdown
|
|
107
|
-
## External Patterns Findings
|
|
108
|
-
|
|
109
|
-
### Standard Stack
|
|
110
|
-
| Library | Version | Purpose | Confidence |
|
|
111
|
-
|---------|---------|---------|------------|
|
|
112
|
-
| zod | 3.22+ | Input validation | HIGH (Context7) |
|
|
113
|
-
| swr | 2.2+ | Data fetching | HIGH (Context7) |
|
|
114
|
-
|
|
115
|
-
### Architecture Pattern
|
|
116
|
-
**Pattern:** Feature-based modules
|
|
117
|
-
**Why:** Keeps related code together, easier to maintain
|
|
118
|
-
**Structure:**
|
|
119
|
-
```
|
|
120
|
-
src/features/{name}/
|
|
121
|
-
├── api.ts # API calls
|
|
122
|
-
├── hooks.ts # React hooks
|
|
123
|
-
├── types.ts # TypeScript types
|
|
124
|
-
├── components/ # UI components
|
|
125
|
-
└── index.ts # Public exports
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Code Patterns
|
|
129
|
-
|
|
130
|
-
**Data fetching with SWR:**
|
|
131
|
-
```typescript
|
|
132
|
-
// Source: Context7 - swr
|
|
133
|
-
export function use{Feature}() {
|
|
134
|
-
const { data, error, isLoading, mutate } = useSWR<{Feature}[]>(
|
|
135
|
-
'/api/{feature}',
|
|
136
|
-
fetcher
|
|
137
|
-
)
|
|
138
|
-
return { items: data, error, isLoading, refresh: mutate }
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Don't Hand-Roll
|
|
143
|
-
| Problem | Use Instead | Why |
|
|
144
|
-
|---------|-------------|-----|
|
|
145
|
-
| Form validation | zod + react-hook-form | Edge cases, error messages |
|
|
146
|
-
| Data fetching | SWR or React Query | Caching, revalidation, race conditions |
|
|
147
|
-
| Date formatting | date-fns | Timezone handling, localization |
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
## Dimension 3: Pitfalls
|
|
151
|
-
|
|
152
|
-
**Agent:** general-purpose with feature-researcher instructions
|
|
153
|
-
**Purpose:** Research what commonly goes wrong
|
|
154
|
-
|
|
155
|
-
**Investigates:**
|
|
156
|
-
- Common implementation mistakes
|
|
157
|
-
- Performance pitfalls
|
|
158
|
-
- Security issues
|
|
159
|
-
- Integration gotchas
|
|
160
|
-
|
|
161
|
-
**Output format:**
|
|
162
|
-
```markdown
|
|
163
|
-
## Pitfalls Findings
|
|
164
|
-
|
|
165
|
-
### Critical (causes failures/rewrites)
|
|
166
|
-
|
|
167
|
-
**Race conditions in data fetching**
|
|
168
|
-
- Why it happens: Multiple rapid requests, stale closures
|
|
169
|
-
- Prevention: Use SWR/React Query, they handle this
|
|
170
|
-
- Detection: Data flickers, wrong data after navigation
|
|
171
|
-
|
|
172
|
-
**Missing auth checks on API routes**
|
|
173
|
-
- Why it happens: Forget to add auth middleware
|
|
174
|
-
- Prevention: Auth check first line of every handler
|
|
175
|
-
- Detection: Unauthenticated access succeeds
|
|
176
|
-
|
|
177
|
-
### Moderate (causes bugs/debt)
|
|
178
|
-
|
|
179
|
-
**Type mismatches between API and client**
|
|
180
|
-
- Why it happens: Types defined separately, drift over time
|
|
181
|
-
- Prevention: Single source of truth for types, use zod inference
|
|
182
|
-
- Detection: Runtime errors, TypeScript errors after API changes
|
|
183
|
-
|
|
184
|
-
### Minor (causes friction)
|
|
185
|
-
|
|
186
|
-
**Inconsistent error handling**
|
|
187
|
-
- Why it happens: Different patterns in different places
|
|
188
|
-
- Prevention: Create `handleApiError` utility, use everywhere
|
|
189
|
-
- Detection: Error messages vary in format/location
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
</research_dimensions>
|
|
193
|
-
|
|
194
|
-
<synthesis>
|
|
195
|
-
|
|
196
|
-
## Combining Research
|
|
197
|
-
|
|
198
|
-
After all agents complete, synthesize into RESEARCH.md:
|
|
199
|
-
|
|
200
|
-
1. **Summary** - Key findings across all dimensions
|
|
201
|
-
2. **Codebase Integration** - Full findings from Explore agent
|
|
202
|
-
3. **Implementation Approach** - External patterns, adapted for this codebase
|
|
203
|
-
4. **Pitfalls** - All pitfalls with task-specific warnings
|
|
204
|
-
5. **Confidence Assessment** - Honest evaluation of each area
|
|
205
|
-
6. **Open Questions** - What couldn't be resolved
|
|
206
|
-
|
|
207
|
-
## Recording Decisions
|
|
208
|
-
|
|
209
|
-
During synthesis, identify any decisions that were made:
|
|
210
|
-
|
|
211
|
-
- Library choice → DEC-XXX with rationale
|
|
212
|
-
- Pattern choice → DEC-XXX with rationale
|
|
213
|
-
- Architecture choice → DEC-XXX with rationale
|
|
214
|
-
|
|
215
|
-
Add all to DECISIONS.md with:
|
|
216
|
-
- Date
|
|
217
|
-
- Context (from research)
|
|
218
|
-
- Decision
|
|
219
|
-
- Rationale (from findings)
|
|
220
|
-
- Implications (for implementation)
|
|
221
|
-
- References (sources used)
|
|
222
|
-
|
|
223
|
-
</synthesis>
|
|
224
|
-
|
|
225
|
-
<quality_gates>
|
|
226
|
-
|
|
227
|
-
## Before Spawning Agents
|
|
228
|
-
|
|
229
|
-
- [ ] Feature exists with FEATURE.md
|
|
230
|
-
- [ ] Codebase docs available (.specd/codebase/)
|
|
231
|
-
- [ ] Research dimensions identified
|
|
232
|
-
|
|
233
|
-
## After Each Agent
|
|
234
|
-
|
|
235
|
-
- [ ] Findings are specific (file paths, versions, code examples)
|
|
236
|
-
- [ ] Confidence levels assigned
|
|
237
|
-
- [ ] Sources cited
|
|
238
|
-
|
|
239
|
-
## Before Writing RESEARCH.md
|
|
240
|
-
|
|
241
|
-
- [ ] All agents completed
|
|
242
|
-
- [ ] Findings synthesized (not just concatenated)
|
|
243
|
-
- [ ] Conflicts resolved
|
|
244
|
-
- [ ] Decisions extracted
|
|
245
|
-
|
|
246
|
-
## Before Committing
|
|
247
|
-
|
|
248
|
-
- [ ] RESEARCH.md follows template
|
|
249
|
-
- [ ] DECISIONS.md updated with new decisions
|
|
250
|
-
- [ ] No LOW confidence items presented as recommendations
|
|
251
|
-
|
|
252
|
-
</quality_gates>
|