specdacular 0.2.2 → 0.2.5

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,583 @@
1
+ <purpose>
2
+ Research implementation patterns for a specific phase before executing it.
3
+
4
+ Uses three parallel research tracks tailored to the phase:
5
+ 1. **Codebase Integration** - How phase deliverables integrate with existing code
6
+ 2. **Phase-Type Patterns** - Patterns specific to this phase type (API, UI, etc.)
7
+ 3. **Phase-Type Pitfalls** - What goes wrong with this type of work
8
+
9
+ Output: `plans/phase-{NN}/RESEARCH.md` that execute-plan consumes.
10
+ </purpose>
11
+
12
+ <philosophy>
13
+
14
+ ## Phase-Focused Research
15
+
16
+ Don't research the whole feature again. Focus narrowly on what THIS phase creates/modifies. If phase 1 creates types, research type patterns. If phase 2 creates APIs, research API patterns.
17
+
18
+ ## Builds on Feature Research
19
+
20
+ If feature-level RESEARCH.md exists, don't duplicate it. Reference it and add phase-specific details.
21
+
22
+ ## Codebase First
23
+
24
+ The most valuable research is understanding how this phase's files integrate with existing code. External patterns matter, but integration patterns matter more.
25
+
26
+ ## Decisions Get Recorded
27
+
28
+ Any choice made during research goes into DECISIONS.md with phase context.
29
+
30
+ </philosophy>
31
+
32
+ <phase_type_research>
33
+
34
+ ## Types/Schema Phase Research
35
+ - Existing type patterns in codebase
36
+ - TypeScript/schema best practices
37
+ - Type relationships and composition
38
+ - Validation library patterns (zod, etc.)
39
+
40
+ ## API/Data Phase Research
41
+ - Existing API patterns in codebase
42
+ - REST/GraphQL conventions
43
+ - Error handling patterns
44
+ - Auth integration patterns
45
+ - Pagination patterns
46
+
47
+ ## Business Logic Phase Research
48
+ - Existing service patterns
49
+ - Error handling approaches
50
+ - Transaction patterns
51
+ - Testing patterns for logic
52
+
53
+ ## UI/Components Phase Research
54
+ - Existing component patterns
55
+ - State management approach
56
+ - Form handling patterns
57
+ - Loading/error state patterns
58
+ - Accessibility patterns
59
+
60
+ ## Integration Phase Research
61
+ - Existing integration patterns
62
+ - Provider/context patterns
63
+ - Initialization patterns
64
+ - Entry point conventions
65
+
66
+ </phase_type_research>
67
+
68
+ <process>
69
+
70
+ <step name="validate">
71
+ Validate feature exists and phase exists.
72
+
73
+ **Parse arguments:**
74
+ Split $ARGUMENTS into feature-name and phase-number.
75
+
76
+ ```bash
77
+ # Check feature exists
78
+ [ -d ".specd/features/$FEATURE_NAME" ] || { echo "Feature not found"; exit 1; }
79
+
80
+ # Check ROADMAP.md exists
81
+ [ -f ".specd/features/$FEATURE_NAME/ROADMAP.md" ] || { echo "No roadmap"; exit 1; }
82
+
83
+ # Check phase directory exists
84
+ PHASE_DIR=".specd/features/$FEATURE_NAME/plans/phase-$(printf '%02d' $PHASE_NUMBER)"
85
+ [ -d "$PHASE_DIR" ] || { echo "Phase not found"; exit 1; }
86
+
87
+ # Check if RESEARCH.md already exists
88
+ [ -f "$PHASE_DIR/RESEARCH.md" ] && echo "existing"
89
+ ```
90
+
91
+ **If RESEARCH.md exists:**
92
+ Use AskUserQuestion:
93
+ - header: "Research Exists"
94
+ - question: "Phase research already exists. What would you like to do?"
95
+ - options:
96
+ - "Update research" — Re-run research, incorporate new findings
97
+ - "View existing" — Show current RESEARCH.md
98
+ - "Continue anyway" — Skip research, use existing
99
+
100
+ Continue to load_context.
101
+ </step>
102
+
103
+ <step name="load_context">
104
+ Load all context needed for phase research.
105
+
106
+ **Read feature context:**
107
+ - `FEATURE.md` — Overall feature requirements
108
+ - `DECISIONS.md` — All decisions so far
109
+ - `ROADMAP.md` — Phase overview
110
+ - `RESEARCH.md` — Feature-level research if exists
111
+
112
+ **Read phase context:**
113
+ - All plan files in `plans/phase-{NN}/`
114
+ - `plans/phase-{NN}/CONTEXT.md` if exists (from discuss-phase)
115
+ - Previous phases' RESEARCH.md files for continuity
116
+
117
+ **Read codebase context:**
118
+ - `PATTERNS.md` — Code patterns to follow
119
+ - `STRUCTURE.md` — Where files go
120
+ - `MAP.md` — System overview
121
+
122
+ **Extract from ROADMAP.md:**
123
+ - Phase title and goal
124
+ - Phase type (Types, API, UI, Integration, Business Logic)
125
+ - Files to be created/modified
126
+
127
+ **Determine phase type** from ROADMAP.md or infer from files:
128
+ - `.ts` types files → Types/Schema
129
+ - `route.ts`, `api/` → API/Data
130
+ - `.tsx` components → UI/Components
131
+ - `service`, `util` → Business Logic
132
+ - `provider`, `setup` → Integration
133
+
134
+ Continue to present_research_plan.
135
+ </step>
136
+
137
+ <step name="present_research_plan">
138
+ Present research plan to user.
139
+
140
+ ```
141
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
142
+ RESEARCH PHASE {N}
143
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
144
+
145
+ **Feature:** {feature-name}
146
+ **Phase:** {N} — {Phase Title}
147
+ **Type:** {Phase Type}
148
+
149
+ ## Phase Deliverables
150
+
151
+ Files to create:
152
+ - {file 1}
153
+ - {file 2}
154
+
155
+ Files to modify:
156
+ - {file 3}
157
+
158
+ ## Research Dimensions
159
+
160
+ I'll research these areas for this {Phase Type} phase:
161
+
162
+ 1. **Codebase Integration** — How these files fit with existing code
163
+ - Existing patterns for {phase type}
164
+ - Files to import from
165
+ - Integration points
166
+
167
+ 2. **{Phase Type} Patterns** — Standard approaches
168
+ - Best practices for {phase type}
169
+ - Library patterns
170
+ - Code examples
171
+
172
+ 3. **{Phase Type} Pitfalls** — What goes wrong
173
+ - Common mistakes
174
+ - Performance issues
175
+ - Integration gotchas
176
+
177
+ Estimated: 3 parallel research agents
178
+
179
+ [Start research] / [Adjust scope]
180
+ ```
181
+
182
+ Use AskUserQuestion:
183
+ - header: "Research"
184
+ - question: "Start phase research?"
185
+ - options:
186
+ - "Start research" — Spawn agents
187
+ - "Adjust scope" — Modify research dimensions
188
+
189
+ Continue to spawn_agents.
190
+ </step>
191
+
192
+ <step name="spawn_agents">
193
+ Spawn three parallel research agents.
194
+
195
+ ### Agent 1: Codebase Integration (using Explore agent)
196
+
197
+ ```
198
+ Task(
199
+ prompt="Research how phase {N} of {feature-name} should integrate with the existing codebase.
200
+
201
+ <phase_context>
202
+ Phase: {N} — {Phase Title}
203
+ Type: {Phase Type}
204
+ Goal: {Phase goal from ROADMAP.md}
205
+
206
+ Files to create:
207
+ {list of files}
208
+
209
+ Files to modify:
210
+ {list of files}
211
+ </phase_context>
212
+
213
+ <locked_decisions>
214
+ {Relevant decisions from DECISIONS.md}
215
+ </locked_decisions>
216
+
217
+ <research_questions>
218
+ 1. What existing files/modules will this phase's files need to import from?
219
+ 2. What patterns do similar {phase type} files in this codebase follow?
220
+ 3. Where exactly should new files be created?
221
+ 4. What types/interfaces already exist that should be reused?
222
+ 5. What utility functions or hooks can be leveraged?
223
+ </research_questions>
224
+
225
+ <output_format>
226
+ Return findings as structured markdown:
227
+
228
+ ## Codebase Integration for Phase {N}
229
+
230
+ ### Import Dependencies
231
+ - `path/to/file` — what it provides, why needed
232
+
233
+ ### Patterns to Follow
234
+ - Pattern name: description, example file reference
235
+
236
+ ### File Locations
237
+ - Exactly where each new file should go
238
+
239
+ ### Reusable Code
240
+ - Types: list with paths
241
+ - Utilities: list with paths
242
+
243
+ ### Integration Points
244
+ - Where this phase's code connects to existing code
245
+ </output_format>
246
+ ",
247
+ subagent_type="Explore",
248
+ description="Phase codebase integration"
249
+ )
250
+ ```
251
+
252
+ ### Agent 2: Phase-Type Patterns Research
253
+
254
+ ```
255
+ Task(
256
+ prompt="First, read ~/.claude/specdacular/agents/feature-researcher.md for your role.
257
+
258
+ <research_type>
259
+ {Phase Type} patterns research for phase {N} of {feature-name}.
260
+ </research_type>
261
+
262
+ <phase_context>
263
+ Phase: {N} — {Phase Title}
264
+ Type: {Phase Type}
265
+ Goal: {Phase goal}
266
+
267
+ Files to create:
268
+ {list of files}
269
+ </phase_context>
270
+
271
+ <codebase_stack>
272
+ {From .specd/codebase/ if available}
273
+ </codebase_stack>
274
+
275
+ <research_questions>
276
+ 1. What's the standard approach for {phase type} in this stack?
277
+ 2. What libraries are commonly used for {phase type}?
278
+ 3. What code patterns work well for {phase type}?
279
+ 4. What should NOT be hand-rolled?
280
+ </research_questions>
281
+
282
+ <tool_strategy>
283
+ 1. Context7 first for any library questions
284
+ 2. Official docs via WebFetch for gaps
285
+ 3. WebSearch for patterns (include current year)
286
+ 4. Verify all findings
287
+ </tool_strategy>
288
+
289
+ <output_format>
290
+ Return findings as structured markdown with confidence levels.
291
+
292
+ ## {Phase Type} Patterns
293
+
294
+ ### Standard Approach
295
+ {Recommended approach with rationale}
296
+
297
+ ### Libraries
298
+ | Library | Version | Purpose | Confidence |
299
+
300
+ ### Code Patterns
301
+ {Code examples with sources}
302
+
303
+ ### Don't Hand-Roll
304
+ | Problem | Use Instead | Why |
305
+ </output_format>
306
+ ",
307
+ subagent_type="general-purpose",
308
+ model="sonnet",
309
+ description="Phase type patterns"
310
+ )
311
+ ```
312
+
313
+ ### Agent 3: Phase-Type Pitfalls Research
314
+
315
+ ```
316
+ Task(
317
+ prompt="First, read ~/.claude/specdacular/agents/feature-researcher.md for your role.
318
+
319
+ <research_type>
320
+ Pitfalls research for {Phase Type} work in phase {N} of {feature-name}.
321
+ </research_type>
322
+
323
+ <phase_context>
324
+ Phase: {N} — {Phase Title}
325
+ Type: {Phase Type}
326
+ Goal: {Phase goal}
327
+
328
+ Files to create:
329
+ {list of files}
330
+ </phase_context>
331
+
332
+ <research_questions>
333
+ 1. What do developers commonly get wrong with {phase type}?
334
+ 2. What are the performance pitfalls for {phase type}?
335
+ 3. What security issues should be avoided?
336
+ 4. What integration mistakes happen with {phase type}?
337
+ </research_questions>
338
+
339
+ <tool_strategy>
340
+ 1. WebSearch for common mistakes (include current year)
341
+ 2. Look for post-mortems, issue discussions
342
+ 3. Check official docs for warnings/caveats
343
+ </tool_strategy>
344
+
345
+ <output_format>
346
+ Return pitfalls as structured markdown:
347
+
348
+ ## {Phase Type} Pitfalls
349
+
350
+ ### Critical (causes failures/rewrites)
351
+ - Pitfall: description
352
+ - Why it happens
353
+ - Prevention
354
+ - Detection
355
+
356
+ ### Moderate (causes bugs/debt)
357
+ - Pitfall: description
358
+ - Prevention
359
+
360
+ ### Minor (causes friction)
361
+ - Pitfall: description
362
+ - Prevention
363
+ </output_format>
364
+ ",
365
+ subagent_type="general-purpose",
366
+ model="sonnet",
367
+ description="Phase type pitfalls"
368
+ )
369
+ ```
370
+
371
+ Wait for all agents to complete.
372
+
373
+ Continue to synthesize.
374
+ </step>
375
+
376
+ <step name="synthesize">
377
+ Combine agent results into single RESEARCH.md.
378
+
379
+ **Create plans/phase-{NN}/RESEARCH.md:**
380
+
381
+ ```markdown
382
+ # Phase {N} Research: {Phase Title}
383
+
384
+ **Feature:** {feature-name}
385
+ **Phase Type:** {Phase Type}
386
+ **Researched:** {today}
387
+
388
+ ## Summary
389
+
390
+ {2-3 paragraphs synthesizing all findings for this phase}
391
+
392
+ **Key recommendation:** {One-liner actionable guidance}
393
+
394
+ ---
395
+
396
+ ## Codebase Integration
397
+
398
+ {From Agent 1 — Explore findings}
399
+
400
+ ### Import From
401
+ | Module | Provides | Path |
402
+ |--------|----------|------|
403
+ | ... | ... | ... |
404
+
405
+ ### Patterns to Follow
406
+ {Patterns with file references}
407
+
408
+ ### File Locations
409
+ ```
410
+ {exact paths for new files}
411
+ ```
412
+
413
+ ### Reusable Code
414
+ - **Types:** {list with @paths}
415
+ - **Utilities:** {list with @paths}
416
+
417
+ ### Integration Points
418
+ {Where this phase connects to existing code}
419
+
420
+ ---
421
+
422
+ ## {Phase Type} Patterns
423
+
424
+ {From Agent 2 — Pattern findings}
425
+
426
+ ### Standard Approach
427
+ {Recommended approach with rationale}
428
+
429
+ ### Libraries
430
+ | Library | Version | Purpose | Confidence |
431
+ |---------|---------|---------|------------|
432
+ | ... | ... | ... | HIGH/MED |
433
+
434
+ ### Code Patterns
435
+ ```typescript
436
+ // Pattern name - source: {Context7/docs URL}
437
+ {code example}
438
+ ```
439
+
440
+ ### Don't Hand-Roll
441
+ | Problem | Use Instead | Why |
442
+ |---------|-------------|-----|
443
+ | ... | ... | ... |
444
+
445
+ ---
446
+
447
+ ## Pitfalls
448
+
449
+ {From Agent 3 — Pitfalls findings}
450
+
451
+ ### Critical
452
+ {List with prevention strategies}
453
+
454
+ ### Moderate
455
+ {List with prevention strategies}
456
+
457
+ ### Phase-Specific Warnings
458
+ | When Implementing | Watch Out For | Prevention |
459
+ |-------------------|---------------|------------|
460
+ | ... | ... | ... |
461
+
462
+ ---
463
+
464
+ ## Confidence Assessment
465
+
466
+ | Area | Level | Reason |
467
+ |------|-------|--------|
468
+ | Codebase integration | {level} | {reason} |
469
+ | {Phase type} patterns | {level} | {reason} |
470
+ | Pitfalls | {level} | {reason} |
471
+
472
+ ## Open Questions
473
+
474
+ {Anything that couldn't be resolved}
475
+
476
+ ## Sources
477
+
478
+ ### Codebase (from Explore)
479
+ - {file references used}
480
+
481
+ ### External (verified)
482
+ - {Context7 queries}
483
+ - {Official docs URLs}
484
+ ```
485
+
486
+ Continue to record_decisions.
487
+ </step>
488
+
489
+ <step name="record_decisions">
490
+ Record any technology choices from research.
491
+
492
+ **Identify decisions from synthesis:**
493
+ - Library choices
494
+ - Pattern choices
495
+ - Approach choices
496
+
497
+ **For each new decision, add to DECISIONS.md:**
498
+
499
+ ```markdown
500
+ ### DEC-{NNN}: {Title}
501
+
502
+ **Date:** {today}
503
+ **Status:** Active
504
+ **Phase:** {N} — {Phase Title}
505
+ **Context:** Identified during phase research
506
+ **Decision:** {What was decided}
507
+ **Rationale:** {From research findings}
508
+ **Implications:** {What this means for implementation}
509
+ **References:** {Sources}
510
+ ```
511
+
512
+ Continue to commit.
513
+ </step>
514
+
515
+ <step name="commit">
516
+ Commit the phase research.
517
+
518
+ ```bash
519
+ git add ".specd/features/{feature}/plans/phase-{NN}/RESEARCH.md"
520
+ git add ".specd/features/{feature}/DECISIONS.md"
521
+
522
+ git commit -m "docs({feature}): research phase {N} - {phase title}
523
+
524
+ Research dimensions:
525
+ - Codebase integration
526
+ - {Phase type} patterns
527
+ - {Phase type} pitfalls
528
+
529
+ Key findings:
530
+ - {one-liner from summary}"
531
+ ```
532
+
533
+ Continue to completion.
534
+ </step>
535
+
536
+ <step name="completion">
537
+ Present summary and next options.
538
+
539
+ ```
540
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
541
+ PHASE RESEARCH COMPLETE
542
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
543
+
544
+ **Feature:** {feature-name}
545
+ **Phase:** {N} — {Phase Title}
546
+ **Confidence:** {overall level}
547
+
548
+ ## Key Findings
549
+
550
+ - {Finding 1}
551
+ - {Finding 2}
552
+ - {Finding 3}
553
+
554
+ ## Files Created
555
+
556
+ - `plans/phase-{NN}/RESEARCH.md`
557
+ - Updated `DECISIONS.md` with {N} new decisions
558
+
559
+ ───────────────────────────────────────────────────────
560
+
561
+ ## What's Next
562
+
563
+ **/specd:execute-plan {feature}** — Execute this phase (will load phase research)
564
+
565
+ **/specd:discuss-phase {feature} {N}** — Discuss this phase further
566
+
567
+ <sub>/clear first — fresh context window for execution</sub>
568
+ ```
569
+
570
+ End workflow.
571
+ </step>
572
+
573
+ </process>
574
+
575
+ <success_criteria>
576
+ - Feature and phase validated
577
+ - Phase context loaded (goals, files, type)
578
+ - Research agents spawned in parallel
579
+ - Results synthesized into phase RESEARCH.md
580
+ - Decisions recorded in DECISIONS.md
581
+ - Committed to git
582
+ - User knows next step is execute-plan
583
+ </success_criteria>