@codename_inc/spectre 3.7.0 → 5.0.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 (106) hide show
  1. package/README.md +6 -7
  2. package/package.json +3 -2
  3. package/plugins/spectre/.claude-plugin/plugin.json +1 -1
  4. package/plugins/spectre/bin/spectre-register +5 -0
  5. package/plugins/spectre/hooks/hooks.json +3 -14
  6. package/plugins/spectre/hooks/scripts/bootstrap.mjs +98 -0
  7. package/plugins/spectre/hooks/scripts/handoff-resume.mjs +404 -0
  8. package/plugins/spectre/hooks/scripts/lib.mjs +82 -0
  9. package/plugins/spectre/hooks/scripts/load-knowledge.mjs +189 -0
  10. package/plugins/spectre/hooks/scripts/register_learning.mjs +264 -0
  11. package/plugins/spectre/hooks/scripts/{test_bootstrap.cjs → test_bootstrap.mjs} +12 -7
  12. package/plugins/spectre/hooks/scripts/{test_handoff-resume.cjs → test_handoff-resume.mjs} +13 -11
  13. package/plugins/spectre/hooks/scripts/{test_load-knowledge.cjs → test_load-knowledge.mjs} +103 -22
  14. package/plugins/spectre/hooks/scripts/test_register-learning.mjs +335 -0
  15. package/plugins/spectre/skills/apply/SKILL.md +87 -0
  16. package/plugins/spectre/{commands/architecture_review.md → skills/architecture_review/SKILL.md} +9 -0
  17. package/plugins/spectre/{commands/clean.md → skills/clean/SKILL.md} +9 -0
  18. package/plugins/spectre/{commands/code_review.md → skills/code_review/SKILL.md} +9 -0
  19. package/plugins/spectre/{commands/create_plan.md → skills/create_plan/SKILL.md} +9 -0
  20. package/plugins/spectre/{commands/create_tasks.md → skills/create_tasks/SKILL.md} +9 -0
  21. package/plugins/spectre/{commands/create_test_guide.md → skills/create_test_guide/SKILL.md} +9 -0
  22. package/plugins/spectre/{commands/evaluate.md → skills/evaluate/SKILL.md} +11 -2
  23. package/plugins/spectre/{commands/execute.md → skills/execute/SKILL.md} +12 -3
  24. package/plugins/spectre/{commands/fix.md → skills/fix/SKILL.md} +9 -0
  25. package/plugins/spectre/{commands/forget.md → skills/forget/SKILL.md} +9 -0
  26. package/plugins/spectre/skills/{spectre-guide → guide}/SKILL.md +6 -5
  27. package/plugins/spectre/{commands/handoff.md → skills/handoff/SKILL.md} +9 -0
  28. package/plugins/spectre/{commands/kickoff.md → skills/kickoff/SKILL.md} +9 -0
  29. package/plugins/spectre/skills/{spectre-learn → learn}/SKILL.md +19 -59
  30. package/plugins/spectre/skills/learn/references/recall-template.md +34 -0
  31. package/plugins/spectre/{commands/plan.md → skills/plan/SKILL.md} +66 -25
  32. package/plugins/spectre/{commands/plan_review.md → skills/plan_review/SKILL.md} +9 -0
  33. package/plugins/spectre/skills/prototype/SKILL.md +314 -0
  34. package/plugins/spectre/{commands/quick_dev.md → skills/quick_dev/SKILL.md} +9 -0
  35. package/plugins/spectre/{commands/rebase.md → skills/rebase/SKILL.md} +9 -0
  36. package/plugins/spectre/skills/recall/SKILL.md +17 -0
  37. package/plugins/spectre/{commands/research.md → skills/research/SKILL.md} +9 -0
  38. package/plugins/spectre/skills/scope/SKILL.md +174 -0
  39. package/plugins/spectre/{commands/ship.md → skills/ship/SKILL.md} +9 -0
  40. package/plugins/spectre/{commands/sweep.md → skills/sweep/SKILL.md} +9 -0
  41. package/plugins/spectre/skills/tdd/SKILL.md +111 -0
  42. package/plugins/spectre/{commands/test.md → skills/test/SKILL.md} +9 -0
  43. package/plugins/spectre/skills/ux/SKILL.md +121 -0
  44. package/plugins/spectre/{commands/validate.md → skills/validate/SKILL.md} +9 -0
  45. package/plugins/spectre-codex/agents/analyst.toml +117 -0
  46. package/plugins/spectre-codex/agents/dev.toml +65 -0
  47. package/plugins/spectre-codex/agents/finder.toml +101 -0
  48. package/plugins/spectre-codex/agents/patterns.toml +203 -0
  49. package/plugins/spectre-codex/agents/reviewer.toml +123 -0
  50. package/plugins/spectre-codex/agents/sync.toml +146 -0
  51. package/plugins/spectre-codex/agents/tester.toml +205 -0
  52. package/plugins/spectre-codex/agents/web-research.toml +104 -0
  53. package/plugins/spectre-codex/hooks/hooks.json +23 -0
  54. package/plugins/{spectre/hooks/scripts/bootstrap.cjs → spectre-codex/hooks/scripts/bootstrap.mjs} +15 -16
  55. package/plugins/{spectre/hooks/scripts/handoff-resume.cjs → spectre-codex/hooks/scripts/handoff-resume.mjs} +21 -27
  56. package/plugins/{spectre/hooks/scripts/lib.cjs → spectre-codex/hooks/scripts/lib.mjs} +3 -4
  57. package/plugins/spectre-codex/hooks/scripts/load-knowledge.mjs +189 -0
  58. package/plugins/spectre-codex/hooks/scripts/register_learning.mjs +264 -0
  59. package/plugins/spectre-codex/skills/apply/SKILL.md +87 -0
  60. package/plugins/spectre-codex/skills/architecture_review/SKILL.md +129 -0
  61. package/plugins/spectre-codex/skills/clean/SKILL.md +322 -0
  62. package/plugins/spectre-codex/skills/code_review/SKILL.md +417 -0
  63. package/plugins/spectre-codex/skills/create_plan/SKILL.md +126 -0
  64. package/plugins/spectre-codex/skills/create_tasks/SKILL.md +383 -0
  65. package/plugins/spectre-codex/skills/create_test_guide/SKILL.md +129 -0
  66. package/plugins/spectre-codex/skills/evaluate/SKILL.md +59 -0
  67. package/plugins/spectre-codex/skills/execute/SKILL.md +96 -0
  68. package/plugins/spectre-codex/skills/fix/SKILL.md +70 -0
  69. package/plugins/spectre-codex/skills/forget/SKILL.md +67 -0
  70. package/plugins/spectre-codex/skills/guide/SKILL.md +359 -0
  71. package/plugins/spectre-codex/skills/handoff/SKILL.md +170 -0
  72. package/plugins/spectre-codex/skills/kickoff/SKILL.md +124 -0
  73. package/plugins/spectre-codex/skills/learn/SKILL.md +595 -0
  74. package/plugins/{spectre/skills/spectre-learn → spectre-codex/skills/learn}/references/recall-template.md +4 -1
  75. package/plugins/spectre-codex/skills/plan/SKILL.md +211 -0
  76. package/plugins/spectre-codex/skills/plan_review/SKILL.md +42 -0
  77. package/plugins/spectre-codex/skills/prototype/SKILL.md +314 -0
  78. package/plugins/spectre-codex/skills/quick_dev/SKILL.md +110 -0
  79. package/plugins/spectre-codex/skills/rebase/SKILL.md +82 -0
  80. package/plugins/spectre-codex/skills/recall/SKILL.md +17 -0
  81. package/plugins/spectre-codex/skills/research/SKILL.md +168 -0
  82. package/plugins/spectre-codex/skills/scope/SKILL.md +174 -0
  83. package/plugins/spectre-codex/skills/ship/SKILL.md +181 -0
  84. package/plugins/spectre-codex/skills/sweep/SKILL.md +91 -0
  85. package/plugins/{spectre/skills/spectre-tdd → spectre-codex/skills/tdd}/SKILL.md +1 -1
  86. package/plugins/spectre-codex/skills/test/SKILL.md +389 -0
  87. package/plugins/spectre-codex/skills/ux/SKILL.md +121 -0
  88. package/plugins/spectre-codex/skills/validate/SKILL.md +352 -0
  89. package/src/config.test.js +6 -5
  90. package/src/install.test.js +100 -11
  91. package/src/lib/config.js +107 -54
  92. package/src/lib/constants.js +17 -23
  93. package/src/lib/doctor.js +19 -22
  94. package/src/lib/install.js +98 -313
  95. package/src/lib/knowledge.js +7 -37
  96. package/src/lib/paths.js +0 -12
  97. package/src/pack.test.js +87 -0
  98. package/plugins/spectre/commands/learn.md +0 -15
  99. package/plugins/spectre/commands/recall.md +0 -5
  100. package/plugins/spectre/commands/scope.md +0 -119
  101. package/plugins/spectre/commands/ux_spec.md +0 -91
  102. package/plugins/spectre/hooks/scripts/load-knowledge.cjs +0 -120
  103. package/plugins/spectre/hooks/scripts/precompact-warning.cjs +0 -19
  104. package/plugins/spectre/hooks/scripts/register_learning.cjs +0 -144
  105. package/plugins/spectre/hooks/scripts/test_register-learning.cjs +0 -146
  106. package/plugins/spectre/skills/spectre-apply/SKILL.md +0 -189
@@ -0,0 +1,211 @@
1
+ ---
2
+ name: "plan"
3
+ description: "👻 | Unified planning entry point - researches, assesses complexity, routes to workflow - primary agent"
4
+ user-invocable: true
5
+ ---
6
+
7
+ # plan
8
+
9
+ ## Input Handling
10
+
11
+ Treat the current command arguments as this workflow's input. When invoked from a slash command, use the forwarded `$ARGUMENTS` value.
12
+
13
+ # plan: Intelligent Planning Router
14
+
15
+ ## Description
16
+
17
+ - **What** — Research codebase, assess complexity, route to appropriate workflow (direct tasks or plan-first)
18
+ - **Outcome** — Detailed task breakdown ready for execution
19
+
20
+ ## ARGUMENTS Input
21
+
22
+ <ARGUMENTS> $ARGUMENTS </ARGUMENTS>
23
+
24
+ ## MANDATORY COMPLIANCE RULES
25
+
26
+ > **⚠️ NON-NEGOTIABLE**: This workflow MUST invoke nested workflows via the Skill tool. Failure to invoke `Skill(create_plan)` and `Skill(create_tasks)` (Claude slash route: `create_plan` and `create_tasks`) is a critical error. Do NOT summarize, describe, or skip these workflows. INVOKE THEM.
27
+
28
+ **After ANY user conversation or questions:**
29
+
30
+ 1. Re-read this prompt from Step 4
31
+ 2. Determine where you are in the workflow
32
+ 3. Execute the next required Skill invocation
33
+
34
+ **You MUST call these skills (not describe them):**
35
+
36
+ - Use the **Skill** tool with `skill: "spectre-create_plan"` and `args: "{path} --depth {tier}"` — generates plan.md
37
+ - Use the **Skill** tool with `skill: "spectre-create_tasks"` and `args: "{path}"` — generates tasks.md
38
+
39
+ ## Instructions
40
+
41
+ - Research before routing; present architectural options for user buy-in
42
+ - Route based on hard-stops and clarity, not point-scoring
43
+ - Never overwrite existing `tasks.md` or `plan.md` — use scoped names
44
+
45
+ ## Step 1 - Research Codebase
46
+
47
+ - **Action** — DetermineOutputDir:
48
+
49
+ - `OUT_DIR=docs/tasks/{branch_name}` (or user-specified)
50
+ - `mkdir -p "${OUT_DIR}"`
51
+
52
+ - **Action** — ScanExistingContext: Read all existing artifacts in `{OUT_DIR}/ (if you haven’t already)` and assess coverage across 4 dimensions.
53
+
54
+ Scan for: `task_context.md`, `specs/plan.md`, `concepts/scope.md`, `research/*.md`
55
+
56
+ | Dimension | Covered if artifact contains... | Covered by |
57
+ | --- | --- | --- |
58
+ | **File locations** | Specific file paths relevant to this feature, entry points, config files | `@finder` |
59
+ | **Code understanding** | Data flow analysis, dependency tracing, how current code works with file:line refs | `@analyst` |
60
+ | **Codebase patterns** | Similar implementations found in codebase, reusable components, naming/style conventions | `@patterns` |
61
+ | **External research** | Best practices, libraries/frameworks, prior art, common pitfalls with source links | `@web-research` |
62
+
63
+ For each dimension, assess: **covered** (artifact has substantive findings for this feature) or **gap** (missing, superficial, or about a different feature).
64
+
65
+ - **Action** — DispatchResearch: Spawn agents **only for dimensions marked as gaps**. Skip agents whose dimensions are already covered. Each prompt must include the feature/problem description from ARGUMENTS so the agent has full context.
66
+
67
+ - **If all 4 covered** → skip to SaveResearch (merge existing findings into task_context.md if scattered across files)
68
+
69
+ - **If gaps exist** → spawn only the needed agents in parallel:
70
+
71
+ - `@finder` *(if File locations = gap)* — "Find all files, components, entry points, routes, and configuration related to \[feature/problem\]. Include: (1) files that would need to be modified or extended, (2) entry points where this feature connects to the system (routes, handlers, event listeners, CLI commands), (3) configuration files, schemas, or migrations that may be affected, (4) test files covering the affected areas. Return file paths organized by relevance."
72
+
73
+ - `@analyst` *(if Code understanding = gap)* — "Analyze how the code paths related to \[feature/problem\] work end-to-end. Trace: (1) data flow from input through processing to storage and output, (2) key dependencies and how components interact, (3) state management patterns and data access methods in the affected areas, (4) error handling and edge cases in the current implementation. Return findings with specific file:line references."
74
+
75
+ - `@patterns` *(if Codebase patterns = gap)* — "Find existing implementations in this codebase that are similar to \[feature/problem\] and could serve as a reference. Look for: (1) analogous features already built — how were they structured?, (2) reusable components, utilities, or abstractions we should leverage, (3) conventions for naming, file organization, and code style in this area, (4) testing patterns used for similar features. Return concrete code examples with file:line references."
76
+
77
+ - `@web-research` *(if External research = gap)* — "Research best practices, proven patterns, relevant libraries/frameworks, and how other projects solve \[feature/problem\]. Focus on: (1) industry best practices and common pitfalls, (2) libraries or frameworks that simplify this work, (3) how well-known open-source projects approach similar problems, (4) architectural patterns recommended for this type of feature. Return findings with source links."
78
+
79
+ - **Wait** for all dispatched agents; read identified files
80
+
81
+ - **Action** — SaveResearch: Merge all findings (existing artifacts + new agent results) into `{OUT_DIR}/task_context.md` with sections: Architecture Patterns, Dependencies, Implementation Approaches, Impact Summary, and External Research (best practices, recommended libraries/frameworks, prior art, common pitfalls)
82
+
83
+ ## Step 2 - Assess Complexity
84
+
85
+ Use research findings from Step 1 to determine appropriate planning depth.
86
+
87
+ - **Action** — AssessFromResearch: Score complexity signals from research:
88
+
89
+ | Signal | Source | Assessment |
90
+ | --- | --- | --- |
91
+ | Files impacted | @finder | 1-3 files = Low, 4-8 = Med, 9+ = High |
92
+ | Pattern match | @patterns | Clear existing pattern = Low, Adapt pattern = Med, New pattern = High |
93
+ | Components crossed | @analyst | 1 component = Low, 2-3 = Med, 4+ = High |
94
+ | Data model changes | Research findings | None = Low, Modify existing = Med, New models/schema = High |
95
+ | Integration points | Research findings | Internal only = Low, 1-2 external = Med, 3+ external = High |
96
+ | External complexity | @web-research | Well-documented with libraries = Low, Some prior art = Med, Novel/emerging = High |
97
+
98
+ - **Action** — CheckHardStops: Any true = automatic COMPREHENSIVE | db_schema_destructive | new_service_or_component | auth_or_pii_change | | payment_billing_logic | public_api_change | caching_consistency | slo_sla_risk |
99
+
100
+ - **Action** — DetermineTier:
101
+
102
+ - **LIGHT**: All/most Low signals, single component, clear pattern match, no hard-stops
103
+ - **STANDARD**: Mix of Low/Med signals, multi-file but contained scope, no hard-stops
104
+ - **COMPREHENSIVE**: Any High signal, multiple Med signals, or any hard-stop triggered
105
+
106
+ - **Action** — LogTier: Note the assessed tier in your response for transparency, then proceed immediately to the next step. Do NOT ask for confirmation.
107
+
108
+ > **CHECKPOINT**: After determining tier, proceed IMMEDIATELY to the next step — Step 3 (High-Level Design) for STANDARD/COMPREHENSIVE, or Step 4 (Route) for LIGHT. Do NOT end turn here. Do NOT ask user to confirm the tier.
109
+
110
+ ## Step 3 - High-Level Design
111
+
112
+ **SKIP IF LIGHT** — proceed directly to Step 4.
113
+
114
+ Goal: align on the *shape* of the solution before generating a full plan. This catches misalignments early and gives the user a chance to redirect before reading a long plan doc.
115
+
116
+ - **Action** — PresentDesign: Synthesize research from Step 1 into a single proposed approach with open questions. Present inline (do not write a separate design file).
117
+
118
+ **Format**:
119
+
120
+ > Here's the high-level design I'd take. Scan the shape, then resolve any open questions or push back on the approach.
121
+ >
122
+ > **Approach**: [1-2 paragraph summary of the solution shape — what changes structurally, not file-by-file]
123
+ >
124
+ > **Key components touched**:
125
+ > - `path/file.ts` — [what shifts and why]
126
+ > - `path/other.ts` — [what shifts and why]
127
+ >
128
+ > **Key decisions**:
129
+ > - [decision] — [rationale; alternative considered]
130
+ > - [decision] — [rationale; alternative considered]
131
+ >
132
+ > **Open questions** (with default assumption):
133
+ > 1. [question] — *default: [assumption]*
134
+ > 2. [question] — *default: [assumption]*
135
+ >
136
+ > Reply with answers, edits to the approach, or 'looks good' to continue.
137
+
138
+ **CRITICAL**:
139
+ - **Single proposed approach**, not a menu. If a true fork exists, surface it as an open question with your recommendation — not as parallel options.
140
+ - Stay at the *shape* level: components, key decisions, structural changes. Defer file-by-file detail to `create_plan`.
141
+ - Open questions should be specific and answerable; pair each with a default assumption so the user can skip if the default is fine.
142
+
143
+ - **Action** — IterateDesign: If the user replies with answers, edits, or pushback, update the design and re-present. Loop until user says 'looks good' (or equivalent).
144
+
145
+ - **Wait** — User signals alignment.
146
+
147
+ - **Action** — PersistDesign: Append a "Selected Design" section to `{OUT_DIR}/task_context.md` capturing the agreed approach, key decisions, and resolved questions. This is what `create_plan` consumes.
148
+
149
+ > **CHECKPOINT**: After alignment, proceed IMMEDIATELY to Step 4. The ONLY valid next action is invoking a Skill.
150
+
151
+ ## Step 4 - Route to Workflow
152
+
153
+ ### ⛔ MANDATORY SKILL INVOCATION ⛔
154
+
155
+ ```plaintext
156
+ ┌────────────────────────────────────────────────────────────────────────┐
157
+ │ YOU MUST USE THE SKILL TOOL TO INVOKE THESE COMMANDS │
158
+ │ │
159
+ │ ❌ WRONG: "I'll now create the plan..." │
160
+ │ ❌ WRONG: "The next step would be to run create_plan" │
161
+ │ ❌ WRONG: Ending turn without invoking Skill tool │
162
+ │ │
163
+ │ ✅ CORRECT: Skill tool with skill: "spectre-create_plan", args: "..." │
164
+ │ ✅ CORRECT: Skill tool with skill: "spectre-create_tasks", args: "..."│
165
+ └────────────────────────────────────────────────────────────────────────┘
166
+ ```
167
+
168
+ **DO NOT:**
169
+
170
+ - Say you’ll create a plan or set of tasks yourself without running the skill tool
171
+ - Describe what you would do
172
+ - Summarize the plan/task steps yourself
173
+ - End your turn without invoking Skill
174
+ - Write plan.md or tasks.md content directly
175
+
176
+ **YOU MUST:**
177
+
178
+ - Use the Skill tool: `skill: "spectre-create_plan"`, `args: "{OUT_DIR}/task_context.md --depth {tier}"`
179
+ - Use the Skill tool: `skill: "spectre-create_tasks"`, `args: "{OUT_DIR}/task_context.md"`
180
+
181
+ ---
182
+
183
+ ### Routing Logic
184
+
185
+ - **If LIGHT**:
186
+
187
+ - **INVOKE NOW** → Skill tool with `skill: "spectre-create_tasks"`, `args: "{OUT_DIR}/task_context.md --depth light"`
188
+ - **Wait** — Returns task breakdown with brief implementation approach
189
+ - Skip to footer
190
+
191
+ - **ElseIf STANDARD**:
192
+
193
+ - **INVOKE NOW** → Skill tool with `skill: "spectre-create_plan"`, `args: "{OUT_DIR}/task_context.md --depth standard"`
194
+ - **Wait** — Returns focused plan (Overview, Approach, Out of Scope)
195
+ - **Action** — PromptUser: "Review plan. Reply 'Approved' or provide feedback."
196
+ - **Wait** — User approval
197
+ - **INVOKE NOW** → Skill tool with `skill: "spectre-create_tasks"`, `args: "{OUT_DIR}/task_context.md"`
198
+ - **Wait** — Returns task breakdown
199
+
200
+ - **ElseIf COMPREHENSIVE**:
201
+
202
+ - **INVOKE NOW** → Skill tool with `skill: "spectre-create_plan"`, `args: "{OUT_DIR}/task_context.md --depth comprehensive"`
203
+ - **Wait** — Returns full plan (all sections: Architecture, Phases, API Design, Testing Strategy, etc.)
204
+ - **Action** — PromptUser: "Review plan. Reply 'Approved' or provide feedback."
205
+ - **Wait** — User approval
206
+ - **INVOKE NOW** → Skill tool with `skill: "spectre-create_tasks"`, `args: "{OUT_DIR}/task_context.md"`
207
+ - **Wait** — Returns task breakdown
208
+
209
+ ---
210
+
211
+ - **Action** — RenderFooter: Use `Skill(spectre-guide)` skill for Next Steps
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: "plan_review"
3
+ description: "👻 | Find simplifications in a plan or tasks"
4
+ user-invocable: true
5
+ ---
6
+
7
+ # plan_review
8
+
9
+ ## Input Handling
10
+
11
+ Treat the current command arguments as this workflow's input. When invoked from a slash command, use the forwarded `$ARGUMENTS` value.
12
+
13
+
14
+ You are a senior staff engineer with deep expertise in system design, architecture, and pragmatic problem-solving. Your specialty is finding the simplest path to meet all requirements.
15
+
16
+ Review the following [plan/document/tasks/context] and identify opportunities to simplify while ensuring all requirements and functionality are delivered.
17
+
18
+ For each simplification opportunity, provide:
19
+ 1. **What to simplify** - Specific component, process, or decision
20
+ 2. **Why** - What complexity it removes (cognitive load, dependencies, maintenance burden, etc.)
21
+ 3. **Impact** - Confirm that all original requirements remain satisfied
22
+ 4. **Risk** - Any trade-offs or risks introduced by the simplification
23
+
24
+ Focus on:
25
+ - Removing unnecessary abstractions or indirection
26
+ - Consolidating duplicated logic or patterns
27
+ - Questioning assumptions that add complexity
28
+ - Identifying over-engineering
29
+ - Suggesting proven, boring solutions over novel approaches
30
+
31
+ ## Testing Review
32
+ **Context**: We use fast TDD with 1 happy path test + 1 unhappy path test per feature. A separate task handles achieving 100% test coverage post-feature work.
33
+
34
+ Evaluate the testing approach and flag:
35
+ - **Over-testing**: Tests beyond 1 happy + 1 unhappy path that should be deferred to the coverage task
36
+ - **Wrong tests**: Testing implementation details instead of behavior, brittle tests that will break on refactors, or tests that don't actually validate requirements
37
+ - **Missing critical paths**: Cases where the 1+1 approach genuinely misses a requirement-breaking scenario (rare, but call it out)
38
+ - **Test complexity**: Overly elaborate test setup, mocking, or assertions that could be simpler
39
+
40
+ Remember: The goal is fast feedback during development. More comprehensive testing comes later.
41
+
42
+ End with a prioritized list of recommendations (high/medium/low impact).
@@ -0,0 +1,314 @@
1
+ ---
2
+ name: "prototype"
3
+ description: "👻 | Generate a self-contained HTML prototype to validate a feature visually before planning - primary agent"
4
+ user-invocable: true
5
+ ---
6
+
7
+ # prototype
8
+
9
+ ## Input Handling
10
+
11
+ Treat the current command arguments as this workflow's input. When invoked from a slash command, use the forwarded `$ARGUMENTS` value.
12
+
13
+ # prototype: Make the Feature Visible Before You Plan It
14
+
15
+ Produce a self-contained, clickable HTML artifact that makes a feature visible — resolving ambiguity before scope, validating flows before plan, or anchoring stakeholder review. Output: single portable HTML file the user can open locally or host anywhere, saved to `{OUT_DIR}/prototypes/{name}_{MMDDYY}.html`.
16
+
17
+ ## ARGUMENTS
18
+
19
+ <ARGUMENTS> $ARGUMENTS </ARGUMENTS>
20
+
21
+ ## Invocation Modes
22
+
23
+ Detect mode from environment markers, ARGUMENTS, and existing docs. **Order matters** — check from most context to least:
24
+
25
+ - **Complete ux.md exists** (post-ux) — full Stage 2 spec is on disk. The prototype's job is to **render the spec**, not synthesize it. Default fidelity: **high-fi**. Skip all intake except visual anchor. Treat ux.md as authoritative — don't invent screens, don't contradict documented states or copy. On completion, recommend `plan` or `create_tasks`.
26
+ - **`FROM_UX=true`** — invoked mid-flow from `ux` Stage 1 → Stage 2 gate. Only approved flows exist (no detailed spec yet). Skip flow-discovery intake. Default fidelity: **mid-fi**. On completion, point user back to `ux` Stage 2.
27
+ - **`--explore` flag in ARGUMENTS** — pre-scope discovery. Concept is unvalidated. Default fidelity: **low-fi**. On completion, recommend `scope` as next step.
28
+ - **scope.md exists for this branch** (no ux.md) — post-scope validation. Default fidelity: **mid-fi**. On completion, recommend `ux` or `plan` based on feature complexity.
29
+ - **Standalone, no context** — ask the user what they're prototyping. Default fidelity: **mid-fi**.
30
+
31
+ ---
32
+
33
+ # STAGE 1: Intake & Fidelity Alignment
34
+
35
+ **Goal**: Confirm what we're prototyping, at what fidelity, and what visual anchor to use. Keep this tight — 2 to 4 questions, never a form.
36
+
37
+ ## Step 1 — Immediate Reply & Detect Context
38
+
39
+ - **Action** — ImmediateReply: Respond before any tools.
40
+ - **If** `FROM_UX=true` → acknowledge ux context, read approved flows from `{OUT_DIR}/ux.md`, **SKIP to Step 3**
41
+ - **Else If** ARGUMENTS empty → probe: "What are we prototyping? A quick description is enough — I'll figure out the fidelity from context."
42
+ - **Else** → proceed to Step 2
43
+ - **CRITICAL**: No tool calls in this step except reading ux output when `FROM_UX=true`.
44
+
45
+ ## Step 2 — Read Available Context & Classify ux.md
46
+
47
+ - **Action** — DetectExistingDocs: Check for relevant inputs before asking the user anything.
48
+ - `branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)`
49
+ - Look for: `docs/tasks/{branch_name}/concepts/scope.md`, `docs/tasks/{branch_name}/specs/prd.md`, `docs/tasks/{branch_name}/ux.md`
50
+ - Read whichever exist FULLY (no offset/limit)
51
+
52
+ - **Action** — ClassifyUxDoc: If `ux.md` exists, classify its completeness — this drives fidelity AND how much intake to skip.
53
+ - **Complete** — contains all of: Screens, Layouts, Components, Interactions, States, Content sections (the Stage 2 deliverables from `ux`). Treat as authoritative. Skip flow-discovery questions. Set mode = **post-ux**.
54
+ - **Flows-only** — contains user flows / journeys but missing Stage 2 sections. Treat flows as approved input but expect to make UI decisions. Set mode = **flows-only ux**.
55
+ - **Absent** — fall back to scope.md / prd.md / standalone modes.
56
+
57
+ ## Step 3 — Recommend Fidelity, Confirm Anchor
58
+
59
+ Pick fidelity from signals available:
60
+
61
+ | Signal present | Recommends |
62
+ |---|---|
63
+ | `--explore` flag, or no scope/prd | **Low-fi** — grayscale, layout-only, no typography polish |
64
+ | scope.md exists, no design system anchor | **Mid-fi** — real colors, basic type, simplified components (default) |
65
+ | scope.md + flows-only ux.md, or brand/design system anchor | **Mid-fi to High-fi** — depends on anchor strength |
66
+ | **Complete ux.md** (post-ux) | **High-fi** — full design tokens, realistic data, micro-interactions; render the spec faithfully |
67
+
68
+ ### Intake by mode
69
+
70
+ **Post-ux mode** (complete ux.md) — present a tight confirmation, ask one question:
71
+
72
+ > **Prototype plan** — rendering complete UX spec
73
+ >
74
+ > Source: `{path to ux.md}` ({N} screens, {M} components, {K} states specified)
75
+ > Fidelity: **high-fi** (default — full spec is on disk; I'll render it faithfully, not invent)
76
+ >
77
+ > One thing I need: **visual anchor** — brand colors, font stack, an existing app/URL to match, or a named aesthetic (e.g. "Linear-style", "Notion-quiet", "Stripe-clean"). If the spec already specifies design tokens, reply "use the spec." If you skip this, I'll commit to a deliberate named aesthetic and call it out at the top of the file.
78
+
79
+ **All other modes** — present recommendation + request anchor + confirm framing:
80
+
81
+ > **Prototype plan**
82
+ >
83
+ > I'm reading this as: **{inferred feature/flow}**
84
+ > Recommended fidelity: **{low-fi | mid-fi | high-fi}** — {one-line reason}
85
+ > Primary flow: **{name}** (from {scope.md | ux.md flows | your description})
86
+ >
87
+ > Two things I need from you:
88
+ > 1. **Override fidelity?** Or "looks good."
89
+ > 2. **Visual anchor** — brand colors, font stack, an existing app/URL to match, or a named aesthetic (e.g. "Linear-style", "Notion-quiet", "Stripe-clean"). If you skip this, I'll commit to a deliberate named aesthetic and call it out at the top of the file so you can redirect.
90
+
91
+ **Wait for response.** If user pushes back on fidelity or feature framing, adjust and re-confirm.
92
+
93
+ ---
94
+
95
+ # STAGE 2: Parallel Research & Generation
96
+
97
+ **Gate**: Only proceed after Stage 1 confirmation (or `FROM_UX=true`).
98
+
99
+ ## Step 4 — Dispatch Parallel Subagents
100
+
101
+ Spawn three subagents in parallel. Each has a focused job.
102
+
103
+ ### `@web-research` — Visual Reference Discovery
104
+
105
+ Prompt template:
106
+
107
+ > Research visual design patterns and UI conventions for **{feature type}**. Specifically:
108
+ >
109
+ > 1. Find 2–3 living examples or screenshots of similar UI patterns in well-regarded products. Return URLs and visual descriptions.
110
+ > 2. Identify the established UX convention for this interaction type (wizard, dashboard, list+detail, modal flow, etc.) and any recent (2025–2026) refinements.
111
+ > 3. If the user specified an aesthetic anchor ({anchor_text}), find representative color palettes (hex), typography choices (font families with fallbacks), and one or two distinctive design moves that define the aesthetic.
112
+ > 4. Return concrete decisions — colors, fonts, layout patterns — not general advice.
113
+ >
114
+ > Length: under 400 words. Cite sources.
115
+
116
+ **Why**: Grounds generation in specific references. Without this step the model defaults to its own distribution (Inter + purple gradients). This is the anti-slop forcing function.
117
+
118
+ ### `@analyst` — Flow & Content Extraction
119
+
120
+ Use one of two prompt templates based on mode detected in Step 2.
121
+
122
+ **Extraction mode** — post-ux (complete ux.md present):
123
+
124
+ > Read **{path to ux.md}** fully. The Stage 2 spec is authoritative — your job is to **extract** structured data for HTML rendering, NOT to synthesize new screens, states, or content.
125
+ >
126
+ > Return a render brief organized by ux.md section:
127
+ >
128
+ > 1. **Screens** — verbatim from the Screens section: name, purpose, navigation relationships
129
+ > 2. **Layouts** — verbatim from Layouts: per-screen header/main/footer + responsive breakpoints
130
+ > 3. **Components** — verbatim from Components: each element's purpose, location, all documented states (default, hover, active, disabled, loading, error)
131
+ > 4. **Interactions** — verbatim from the Interactions table: Element | Action | Result
132
+ > 5. **States** — verbatim from the States table: State | Trigger | Appearance | Available Actions
133
+ > 6. **Content** — verbatim copy from the Content section: page titles, button labels, empty-state messages, error messages, confirmation dialogs. Use this copy EXACTLY in the prototype — do not paraphrase.
134
+ > 7. **Edge cases & a11y** — note any documented constraints (limits, null/long data, keyboard actions, focus management) the prototype should reflect
135
+ >
136
+ > If the spec specifies a state or content value, the prototype must match it. If the spec is silent on a detail, flag it as a "filled assumption" so it appears in the prototype's metadata header. Never invent screens that aren't in the spec.
137
+
138
+ **Synthesis mode** — flows-only ux, scope-only, or standalone:
139
+
140
+ > Read these documents fully: **{list of paths — scope.md, prd.md, ux.md flows section if present}**. Extract a content skeleton for an HTML prototype:
141
+ >
142
+ > 1. **Primary flow** — entry → action → outcome, with decision points
143
+ > 2. **Required UI states per screen** — every screen needs at minimum: happy path, empty state, error or edge state. Some screens also need: loading, success
144
+ > 3. **Stated constraints** — any layout, behavior, or content constraints from the docs
145
+ > 4. **Realistic content** — actual product names, plausible numbers, real-looking copy. NO Lorem ipsum. NO "Card Title." If domain-specific data is unclear, invent plausible values that match the feature's domain.
146
+ > 5. **Component inventory** — every recurring UI element that will need a named CSS class (button, card, input, badge, etc.)
147
+ >
148
+ > Return a structured flow brief: screen list, per-screen state list, realistic content for each, component inventory.
149
+
150
+ **Why**: This is the content skeleton. In post-ux mode, the spec already did this work — re-synthesizing risks contradicting documented decisions. In all other modes, skipping synthesis produces prototypes with Lorem ipsum and inconsistent component styling.
151
+
152
+ ### `@patterns` — Existing Codebase Anchor (only if applicable)
153
+
154
+ Skip this agent if there is no existing app to anchor to. Otherwise:
155
+
156
+ > Find existing UI patterns in this codebase that the prototype should match or extend: design tokens (colors, spacing, type), component conventions (button styles, card layouts), and any established interaction patterns. Return file references with the actual values (hex codes, class names, etc.) — not just paths.
157
+
158
+ **Why**: When prototyping inside an existing app, the prototype should look like a plausible new screen of that app, not a designer's blank canvas.
159
+
160
+ ## Step 5 — Generate the HTML Artifact
161
+
162
+ Wait for ALL subagents to complete. Synthesize their outputs, then generate a single self-contained HTML file. Use `@dev` to produce the file (or inline if the synthesis is straightforward).
163
+
164
+ ### Hard constraints on the generated HTML
165
+
166
+ **File structure** (every prototype includes these in order):
167
+
168
+ 1. **`<!DOCTYPE html>` + minimal `<head>`** with `<meta viewport>` and an inline `<style>` block
169
+ 2. **Metadata comment block** at the very top of `<head>`:
170
+ ```html
171
+ <!--
172
+ SPECTRE PROTOTYPE
173
+ Feature: {feature name}
174
+ Fidelity: {low-fi | mid-fi | high-fi}
175
+ Generated: {YYYY-MM-DD}
176
+ Branch: {branch_name}
177
+ Flow covered: {primary flow}
178
+ Screens/states: {comma-separated list}
179
+ Visual anchor: {named aesthetic or reference URL}
180
+ Source spec: {path to ux.md if post-ux mode, else "none — synthesized from {scope.md | description}"}
181
+ Key assumptions: {bullet list of design decisions and content assumptions}
182
+ Filled assumptions: {only in post-ux mode — items the spec was silent on that the prototype filled in; review these against the spec}
183
+ NOT included: {explicit list of what was deliberately left out}
184
+ Next step: plan OR resume ux Stage 2
185
+ -->
186
+ ```
187
+ 3. **Design tokens comment block** in `<head>`:
188
+ ```html
189
+ <!-- DESIGN TOKENS
190
+ Primary: #{hex}
191
+ Accent: #{hex}
192
+ Surface: #{hex}
193
+ Text: #{hex}
194
+ Font: {family}, served from {CDN or system}
195
+ Border-radius: {value}
196
+ Spacing unit: {value}
197
+ -->
198
+ ```
199
+ Also encode these as CSS custom properties on `:root` so they're reusable in the stylesheet.
200
+ 4. **Navigation bar** (only if multi-screen) — vanilla JS section toggling via `display:block/none`. No routing, no framework.
201
+ 5. **One `<section>` per screen.** Every screen must include the happy path AND at least one of: empty state, error state, loading state. Skipping these is the most common prototype failure mode.
202
+ 6. **Inline `<script>`** at end of body for interactions (tab switching, form submit interception, modal toggle, accordion). Vanilla JS only.
203
+
204
+ **Size budget**: under 300KB. No base64 photos. No Chart.js or other large libraries. Use inline SVG and CSS-drawn shapes for any illustrations. Tailwind via CDN is acceptable for mid/high-fi; skip for low-fi.
205
+
206
+ **Asset rules** (keep the file portable so users can open locally, email it, host on a gist, or push to any static host):
207
+ - No `<img src="https://...">` that can 404 — use inline SVG, data URIs, or CSS shapes
208
+ - No local relative paths (`./image.png`, `../style.css`) — they break the moment the file moves
209
+ - Fonts: Google Fonts CDN (single family, two weights max) or system fonts. No custom WOFF files.
210
+
211
+ ### Negative constraints (embed these explicitly in the @dev prompt)
212
+
213
+ When delegating to `@dev`, the prompt MUST include these as forbidden patterns:
214
+
215
+ - **No generic AI aesthetic.** Do not use Inter or Roboto by default. Do not use purple gradients on white. Commit to a named, deliberate aesthetic and call it out in the metadata.
216
+ - **No Lorem ipsum or placeholder filler.** All text must be realistic for the domain. "Card Title", "User Name", "Description goes here" are forbidden.
217
+ - **No happy-path-only screens.** Every screen must show at least one non-happy state (empty, error, or edge).
218
+ - **No broken interactivity.** Every `onclick`, `<form>`, or interactive element must respond visually. No `href="#"` that causes page jumps. No event handlers that throw console errors.
219
+ - **No external image dependencies that can break.** Inline SVG only.
220
+ - **No inconsistent component instances.** Define every recurring component as a named CSS class ONCE and reuse it. Do not re-style inline. If a card appears five times, it uses the same class five times.
221
+ - **No page-thinking when flow-thinking is required.** Screens appear in the order a user encounters them, not in the order they're easy to build.
222
+ - **No file-size bloat.** No base64 photos. No Chart.js, D3, or other heavyweight libraries. SVG and CSS only.
223
+
224
+ ### Output location
225
+
226
+ - **Action** — DetermineOutputDir:
227
+ - `branch_name=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)`
228
+ - **If** `FROM_UX=true` or `FROM_KICKOFF=true` → use the existing task directory
229
+ - **Else If** user specifies path → use that
230
+ - **Else** → `OUT_DIR=docs/tasks/{branch_name}`
231
+ - `mkdir -p "$OUT_DIR/prototypes"`
232
+
233
+ - **Action** — SaveArtifact: Write file to `{OUT_DIR}/prototypes/{feature_slug}_{MMDDYY}.html`
234
+
235
+ ## Step 6 — Self-Check Portability
236
+
237
+ Before reporting completion, sanity-check the artifact against the portability rules:
238
+
239
+ - File size under 300KB
240
+ - No `<img src="http...">` external images
241
+ - No local relative paths (`./`, `../`, `/local/`)
242
+ - All recurring components share a named CSS class (no inline-styled duplicates)
243
+ - Every screen includes at least one non-happy state
244
+
245
+ Surface any violations as caveats in the handoff. Don't silently ship a broken portable file.
246
+
247
+ ## Step 7 — Present & Handoff
248
+
249
+ - **Action** — PresentForReview:
250
+
251
+ > **Prototype complete**: `{path}` ({size} KB, {N} screens, {fidelity})
252
+ >
253
+ > **Visual anchor**: {named aesthetic}
254
+ > **Key assumptions made** (also embedded in file header):
255
+ > - {bullet 1}
256
+ > - {bullet 2}
257
+ > - {bullet 3}
258
+ > **NOT included**: {explicit list}
259
+ >
260
+ > Open the file in a browser to review (`open {path}` on macOS, or drag into any browser tab). The file is fully self-contained — share it however you like (email, gist, static host, etc.). Reply with feedback to iterate, or pick a next step below.
261
+
262
+ - **Action** — SurfaceFilledAssumptions (post-ux mode only): If `mode = post-ux` AND any filled assumptions exist (items the spec was silent on that the prototype filled in), append a closing-the-loop block:
263
+
264
+ > **Filled assumptions** — ux.md was silent on these; I made calls to render the spec. Review and tell me which to promote into the spec:
265
+ >
266
+ > 1. {assumption} → I chose **{decision}** ({why, one line})
267
+ > 2. {assumption} → I chose **{decision}** ({why, one line})
268
+ > 3. {assumption} → I chose **{decision}** ({why, one line})
269
+ >
270
+ > Reply with numbers to update ux.md (e.g. `1, 3`), `all` to add all, or `skip` to leave the spec as-is.
271
+
272
+ If user picks updates:
273
+ - Edit `ux.md` directly: place each chosen item in the appropriate section (Components / States / Content / Edge Cases / Interactions).
274
+ - Re-run the Step 6 portability check (no regen needed unless user also requested HTML changes).
275
+ - Re-present with a one-line diff per added item: `ux.md ← added: {item} (in {section})`.
276
+
277
+ - **Action** — RenderFooter: Render Next Steps using `Skill(spectre-guide)` skill, with mode-specific recommendation:
278
+ - **If `FROM_UX=true`** → recommend: "Resume `ux` Stage 2 with this prototype as input"
279
+ - **If `--explore`** → recommend: `scope` with the prototype as anchor
280
+ - **If post-scope** → recommend: `ux` (if flows still need detail) or `plan` (if ready to build)
281
+ - **Else** → standard Next Steps options
282
+
283
+ ---
284
+
285
+ ## Iteration Loop
286
+
287
+ If the user replies with feedback after Step 7:
288
+ - Small visual tweaks (color, copy, layout) → edit the HTML directly
289
+ - Structural changes (add screen, change flow) → re-run Step 4 subagents with the deltas and regenerate
290
+ - **Spec contradicts prototype** (post-ux mode) → ask which is authoritative for each contradiction, then update ux.md AND the HTML together so they stay paired; re-run Step 6 portability check
291
+ - After any edit, re-run the Step 6 self-check before re-presenting
292
+
293
+ ---
294
+
295
+ ## Success Criteria
296
+
297
+ - [ ] Immediate reply sent; mode detected (FROM_UX, --explore, post-scope, or standalone)
298
+ - [ ] Existing context docs (scope.md, prd.md, ux.md) read FULLY before asking questions
299
+ - [ ] Fidelity recommended with rationale; user confirmed or overrode
300
+ - [ ] Visual anchor captured (named aesthetic or reference) — never left as generic default
301
+ - [ ] Three subagents dispatched in parallel: web-research (references), analyst (flow + content), patterns (existing codebase anchor, if applicable)
302
+ - [ ] ALL subagents completed before generation
303
+ - [ ] HTML artifact is single self-contained file under 300KB
304
+ - [ ] Metadata comment block at top of `<head>` includes feature, fidelity, assumptions, NOT-included list
305
+ - [ ] Design tokens block present and encoded as CSS custom properties on `:root`
306
+ - [ ] Every screen includes happy path + at least one non-happy state (empty, error, or edge)
307
+ - [ ] No Lorem ipsum, no placeholder filler — realistic domain content throughout
308
+ - [ ] No external image dependencies (inline SVG only)
309
+ - [ ] All recurring components use a single named CSS class (no inline re-styling)
310
+ - [ ] All interactive elements respond visually; no console errors; no `href="#"` jump links
311
+ - [ ] Saved to `{OUT_DIR}/prototypes/{slug}_{MMDDYY}.html`
312
+ - [ ] Portability self-check run (size, external images, relative paths, component reuse, state coverage); violations surfaced as caveats
313
+ - [ ] (post-ux mode only) Filled assumptions surfaced in chat with offer to update ux.md; selected items written to ux.md with diff summary
314
+ - [ ] Next Steps footer rendered with mode-appropriate recommendation