specdacular 0.2.1 → 0.2.2

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.
@@ -0,0 +1,252 @@
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>
@@ -1,55 +0,0 @@
1
- # Requirements: {Feature Name}
2
-
3
- ## v1 Requirements
4
-
5
- {Must-have requirements for the initial release. Each requirement should be testable and specific.}
6
-
7
- ### UI Requirements
8
- - [ ] **{FEAT}-UI-01**: {Testable requirement description}
9
- - [ ] **{FEAT}-UI-02**: {Testable requirement description}
10
-
11
- ### API Requirements
12
- - [ ] **{FEAT}-API-01**: {Testable requirement description}
13
-
14
- ### Data Requirements
15
- - [ ] **{FEAT}-DATA-01**: {Testable requirement description}
16
-
17
- ### Integration Requirements
18
- - [ ] **{FEAT}-INT-01**: {Testable requirement description}
19
-
20
- ## v2 Requirements
21
-
22
- {Deferred requirements for future iterations. Include rationale for deferral.}
23
-
24
- - **{FEAT}-UI-03**: {Requirement description}
25
- - *Deferred because:* {Rationale}
26
-
27
- - **{FEAT}-API-02**: {Requirement description}
28
- - *Deferred because:* {Rationale}
29
-
30
- ## Out of Scope
31
-
32
- {Explicitly excluded from this feature. Prevents scope creep.}
33
-
34
- | Feature | Reason |
35
- |---------|--------|
36
- | {What's excluded} | {Why it's out of scope} |
37
-
38
- ## Requirement Categories
39
-
40
- | Category | Code | Description |
41
- |----------|------|-------------|
42
- | UI | UI | User interface and interactions |
43
- | API | API | Backend endpoints and logic |
44
- | Data | DATA | Data models, storage, migrations |
45
- | Integration | INT | External services, third-party APIs |
46
- | Security | SEC | Authentication, authorization, data protection |
47
- | Performance | PERF | Speed, efficiency, scalability |
48
-
49
- ## Traceability
50
-
51
- | Requirement | Phase | Status | Notes |
52
- |-------------|-------|--------|-------|
53
- | {FEAT}-UI-01 | 1 | pending | |
54
- | {FEAT}-UI-02 | 1 | pending | |
55
- | {FEAT}-API-01 | 2 | pending | |