@codename_inc/spectre 3.7.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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +411 -0
  3. package/bin/spectre.js +8 -0
  4. package/package.json +23 -0
  5. package/plugins/spectre/.claude-plugin/plugin.json +5 -0
  6. package/plugins/spectre/agents/analyst.md +122 -0
  7. package/plugins/spectre/agents/dev.md +70 -0
  8. package/plugins/spectre/agents/finder.md +105 -0
  9. package/plugins/spectre/agents/patterns.md +207 -0
  10. package/plugins/spectre/agents/reviewer.md +128 -0
  11. package/plugins/spectre/agents/sync.md +151 -0
  12. package/plugins/spectre/agents/tester.md +209 -0
  13. package/plugins/spectre/agents/web-research.md +109 -0
  14. package/plugins/spectre/commands/architecture_review.md +120 -0
  15. package/plugins/spectre/commands/clean.md +313 -0
  16. package/plugins/spectre/commands/code_review.md +408 -0
  17. package/plugins/spectre/commands/create_plan.md +117 -0
  18. package/plugins/spectre/commands/create_tasks.md +374 -0
  19. package/plugins/spectre/commands/create_test_guide.md +120 -0
  20. package/plugins/spectre/commands/evaluate.md +50 -0
  21. package/plugins/spectre/commands/execute.md +87 -0
  22. package/plugins/spectre/commands/fix.md +61 -0
  23. package/plugins/spectre/commands/forget.md +58 -0
  24. package/plugins/spectre/commands/handoff.md +161 -0
  25. package/plugins/spectre/commands/kickoff.md +115 -0
  26. package/plugins/spectre/commands/learn.md +15 -0
  27. package/plugins/spectre/commands/plan.md +170 -0
  28. package/plugins/spectre/commands/plan_review.md +33 -0
  29. package/plugins/spectre/commands/quick_dev.md +101 -0
  30. package/plugins/spectre/commands/rebase.md +73 -0
  31. package/plugins/spectre/commands/recall.md +5 -0
  32. package/plugins/spectre/commands/research.md +159 -0
  33. package/plugins/spectre/commands/scope.md +119 -0
  34. package/plugins/spectre/commands/ship.md +172 -0
  35. package/plugins/spectre/commands/sweep.md +82 -0
  36. package/plugins/spectre/commands/test.md +380 -0
  37. package/plugins/spectre/commands/ux_spec.md +91 -0
  38. package/plugins/spectre/commands/validate.md +343 -0
  39. package/plugins/spectre/hooks/hooks.json +34 -0
  40. package/plugins/spectre/hooks/scripts/bootstrap.cjs +99 -0
  41. package/plugins/spectre/hooks/scripts/handoff-resume.cjs +410 -0
  42. package/plugins/spectre/hooks/scripts/lib.cjs +83 -0
  43. package/plugins/spectre/hooks/scripts/load-knowledge.cjs +120 -0
  44. package/plugins/spectre/hooks/scripts/precompact-warning.cjs +19 -0
  45. package/plugins/spectre/hooks/scripts/register_learning.cjs +144 -0
  46. package/plugins/spectre/hooks/scripts/test_bootstrap.cjs +84 -0
  47. package/plugins/spectre/hooks/scripts/test_handoff-resume.cjs +858 -0
  48. package/plugins/spectre/hooks/scripts/test_load-knowledge.cjs +285 -0
  49. package/plugins/spectre/hooks/scripts/test_register-learning.cjs +146 -0
  50. package/plugins/spectre/skills/spectre-apply/SKILL.md +189 -0
  51. package/plugins/spectre/skills/spectre-guide/SKILL.md +358 -0
  52. package/plugins/spectre/skills/spectre-learn/SKILL.md +635 -0
  53. package/plugins/spectre/skills/spectre-learn/references/recall-template.md +31 -0
  54. package/plugins/spectre/skills/spectre-tdd/SKILL.md +111 -0
  55. package/src/config.test.js +134 -0
  56. package/src/install.test.js +273 -0
  57. package/src/lib/config.js +516 -0
  58. package/src/lib/constants.js +60 -0
  59. package/src/lib/doctor.js +168 -0
  60. package/src/lib/install.js +482 -0
  61. package/src/lib/knowledge.js +217 -0
  62. package/src/lib/paths.js +98 -0
  63. package/src/lib/project.js +473 -0
  64. package/src/main.js +150 -0
@@ -0,0 +1,408 @@
1
+ ---
2
+ description: 👻 | Independent LLM Code Review - subagent
3
+ ---
4
+ # code_review: Comprehensive Code Analysis
5
+
6
+ ## Description
7
+
8
+ - Description — Conduct thorough, comprehensive code analysis covering all aspects of code quality, security, and production readiness. Provides comprehensive analysis in single review session with severity-based findings and actionable recommendations.
9
+ - Desired Outcome — Complete code review report with severity-categorized findings (CRITICAL/HIGH/MEDIUM/LOW), comprehensive scores, prioritized action plan, saved to a scoped report file (default `comprehensive_code_review.md`, but use a scoped filename if one already exists).
10
+
11
+ ## ARGUMENTS Input
12
+
13
+ Optional user input to seed this workflow.
14
+
15
+ <ARGUMENTS> $ARGUMENTS </ARGUMENTS>
16
+
17
+ ## Step (1/4) - Define Review Scope
18
+
19
+ - **Action** — ProcessGuidance: Check for ARGUMENTS and extract guidance.
20
+ - **If** ARGUMENTS exists → acknowledge guidance; extract specific focus areas;
21
+ - Proceed with comprehensive review while honoring context
22
+ - **Action** — SpecifyScope: Define exact scope using completed work and modified files to prevent scope creep.
23
+ - **CRITICAL**: Before dispatching review agent, provide what was actually implemented and files touched/modified; gives concrete scope boundaries regardless of work origin
24
+
25
+ **Review Scope Specification - Choose Appropriate Scenario:**
26
+
27
+ **Common File Format (All Scenarios):**
28
+
29
+ ```plaintext
30
+ **Files Modified/Created:**
31
+ - `path/to/file.ext` ({created|modified|deleted} - {purpose/what changed})
32
+
33
+ **Related Files for Review:**
34
+ - `path/to/related.ext` ({imports|dependencies|tests|config})
35
+ ```
36
+
37
+ #### **Scenario A: Work from Task List** (when `tasks.md` exists and was followed)
38
+
39
+ ```plaintext
40
+ **Work Completed (from Task List):**
41
+ - Task 1.1: [exact task description from tasks.md]
42
+ - Task 1.2: [exact task description from tasks.md]
43
+ - Task 2.1: [exact task description from tasks.md]
44
+
45
+ [Use common file format above]
46
+ ```
47
+
48
+ #### **Scenario B: Work from Plan** (working from `plan.md` without formal tasks)
49
+
50
+ ```plaintext
51
+ **Work Completed (from Plan Implementation):**
52
+ - Implemented: [specific functionality completed, referencing plan.md sections]
53
+ - Delivered: [specific features/capabilities built]
54
+ - Completed: [specific plan items addressed]
55
+
56
+ [Use common file format above]
57
+
58
+ **Plan Context:**
59
+ - Plan Section: [specific sections of plan.md implemented]
60
+ - Plan Requirements: [requirements from plan this work addresses]
61
+ ```
62
+
63
+ #### **Scenario C: Ad-hoc/Independent Work** (work without formal tasks or detailed plan)
64
+
65
+ ```plaintext
66
+ **Work Completed (Independent Implementation):**
67
+ - Implemented: [specific functionality completed]
68
+ - Purpose: [why this work was done - bug fix, feature addition, etc.]
69
+ - Scope: [what was intended to be delivered]
70
+
71
+ [Use common file format above]
72
+
73
+ **Requirements Context:**
74
+ - Original Requirements: [extract from task_summary.md, PRD, or user request]
75
+ - Acceptance Criteria: [how success is defined for this work]
76
+ - Constraints: [any technical or scope constraints that applied]
77
+ ```
78
+
79
+ - **Action** — ExtractWorkContext: Extract requirements and context from appropriate documentation based on scenario.
80
+ - All scenarios: Extract work requirements → trace to origin docs (PRD/task_summary) → pull technical details → identify file context → document out-of-scope
81
+ - **Scenario A**: Source from `tasks.md`
82
+ - **Scenario B**: Source from `plan.md`/`quick_task_plan.md`
83
+ - **Scenario C**: Source from task_summary.md/PRD/user comms; define acceptance criteria
84
+
85
+ ## Step (2/4) - Dispatch Review Agent
86
+
87
+ - **Action** — GenerateReviewPrompt: Create comprehensive @spectre:reviewer subagent prompt replacing bracketed placeholders:
88
+
89
+ ────────────────────────────────────
90
+
91
+ ### 🔍 Comprehensive Code Review Agent Prompt
92
+
93
+ **Review Type:** Comprehensive Analysis (All Aspects)
94
+
95
+ **Work Completed for Review:**\[Choose appropriate format based on work origin - Scenario A, B, or C from Step 2\]
96
+
97
+ **Files Modified/Created:**\[Complete list of files touched during implementation\]
98
+
99
+ - `path/to/file1.py` (created - \[brief purpose\])
100
+ - `path/to/file2.py` (modified - \[what was changed\])
101
+ - `path/to/file3.py` (deleted - \[reason\])
102
+
103
+ **Related Files to Review:**\[Dependencies, tests, config files that may be impacted\]
104
+
105
+ - `path/to/related1.py` (imports/dependencies)
106
+ - `path/to/test_file.py` (test coverage)
107
+ - `config/settings.py` (configuration changes)
108
+
109
+ **Requirements & Context:**\[Specific requirements and acceptance criteria for work completed - extracted from appropriate documentation based on scenario\]
110
+
111
+ **Project Overview:**\[High‑level feature/bug description, requirements, acceptance criteria\]
112
+
113
+ **Documentation Context:**`docs/tasks/{task_name}/` (if available)
114
+
115
+ - Available docs: \[list which exist: task_summary.md, prd.md, plan.md, tasks.md\]
116
+ - Missing docs: \[list which expected docs are missing\]
117
+
118
+ **Guidelines & Preferences:**\[Style guides, architecture rules, naming conventions, test expectations\]
119
+
120
+ ---
121
+
122
+ #### Step 1: Context Collection & Code Identification
123
+
124
+ **FIRST: Gather Task Context**
125
+
126
+ 1. **Read Task Documentation**: Locate and read files in `docs/tasks/{task_name}/`:
127
+
128
+ - `scope.md` or `ux.md` or `prd.md` or `spec.md` or any other scope artifact
129
+ - `initial_plan.md` or `plan.md` or `quick_task_plan.md` - Implementation approach
130
+ - `tasks.md` or `{task_name}_tasks.md` - Specific work items and progress
131
+
132
+ 2. **Identify Code Scope**: Based on task documentation:
133
+
134
+ - **Primary Files**: Files directly mentioned in plans and task lists
135
+ - **Related Files**: Dependencies, imports, related modules
136
+ - **Test Files**: Associated unit tests and integration tests
137
+ - **Configuration**: Any config changes related to feature
138
+
139
+ 3. **Explore Codebase**: Use codebase search tools to:
140
+
141
+ - Find implementations mentioned in task documentation
142
+ - Locate related functions, classes, modules
143
+ - Identify recent changes related to task scope
144
+
145
+ **Code Review Scope Decision**: Focus review on code that:
146
+
147
+ - ✅ Is directly mentioned in task documentation
148
+ - ✅ Implements features described in plan
149
+ - ✅ Contains recent changes related to task objectives
150
+ - ✅ Has dependencies or impacts from primary implementation
151
+
152
+ **THEN: Proceed with Comprehensive Review**
153
+
154
+ ---
155
+
156
+ #### Step 2: Comprehensive Code Review Analysis
157
+
158
+ **Severity Scale Reference:**
159
+
160
+ - **CRITICAL**: Prevents execution, security vulnerabilities, auth bypasses, data exposure
161
+ - **HIGH**: Affects maintainability, core functionality, user experience, resource leaks
162
+ - **MEDIUM**: Quality improvements, test coverage, configuration, performance (non-critical)
163
+ - **LOW**: Documentation, polish, cleanup
164
+
165
+ **Perform comprehensive analysis covering all aspects:**
166
+
167
+ ### 🔧 Foundation & Correctness
168
+
169
+ **1. Compile/Run Readiness** → CRITICAL if prevents execution
170
+
171
+ - Syntax errors, unresolved references, missing imports/modules
172
+ - Misconfigured build / dependency files
173
+
174
+ **2. Structural Soundness** → HIGH if affects maintainability
175
+
176
+ - File & class organization, directory layout, module boundaries
177
+
178
+ **3. Implementation Completeness** → HIGH if core functionality missing
179
+
180
+ - Stubbed functions, TODO/FIXME markers, unhandled edge paths
181
+ - Absence of required unit tests or placeholders for them
182
+
183
+ **4. Logic Validation** → CRITICAL if breaks functionality
184
+
185
+ - Off‑by‑one mistakes, null handling, obvious condition errors
186
+ - End‑to‑end scenario walkthroughs against requirements
187
+ - State transitions and error flows for all inputs
188
+
189
+ ### 🛡️ Security & Safety
190
+
191
+ **Input Validation & Injection Prevention** → CRITICAL
192
+
193
+ - SQL injection: Parameterized queries, input sanitization
194
+ - XSS: Output encoding, Content Security Policy, input validation
195
+ - Command injection: Avoid system calls with user input
196
+ - Path traversal: Validate file paths, use safe path operations
197
+
198
+ **Authentication & Authorization** → CRITICAL for auth bypasses
199
+
200
+ - Broken authentication: Session management, password policies
201
+ - Privilege escalation: Role-based access control validation
202
+ - JWT security: Proper signing, expiration, secure storage
203
+ - API authentication: Rate limiting, token validation
204
+
205
+ **Data Protection** → CRITICAL for data exposure
206
+
207
+ - Sensitive data exposure: Encryption at rest and in transit
208
+ - PII handling: Data minimization, proper anonymization
209
+ - Hard-coded secrets: Environment variables, secret management
210
+ - Insecure randomness: Cryptographically secure random generation
211
+
212
+ **API & Network Security** → HIGH
213
+
214
+ - SSRF: URL validation, allowlist external requests
215
+ - CORS misconfiguration: Proper origin validation
216
+ - API rate limiting: Prevent abuse and DoS
217
+ - HTTPS enforcement: Secure transport, HSTS headers
218
+
219
+ ### 🎯 Quality & Robustness
220
+
221
+ **5. Error Handling & User Safety** → HIGH if affects user experience
222
+
223
+ - Ensure graceful degradation and clear, user‑appropriate messages
224
+ - Detect error states that could block users or leak internal details
225
+
226
+ **6. Test Coverage & Quality** → MEDIUM if adequate coverage exists
227
+
228
+ - Measure unit/integration test breadth, branch coverage, boundary cases
229
+ - Point out missing negative tests and flaky patterns
230
+
231
+ **7. Performance Considerations** → HIGH if affects UX, MEDIUM otherwise
232
+
233
+ - O(n²) loops on large data, excessive network/DB calls, synchronous waits
234
+ - N+1 queries, blocking I/O on hot paths
235
+ - Inefficient algorithms, caching opportunities
236
+
237
+ **8. Code Quality & Maintainability** → MEDIUM
238
+
239
+ - Duplication & reusability: Copy‑pasted blocks, redundant utility functions
240
+ - Design consistency: Architecture layers, API contracts, dependency inversion
241
+ - Naming coherence, comment accuracy, adherence to style guides
242
+
243
+ ### 🚀 Production Readiness
244
+
245
+ **9. Resource Management** → HIGH if causes leaks, MEDIUM otherwise
246
+
247
+ - Memory & resource leaks: Unclosed files/streams, lingering timers, event listeners, DB cursors
248
+ - Repeated allocations in tight loops, large object retention
249
+
250
+ **10. Infrastructure & Configuration** → MEDIUM
251
+
252
+ - Insecure dependencies: Known CVEs, outdated packages
253
+ - Security headers: CSP, X-Frame-Options, etc.
254
+ - Error handling: No sensitive info in error messages
255
+ - Logging security: No credentials in logs, log injection prevention
256
+
257
+ **11. Documentation & Developer UX** → LOW
258
+
259
+ - Up‑to‑date README, code comments, public API docs
260
+ - Log levels appropriate, no PII in logs, actionable messages
261
+
262
+ **12. Final Polish** → LOW
263
+
264
+ - Remove unused functions, constants, feature flags, debug prints
265
+ - Ensure commit history or diff is clean and scoped
266
+
267
+ **Critical Rule for Review Recommendations:**
268
+
269
+ - **Flag as Issues**: Only problems that prevent delivering **Work Completed** requirements
270
+ - **Suggest Improvements**: Only changes that directly support **Work Completed** acceptance criteria
271
+ - **DO NOT Flag**: Missing functionality from incomplete work, future plans, or different scopes
272
+ - **DO NOT Suggest**: Enhancements beyond minimal viable implementation for completed work
273
+
274
+ ---
275
+
276
+ ### Response Format
277
+
278
+ **Structure your review report with these sections:**
279
+
280
+ 1. **Work & File Scope Boundary Validation** – Confirmation that review aligns with completed work and modified files
281
+
282
+ - Completed work parsed and understood (tasks/plan/independent work with specifics)
283
+ - Modified/created files identified and their purposes understood
284
+ - Work-specific requirements extracted from available documentation
285
+ - In-scope vs out-of-scope work/files for THIS review clearly identified
286
+ - Other work not completed or out of scope explicitly excluded from this review
287
+
288
+ 2. **Context Collection Summary** – Brief overview of task documentation reviewed and code scope identified
289
+
290
+ 3. **Files Reviewed** – List of specific files and code areas examined
291
+
292
+ 4. **Summary Assessment** – Overall readiness, security posture, and risk level
293
+
294
+ 5. **Detailed Findings by Severity**:
295
+
296
+ **🚨 CRITICAL Issues** - Must fix before any deployment
297
+
298
+ - `[File:Line]` **Security/Functionality**: \[Description and fix\]
299
+
300
+ **🔥 HIGH Priority** - Should fix before next stage
301
+
302
+ - `[File:Line]` **Logic/Performance**: \[Description and fix\]
303
+
304
+ **⚠️ MEDIUM Priority** - Quality improvements
305
+
306
+ - `[File:Line]` **Code Quality**: \[Description and fix\]
307
+
308
+ **💡 LOW Priority** - Nice-to-have improvements
309
+
310
+ - `[File:Line]` **Polish/Documentation**: \[Description and fix\]
311
+
312
+ 6. **Comprehensive Scores (0‑10)**:
313
+
314
+ - **Security Posture**: \[Score\] - Vulnerability assessment
315
+ - **Logic Correctness**: \[Score\] - Functionality validation
316
+ - **Code Quality**: \[Score\] - Maintainability and structure
317
+ - **Production Readiness**: \[Score\] - Overall deployment readiness
318
+
319
+ 7. **Prioritized Action Plan** – Ordered list of fixes by severity and impact
320
+
321
+ Save the report as **Markdown Document** (default `docs/tasks/{task_name}/reviews/comprehensive_code_review.md`; if it already exists, create a scoped variant like `docs/tasks/{task_name}/reviews/{task_name}_comprehensive_code_review_{timestamp}.md` to avoid overwriting). Create `docs/tasks/{task_name}` if it does not exist.
322
+
323
+ Respond to user with summary of only high priority items and point to file. Do not perform fixes yourself.
324
+
325
+ ### Final Important Note
326
+
327
+ We are a startup building an early stage product hoping to find Product Market Fit. We must avoid over-engineering like the plague. Stick to YAGNI + SOLID + KISS + DRY principles. All recommendations, while comprehensive, should not over complicate the product or architecture for the stage that we're in.
328
+
329
+ **CRITICAL**: DO NOT flag missing features from incomplete work or different scopes. DO NOT suggest improvements beyond what is explicitly requested in completed work. Focus only on ensuring code delivers what was specifically asked for in completed work, not entire project scope.
330
+
331
+ ────────────────────────────────────
332
+
333
+ - **Action** — DispatchAgent: Deploy @spectre:reviewer subagent code review agent with comprehensive prompt above.
334
+
335
+ ## Step (3/4) - Process Review & Create Action Plan
336
+
337
+ - **Action** — CollectReview: Monitor and receive comprehensive code review analysis.
338
+
339
+ - Wait for review agent completion
340
+ - Receive comprehensive report with severity-based findings
341
+ - Verify report covers all required areas (foundation, security, quality, production readiness)
342
+
343
+ - **Action** — ProcessFindings: Create actionable next steps.
344
+
345
+ - Summarize by severity: Extract CRITICAL, identify HIGH, note MEDIUM, catalog LOW
346
+ - Create action plan: Prioritize by severity and impact; suggest implementation order (CRITICAL → HIGH → MEDIUM → LOW); identify additional resources needed; group related fixes
347
+
348
+ - **Action** — PresentSummary: Present findings to user with numbered, severity‑based summary.
349
+
350
+ > **🔍 Comprehensive Code Review Complete**
351
+ **> **Overall Assessment**: \[Brief headline on code readiness, security posture, risk level\]
352
+ **> **Review Report Location**: `{REVIEW_FILE}`
353
+ >
354
+ > ## Key Findings (Numbered for User Selection)
355
+ >
356
+ > ### 🚨 Critical Issues (Must Fix Immediately)
357
+ >
358
+ > 1. **\[Security/Functionality\]**: \[Brief description with file/line reference\]
359
+ >
360
+ > - **Impact**: \[Why this is critical\]
361
+ > - **Recommendation**: \[Specific fix needed\]
362
+ >
363
+ > 2. **\[Security/Functionality\]**: \[Brief description with file/line reference\]
364
+ >
365
+ > - **Impact**: \[Why this is critical\]
366
+ > - **Recommendation**: \[Specific fix needed\]
367
+ >
368
+ > ### 🔥 High Priority (Should Fix Next)
369
+ >
370
+ > 3. **\[Logic/Performance\]**: \[Brief description with file/line reference\]
371
+ >
372
+ > - **Impact**: \[Quality/performance impact\]
373
+ > - **Effort**: \[Estimated complexity\]
374
+ >
375
+ > 4. **\[Error Handling\]**: \[Brief description with file/line reference\]
376
+ >
377
+ > - **Impact**: \[User experience impact\]
378
+ > - **Effort**: \[Estimated complexity\]
379
+ >
380
+ > ### ⚠️ Medium Priority (Quality Improvements)
381
+ >
382
+ > 5. **\[Code Quality\]**: \[Brief description with file/line reference\]
383
+ >
384
+ > - **Benefit**: \[Maintainability improvement\]
385
+ > - **Effort**: \[Low/Medium complexity\]
386
+ >
387
+ > 6. **\[Test Coverage\]**: \[Brief description with file/line reference\]
388
+ >
389
+ > - **Benefit**: \[Quality assurance improvement\]
390
+ > - **Effort**: \[Low/Medium complexity\]
391
+ >
392
+ > ### 💡 Low Priority (Polish & Documentation)
393
+ >
394
+ > 7. **\[Documentation\]**: \[Brief description\]
395
+ > - **Benefit**: \[Developer experience improvement\]
396
+ > - **Effort**: \[Low complexity\]
397
+
398
+ ## Step (4/4) - Handoff
399
+
400
+ - **Action** — RenderFooter: Render Next Steps using `@skill-spectre:spectre-guide` skill.
401
+
402
+ ## Output Location
403
+
404
+ ```bash
405
+ branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)
406
+ OUT_DIR=${target_dir:-docs/tasks/$branch_name}
407
+ mkdir -p "$OUT_DIR/reviews"
408
+ ```
@@ -0,0 +1,117 @@
1
+ ---
2
+ description: 👻 | Create implementation plan from PRD - primary agent
3
+ ---
4
+ # create_plan: Transform PRD into Technical Implementation Plan
5
+
6
+ ## Description
7
+
8
+ - **What** — Conduct codebase research, collect clarifications, generate implementation plan
9
+ - **Outcome** — Complete `plan.md` with technical approach, phases, and architecture; ready for task breakdown
10
+ - **Role** — Sr. staff engineer biasing to YAGNI + SOLID + KISS + DRY
11
+
12
+ ## ARGUMENTS Input
13
+
14
+ <ARGUMENTS> $ARGUMENTS </ARGUMENTS>
15
+
16
+ ## Step (1/4) - Codebase Architecture Research
17
+
18
+ - **Action** — CheckExistingResearch: Check if technical research already completed.
19
+ - Read `TASK_DIR/task_context.md`; look for "## Technical Research" section.
20
+ - **If** found with comprehensive analysis → use existing research; skip to Step 3.
21
+ - **Else** → proceed with new research below.
22
+ - **Action** — AutomatedResearch: Spawn parallel research agents for comprehensive analysis.
23
+ - Use `codebase-locator` to find all files related to feature area.
24
+ - Dispatch multiple parallel `codebase-analyzer` subagents to understand current implementation patterns. Pay particular attention to how and where data is accessed that will be needed for this feature.
25
+ - Wait for ALL agents to complete before proceeding.
26
+ - Read ALL identified files into context.
27
+ - **Action** — TraceCodePaths: Trace through relevant execution paths.
28
+ - Identify the key entry points for the feature area (routes, handlers, event listeners, CLI commands).
29
+ - Follow the data flow end-to-end: from input → processing → storage → output.
30
+ - Find similar features already implemented in the codebase and study how they work — these are your implementation reference.
31
+ - Read the actual code at each step; do not rely on file names or agent summaries alone.
32
+ - **Action** — DocumentationReview: Review core architecture documentation.
33
+ - Review `CLAUDE.md` for rules and key patterns.
34
+ - Review `README.md` for major components.
35
+ - Cross-reference automated findings with documentation.
36
+ - **Action** — PatternAnalysis: Synthesize findings.
37
+ - Synthesize agent findings with manual code path analysis.
38
+ - Identify reusable components and utilities from research.
39
+ - Note integration patterns with existing systems.
40
+ - Validate agent discoveries through code inspection.
41
+ - **Output Location** — DetermineOutputDir: Decide where to save artifacts for this workflow.
42
+ - `branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)`
43
+ - **If** user specifies `target_dir/path` → `OUT_DIR={that value}`
44
+ - **Else** → `OUT_DIR=docs/tasks/{branch_name}`
45
+ - `mkdir -p "OUT_DIR/specs"` && `mkdir -p "OUT_DIR/clarifications"`
46
+ - **Action** — SaveResearch: Save technical research to task context (if newly completed).
47
+ - **If** research was just completed → update `{OUT_DIR}/task_context.md` with a "## Technical Research" section summarizing architecture patterns, dependencies, similar features found, and integration requirements.
48
+ - **Else** → skip (existing research already in context).
49
+
50
+ ## Step (2/4) - Technical Clarifications
51
+
52
+ Dynamically generate up to 10 technical questions based on research findings. **IMPORTANT**: Only ask questions genuinely not answered in the PRD or discoverable through code investigation. Goal: eliminate scope and design ambiguity. If a question involves choosing between approaches, present options with Pros/Cons/Trade-offs.
53
+
54
+ - **Action** — DetectClarificationMethod: Check if `AskUserQuestion` tool is available.
55
+ - **If available** → use inline clarification flow (Path A).
56
+ - **If not available** → use file-based clarification flow (Path B).
57
+
58
+ ### Path A: Inline Clarifications (AskUserQuestion available)
59
+
60
+ - **Action** — AskInline: Present questions directly using AskUserQuestion.
61
+ - Ask the most critical questions (up to 4 at a time, the tool limit).
62
+ - For approach decisions, present options as choices.
63
+ - If more than 4 questions, ask in batches — most important first.
64
+ - Use responses (and intelligent defaults for any skipped) to proceed.
65
+
66
+ ### Path B: File-Based Clarifications (no AskUserQuestion)
67
+
68
+ - **Action** — GenerateClarifications: Create targeted technical questions document.
69
+ - Create directory if missing: `{OUT_DIR}/clarifications/`
70
+ - Create file: `{OUT_DIR}/clarifications/plan_clarifications_{YYYY-MM-DD_HHMMSS}.md`
71
+ - Format each question with `<response></response>` blocks for user answers.
72
+ - For approach decisions, list options inline with Pros/Cons/Trade-offs/Impact.
73
+ - **Action** — RequestUserInput: Direct user to answer clarifications.
74
+ - Message: "I saved technical clarifications here: `{clarifications_file_path}`. Please add answers inside `<response></response>` blocks. Leave blocks empty for me to proceed with intelligent assumptions. When ready, reply 'Read it'."
75
+ - Render ACTION REQUIRED footer (see Next Steps section for format).
76
+ - **Wait** — User replies "Read it" after updating clarifications document.
77
+ - **Action** — ReadClarifications: Re-open clarifications file from disk.
78
+ - **If** user provides path → use it.
79
+ - **Else** → open most recent `{OUT_DIR}/clarifications/plan_clarifications_*.md`.
80
+ - Read entire file; use responses when provided; proceed with assumptions if empty.
81
+
82
+ ## Step (3/4) - Create Implementation Plan
83
+
84
+ - **Action** — DetermineDepth: Read `--depth` from ARGUMENTS
85
+
86
+ - Default: `standard` if not specified
87
+ - Options: `standard`, `comprehensive`
88
+
89
+ - **Action** — DesignTechnicalApproach: Create the implementation plan.
90
+
91
+ **STANDARD** depth — Focused plan for contained changes. Include the sections that matter for THIS feature. Typical sections: Overview, Desired End State, Out of Scope, Technical Approach.
92
+
93
+ **COMPREHENSIVE** depth — Full technical design for complex/risky changes. Consider all of the following, but only include sections relevant to the feature: Overview, Current State (with file:line refs), Desired End State, Out of Scope, Technical Approach, System Architecture, Implementation Phases, Component/Data Architecture, API Design, Testing Strategy.
94
+
95
+ Use your judgment — the goal is a plan that gives a developer everything they need to implement, not a template with empty sections.
96
+
97
+ - **Action** — AppendCriticalFiles: End the plan with a "Critical Files for Implementation" section.
98
+
99
+ - List 3-7 files most critical for implementing this plan.
100
+ - Format: `path/to/file.ts` — brief reason (e.g., "Core logic to modify", "Pattern to follow", "Interface to implement").
101
+ - These should be specific files discovered during research, not guesses.
102
+
103
+ - **Action** — DocumentPlan: Save to `{OUT_DIR}/specs/plan.md` (use scoped name if exists)
104
+
105
+ - **Action** — RequestReview:
106
+
107
+ > "Implementation plan saved to `{path}`. Review and reply with feedback or 'Approved' to proceed."
108
+
109
+ - **Wait** — User provides feedback or approval
110
+
111
+ ## Step (4/4) - Finalize and Present Next Steps
112
+
113
+ - **Action** — ConfirmCompletion:
114
+
115
+ > "🎯 Implementation Planning Complete. Documents: {plan_path}, task_context.md"
116
+
117
+ - **Action** — RenderFooter: Use `@skill-spectre:spectre-guide` skill for Next Steps footer