qualia-framework 4.5.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +24 -0
- package/CLAUDE.md +12 -75
- package/README.md +23 -16
- package/agents/builder.md +9 -21
- package/agents/planner.md +8 -0
- package/agents/verifier.md +8 -0
- package/agents/visual-evaluator.md +132 -0
- package/bin/cli.js +54 -18
- package/bin/install.js +369 -29
- package/bin/qualia-ui.js +208 -1
- package/bin/slop-detect.mjs +5 -0
- package/bin/state.js +34 -1
- package/docs/install-redesign-builder-prompt.md +290 -0
- package/docs/install-redesign-pilot.md +234 -0
- package/docs/playwright-loop-builder-prompt.md +185 -0
- package/docs/playwright-loop-design-notes.md +108 -0
- package/docs/playwright-loop-pilot-results.md +170 -0
- package/docs/playwright-loop-tester-prompt.md +213 -0
- package/docs/polish-loop-supervised-run.md +111 -0
- package/docs/reviews/matt-pocock-skills-analysis.md +300 -0
- package/guide.md +9 -5
- package/hooks/env-empty-guard.js +74 -0
- package/hooks/pre-compact.js +19 -9
- package/hooks/pre-deploy-gate.js +8 -2
- package/hooks/pre-push.js +26 -12
- package/hooks/supabase-destructive-guard.js +62 -0
- package/hooks/vercel-account-guard.js +91 -0
- package/package.json +2 -1
- package/rules/design-brand.md +4 -0
- package/rules/design-laws.md +4 -0
- package/rules/design-product.md +4 -0
- package/rules/design-rubric.md +4 -0
- package/rules/grounding.md +4 -0
- package/skills/qualia-build/SKILL.md +40 -46
- package/skills/qualia-discuss/SKILL.md +51 -68
- package/skills/qualia-handoff/SKILL.md +1 -0
- package/skills/qualia-hook-gen/SKILL.md +206 -0
- package/skills/qualia-issues/SKILL.md +151 -0
- package/skills/qualia-map/SKILL.md +78 -35
- package/skills/qualia-new/REFERENCE.md +139 -0
- package/skills/qualia-new/SKILL.md +45 -121
- package/skills/qualia-optimize/REFERENCE.md +265 -0
- package/skills/qualia-optimize/SKILL.md +92 -232
- package/skills/qualia-plan/SKILL.md +58 -65
- package/skills/qualia-polish-loop/REFERENCE.md +265 -0
- package/skills/qualia-polish-loop/SKILL.md +201 -0
- package/skills/qualia-polish-loop/fixtures/broken.html +117 -0
- package/skills/qualia-polish-loop/fixtures/clean.html +196 -0
- package/skills/qualia-polish-loop/scripts/loop.mjs +323 -0
- package/skills/qualia-polish-loop/scripts/playwright-capture.mjs +206 -0
- package/skills/qualia-polish-loop/scripts/score.mjs +176 -0
- package/skills/qualia-prd/SKILL.md +199 -0
- package/skills/qualia-report/SKILL.md +141 -200
- package/skills/qualia-research/SKILL.md +28 -33
- package/skills/qualia-road/SKILL.md +103 -0
- package/skills/qualia-ship/SKILL.md +1 -0
- package/skills/qualia-task/SKILL.md +1 -1
- package/skills/qualia-test/SKILL.md +50 -2
- package/skills/qualia-triage/SKILL.md +152 -0
- package/skills/qualia-verify/SKILL.md +63 -104
- package/skills/qualia-zoom/SKILL.md +51 -0
- package/skills/zoho-workflow/SKILL.md +1 -1
- package/templates/CONTEXT.md +36 -0
- package/templates/decisions/ADR-template.md +30 -0
- package/tests/bin.test.sh +598 -7
- package/tests/state.test.sh +58 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: qualia-new
|
|
3
|
-
description: "Set up a new project from scratch — deep questioning, ALWAYS-AUTO research, JOURNEY.md with all milestones to handoff, single approval gate, optional auto-chain into building. Use when starting any new client project."
|
|
3
|
+
description: "Set up a new project from scratch — deep questioning, ALWAYS-AUTO research, CONTEXT.md domain glossary seed, decisions/ ADR folder initialized, JOURNEY.md with all milestones to handoff, single approval gate, optional auto-chain into building. Use when starting any new client project."
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- Bash
|
|
6
6
|
- Read
|
|
@@ -17,6 +17,12 @@ allowed-tools:
|
|
|
17
17
|
|
|
18
18
|
# /qualia-new — New Project (Full Journey)
|
|
19
19
|
|
|
20
|
+
## Reference templates
|
|
21
|
+
|
|
22
|
+
Detailed agent-prompt templates and rendering formats live in `REFERENCE.md` (in this same skill folder). When a step below says "see REFERENCE.md section X", read that section before generating the spawn.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
20
26
|
Initialize a project with the **entire arc mapped from kickoff to handoff**. All milestones defined upfront so the team follows a clear path, not improvising after each ship.
|
|
21
27
|
|
|
22
28
|
## Flags
|
|
@@ -107,6 +113,35 @@ git add .planning/PROJECT.md
|
|
|
107
113
|
git commit -m "docs: initialize project"
|
|
108
114
|
```
|
|
109
115
|
|
|
116
|
+
### Step 5a. Seed CONTEXT.md and decisions/ (v5.0 — REQUIRED)
|
|
117
|
+
|
|
118
|
+
The domain glossary is the single highest-leverage piece of substrate — every road agent loads it BEFORE PROJECT.md/DESIGN.md. Misalignment is the #1 failure mode in AI coding; CONTEXT.md kills it.
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Copy template
|
|
122
|
+
cp ~/.claude/qualia-templates/CONTEXT.md .planning/CONTEXT.md
|
|
123
|
+
|
|
124
|
+
# Initialize ADR folder with the template available for reference
|
|
125
|
+
mkdir -p .planning/decisions
|
|
126
|
+
cp ~/.claude/qualia-templates/decisions/ADR-template.md .planning/decisions/_template.md
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Then **seed the glossary from the questioning answers**. For each domain term that came up during Step 1 (Deep Questioning) — entities, actions, statuses, key nouns the user repeatedly said — add an entry to `.planning/CONTEXT.md` under `## Language` with:
|
|
130
|
+
- the term
|
|
131
|
+
- a one-sentence definition
|
|
132
|
+
- an `Avoid:` line listing rejected synonyms (terms the team should NOT use for this concept)
|
|
133
|
+
|
|
134
|
+
If the user used multiple terms for the same thing during questioning, capture the disambiguation under `## Flagged ambiguities` (e.g. "User → AuthUser vs Customer").
|
|
135
|
+
|
|
136
|
+
Replace `{{PROJECT_NAME}}` in CONTEXT.md with the project name.
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
git add .planning/CONTEXT.md .planning/decisions/
|
|
140
|
+
git commit -m "docs: seed CONTEXT.md domain glossary + decisions/ folder"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The glossary stays terse — one sentence per entry. It's loaded into every agent spawn; bloat costs tokens. `/qualia-discuss` will grow it inline as decisions crystallize during phase planning.
|
|
144
|
+
|
|
110
145
|
### Step 5b. Write PRODUCT.md (v4.5.0 — REQUIRED)
|
|
111
146
|
|
|
112
147
|
`PRODUCT.md` is the "who and why" every road agent reads before designing or building. It is **required** — the planner, builder, and verifier all load it as substrate.
|
|
@@ -183,62 +218,9 @@ mkdir -p .planning/research
|
|
|
183
218
|
|
|
184
219
|
Say: **"Running 4 parallel research agents (stack, features, architecture, pitfalls)..."**
|
|
185
220
|
|
|
186
|
-
Spawn 4 researchers in parallel (single message, 4 Agent tool calls), with multi-milestone scope
|
|
221
|
+
Spawn 4 researchers in parallel (single message, 4 Agent tool calls), with multi-milestone scope. See REFERENCE.md section "Researcher prompts (4 dimensions)" for the verbatim prompt templates.
|
|
187
222
|
|
|
188
|
-
|
|
189
|
-
Agent(prompt="
|
|
190
|
-
Read your role: @~/.claude/agents/researcher.md
|
|
191
|
-
|
|
192
|
-
<dimension>stack</dimension>
|
|
193
|
-
<domain>{inferred domain from PROJECT.md}</domain>
|
|
194
|
-
<project_context>{PROJECT.md summary}</project_context>
|
|
195
|
-
<milestone_context>multi-milestone — research must cover scalability through Milestone 3+</milestone_context>
|
|
196
|
-
<output_path>.planning/research/STACK.md</output_path>
|
|
197
|
-
", subagent_type="qualia-researcher", description="Stack research")
|
|
198
|
-
|
|
199
|
-
Agent(prompt="
|
|
200
|
-
Read your role: @~/.claude/agents/researcher.md
|
|
201
|
-
|
|
202
|
-
<dimension>features</dimension>
|
|
203
|
-
<domain>{inferred domain}</domain>
|
|
204
|
-
<project_context>{PROJECT.md summary}</project_context>
|
|
205
|
-
<milestone_context>multi-milestone — distinguish v1 table stakes from v2 differentiators</milestone_context>
|
|
206
|
-
<output_path>.planning/research/FEATURES.md</output_path>
|
|
207
|
-
", subagent_type="qualia-researcher", description="Features research")
|
|
208
|
-
|
|
209
|
-
Agent(prompt="
|
|
210
|
-
Read your role: @~/.claude/agents/researcher.md
|
|
211
|
-
|
|
212
|
-
<dimension>architecture</dimension>
|
|
213
|
-
<domain>{inferred domain}</domain>
|
|
214
|
-
<project_context>{PROJECT.md summary}</project_context>
|
|
215
|
-
<milestone_context>multi-milestone — Phase 1 foundations must support final-milestone requirements</milestone_context>
|
|
216
|
-
<output_path>.planning/research/ARCHITECTURE.md</output_path>
|
|
217
|
-
", subagent_type="qualia-researcher", description="Architecture research")
|
|
218
|
-
|
|
219
|
-
Agent(prompt="
|
|
220
|
-
Read your role: @~/.claude/agents/researcher.md
|
|
221
|
-
|
|
222
|
-
<dimension>pitfalls</dimension>
|
|
223
|
-
<domain>{inferred domain}</domain>
|
|
224
|
-
<project_context>{PROJECT.md summary}</project_context>
|
|
225
|
-
<milestone_context>multi-milestone — flag risks that stall LATER milestones, not just v1</milestone_context>
|
|
226
|
-
<output_path>.planning/research/PITFALLS.md</output_path>
|
|
227
|
-
", subagent_type="qualia-researcher", description="Pitfalls research")
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
**After all 4 complete, spawn synthesizer:**
|
|
231
|
-
|
|
232
|
-
```
|
|
233
|
-
Agent(prompt="
|
|
234
|
-
Read your role: @~/.claude/agents/research-synthesizer.md
|
|
235
|
-
|
|
236
|
-
Merge the 4 research files at .planning/research/ into .planning/research/SUMMARY.md.
|
|
237
|
-
This is a multi-milestone project — the SUMMARY must suggest a FULL milestone arc
|
|
238
|
-
(2-5 milestones including Handoff), not just a v1 phase list. Include roadmap
|
|
239
|
-
implications AND handoff implications (what client takeover requires).
|
|
240
|
-
", subagent_type="qualia-research-synthesizer", description="Synthesize research")
|
|
241
|
-
```
|
|
223
|
+
**After all 4 complete, spawn synthesizer.** See REFERENCE.md section "Synthesizer prompt" for the verbatim prompt template.
|
|
242
224
|
|
|
243
225
|
**Commit:**
|
|
244
226
|
```bash
|
|
@@ -276,40 +258,7 @@ Gather any additional requirements the user wants that research missed.
|
|
|
276
258
|
node ~/.claude/bin/qualia-ui.js banner roadmap
|
|
277
259
|
```
|
|
278
260
|
|
|
279
|
-
Spawn the roadmapper with full-journey mandate. If the user passed `--full-detail`, include `<full_detail>true</full_detail>` in the prompt so the roadmapper writes complete phase detail for ALL milestones.
|
|
280
|
-
|
|
281
|
-
```
|
|
282
|
-
Agent(prompt="
|
|
283
|
-
Read your role: @~/.claude/agents/roadmapper.md
|
|
284
|
-
|
|
285
|
-
<task>
|
|
286
|
-
Create the FULL JOURNEY for this project:
|
|
287
|
-
- .planning/JOURNEY.md — all milestones (2-5 including Handoff) with exit criteria
|
|
288
|
-
- .planning/REQUIREMENTS.md — requirements grouped by milestone
|
|
289
|
-
- .planning/ROADMAP.md — Milestone 1's phase detail (and ALL milestones if full_detail=true)
|
|
290
|
-
|
|
291
|
-
User-scoped v1 features:
|
|
292
|
-
{list of features selected in Step 9, grouped by category}
|
|
293
|
-
|
|
294
|
-
Template type: {template_type from config.json}
|
|
295
|
-
If set, use ~/.claude/qualia-templates/projects/{type}.md as the milestone arc starting point.
|
|
296
|
-
|
|
297
|
-
<full_detail>{true if --full-detail, else false}</full_detail>
|
|
298
|
-
- false (default): Milestone 1 gets full phase detail; M2..M{N-1} stay as sketches. Detail fills in when each milestone opens via /qualia-milestone.
|
|
299
|
-
- true: every milestone (M1..Handoff) gets full phase-level detail in ROADMAP.md upfront. Useful when the client wants a fully-committed plan at kickoff.
|
|
300
|
-
|
|
301
|
-
The final milestone MUST be named 'Handoff' with the fixed 4 phases
|
|
302
|
-
(Polish, Content + SEO, Final QA, Handoff). Do not omit it.
|
|
303
|
-
|
|
304
|
-
After writing, update STATE.md via:
|
|
305
|
-
node ~/.claude/bin/state.js init \\
|
|
306
|
-
--project '{name}' --client '{client}' --type '{type}' \\
|
|
307
|
-
--milestone_name '{Milestone 1 name}' \\
|
|
308
|
-
--phases '<JSON: Milestone 1 phases only>' \\
|
|
309
|
-
--total_phases <count>
|
|
310
|
-
</task>
|
|
311
|
-
", subagent_type="qualia-roadmapper", description="Create full journey")
|
|
312
|
-
```
|
|
261
|
+
Spawn the roadmapper with full-journey mandate. If the user passed `--full-detail`, include `<full_detail>true</full_detail>` in the prompt so the roadmapper writes complete phase detail for ALL milestones. See REFERENCE.md section "Roadmapper prompt" for the verbatim prompt template.
|
|
313
262
|
|
|
314
263
|
### Step 11. Present the Journey (single view)
|
|
315
264
|
|
|
@@ -321,37 +270,7 @@ node ~/.claude/bin/qualia-ui.js journey-tree .planning/JOURNEY.md
|
|
|
321
270
|
|
|
322
271
|
This shows M1..M{N} as a vertical ladder: shipped milestones get a green dot, current gets a teal diamond with `[CURRENT]` tag, future get dim open circles. Handoff gets `[FINAL]` tag. Why-now + phase sketch render under current and final.
|
|
323
272
|
|
|
324
|
-
Also narrate the one-glance summary
|
|
325
|
-
|
|
326
|
-
```
|
|
327
|
-
## Proposed Journey
|
|
328
|
-
|
|
329
|
-
**{N} milestones to handoff** | **{X} requirements mapped** | All v1 requirements covered ✓
|
|
330
|
-
|
|
331
|
-
┌─ Milestone 1 · {Name} [CURRENT]
|
|
332
|
-
│ Why now: {one line}
|
|
333
|
-
│ Exit: {outcome 1}, {outcome 2}
|
|
334
|
-
│ Phases: 1. {name} → 2. {name} → 3. {name}
|
|
335
|
-
│ Requirements: {REQ-IDs}
|
|
336
|
-
└─
|
|
337
|
-
↓
|
|
338
|
-
┌─ Milestone 2 · {Name}
|
|
339
|
-
│ Why now: {one line}
|
|
340
|
-
│ Exit: {outcome 1}, {outcome 2}
|
|
341
|
-
│ Phases: 1. {name} → 2. {name}
|
|
342
|
-
│ Requirements: {REQ-IDs}
|
|
343
|
-
└─
|
|
344
|
-
↓
|
|
345
|
-
...
|
|
346
|
-
↓
|
|
347
|
-
┌─ Milestone {N} · Handoff [FINAL]
|
|
348
|
-
│ Exit: Deployed, docs, credentials, walkthrough
|
|
349
|
-
│ Phases: 1. Polish → 2. Content + SEO → 3. Final QA → 4. Handoff
|
|
350
|
-
└─
|
|
351
|
-
|
|
352
|
-
Milestone 1 is fully planned. Milestones 2..{N-1} are sketched and will be detailed
|
|
353
|
-
when they open. Milestone {N} (Handoff) uses the standard 4-phase template.
|
|
354
|
-
```
|
|
273
|
+
Also narrate the one-glance summary. See REFERENCE.md section "Journey ladder format" for the ASCII template.
|
|
355
274
|
|
|
356
275
|
### Step 12. Approval Gate (single — for the whole journey)
|
|
357
276
|
|
|
@@ -422,6 +341,9 @@ Show summary:
|
|
|
422
341
|
| Artifact | Location |
|
|
423
342
|
|----------------|-----------------------------|
|
|
424
343
|
| Project | .planning/PROJECT.md |
|
|
344
|
+
| Glossary | .planning/CONTEXT.md |
|
|
345
|
+
| Decisions | .planning/decisions/ |
|
|
346
|
+
| Product | .planning/PRODUCT.md |
|
|
425
347
|
| Journey | .planning/JOURNEY.md |
|
|
426
348
|
| Requirements | .planning/REQUIREMENTS.md |
|
|
427
349
|
| Roadmap (M1) | .planning/ROADMAP.md |
|
|
@@ -451,3 +373,5 @@ Do NOT use `--quick` for: client projects, anything with compliance stakes, anyt
|
|
|
451
373
|
5. **Milestone 1 is fully detailed.** M2..M{N-1} are sketched. Detail fills in when each milestone opens.
|
|
452
374
|
6. **STATE.md through state.js.** Never edit STATE.md or tracking.json by hand.
|
|
453
375
|
7. **Inline skill invocation.** When Step 0.5 offers `/qualia-map`, invoke it inline — don't exit.
|
|
376
|
+
8. **CONTEXT.md is mandatory (v5.0).** Every project gets a domain glossary at `.planning/CONTEXT.md`. Seeded from questioning answers. Loaded by every road agent. Kept terse.
|
|
377
|
+
9. **ADRs are scarce.** `.planning/decisions/` exists from day one but only fills with hard-to-reverse, surprising-without-context, real-tradeoff decisions. Cargo-culting ADRs ruins the signal.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# /qualia-optimize Reference Templates
|
|
2
|
+
|
|
3
|
+
Agent-prompt templates for SKILL.md. Copy, fill `{placeholders}`, spawn.
|
|
4
|
+
|
|
5
|
+
## Frontend agent prompt
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Agent(
|
|
9
|
+
prompt="Optimize frontend. Analyze planning docs + rules, then code.
|
|
10
|
+
|
|
11
|
+
<planning>
|
|
12
|
+
{PROJECT.md content}
|
|
13
|
+
{REQUIREMENTS.md content}
|
|
14
|
+
{DESIGN.md content}
|
|
15
|
+
</planning>
|
|
16
|
+
|
|
17
|
+
<rules>
|
|
18
|
+
{rules/frontend.md content}
|
|
19
|
+
</rules>
|
|
20
|
+
|
|
21
|
+
<task>
|
|
22
|
+
Analyze frontend:
|
|
23
|
+
|
|
24
|
+
1. **UI Quality**
|
|
25
|
+
- Loading: every async op needs indicator
|
|
26
|
+
- Error: data-fetching components handle errors
|
|
27
|
+
- Empty: lists/tables handle zero items helpfully
|
|
28
|
+
- Responsive: no fixed px widths, breakpoints handled
|
|
29
|
+
- A11y: alt text, ARIA, keyboard nav
|
|
30
|
+
|
|
31
|
+
2. **Design Alignment**
|
|
32
|
+
- Components vs DESIGN.md (colors, typography, spacing)
|
|
33
|
+
- rules/frontend.md compliance: distinctive fonts? sharp accents? transitions? No card grids / gradients?
|
|
34
|
+
- Consistency across app (buttons, spacing, colors)
|
|
35
|
+
|
|
36
|
+
3. **Frontend Perf**
|
|
37
|
+
- Bundle: large imports -> tree-shake or dynamic import
|
|
38
|
+
- Images: next/image? width/height? lazy below fold?
|
|
39
|
+
- Fonts: next/font? No render-blocking?
|
|
40
|
+
- CSS: unused Tailwind? conflicts?
|
|
41
|
+
- Rendering: unnecessary re-renders, missing memo, heavy computations
|
|
42
|
+
|
|
43
|
+
Per finding: What / Where (file:line) / Why (impact) / Fix / Severity (CRITICAL|HIGH|MEDIUM|LOW)
|
|
44
|
+
</task>",
|
|
45
|
+
subagent_type="general-purpose",
|
|
46
|
+
description="Frontend optimization analysis"
|
|
47
|
+
)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Backend agent prompt
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
Agent(
|
|
54
|
+
prompt="Optimize backend. Analyze planning docs + security rules, then code.
|
|
55
|
+
|
|
56
|
+
<planning>
|
|
57
|
+
{PROJECT.md content}
|
|
58
|
+
{REQUIREMENTS.md content}
|
|
59
|
+
</planning>
|
|
60
|
+
|
|
61
|
+
<rules>
|
|
62
|
+
{rules/security.md content}
|
|
63
|
+
</rules>
|
|
64
|
+
|
|
65
|
+
<task>
|
|
66
|
+
Analyze backend:
|
|
67
|
+
|
|
68
|
+
1. **Security**
|
|
69
|
+
- RLS: every table needs RLS + policies
|
|
70
|
+
- Service role: grep client code (app/, components/, src/) for service_role -> must be ZERO
|
|
71
|
+
- Auth: mutations use server-side auth (supabase.auth.getUser())
|
|
72
|
+
- Validation: Zod before DB ops
|
|
73
|
+
- No dangerouslySetInnerHTML / eval()
|
|
74
|
+
|
|
75
|
+
2. **Data Access**
|
|
76
|
+
- Writes via 'use server' actions, not direct client calls
|
|
77
|
+
- try/catch with meaningful errors
|
|
78
|
+
- revalidatePath/revalidateTag after mutations
|
|
79
|
+
|
|
80
|
+
3. **Edge Functions** (if supabase/functions/ exists)
|
|
81
|
+
- Cold start: bundle size, dep count
|
|
82
|
+
- Error handling + logging
|
|
83
|
+
- CORS config
|
|
84
|
+
- Timeout protection
|
|
85
|
+
|
|
86
|
+
4. **API Quality**
|
|
87
|
+
- Rate limiting on public endpoints
|
|
88
|
+
- Proper HTTP status codes
|
|
89
|
+
- Consistent error format
|
|
90
|
+
|
|
91
|
+
Per finding: What / Where (file:line) / Why (impact) / Fix / Severity (CRITICAL|HIGH|MEDIUM|LOW)
|
|
92
|
+
</task>",
|
|
93
|
+
subagent_type="general-purpose",
|
|
94
|
+
description="Backend optimization analysis"
|
|
95
|
+
)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Performance oracle prompt
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
Agent(
|
|
102
|
+
prompt="Analyze cross-cutting perf issues.
|
|
103
|
+
|
|
104
|
+
<planning>
|
|
105
|
+
{PROJECT.md content}
|
|
106
|
+
</planning>
|
|
107
|
+
|
|
108
|
+
<task>
|
|
109
|
+
Full-stack perf analysis:
|
|
110
|
+
|
|
111
|
+
1. **DB Queries**
|
|
112
|
+
- N+1: .from() inside loops/.map()
|
|
113
|
+
- Missing indexes on .eq()/.filter()/.order() columns
|
|
114
|
+
- Sequential -> parallel (Promise.all)
|
|
115
|
+
- Over-fetching: SELECT * when specific columns suffice
|
|
116
|
+
|
|
117
|
+
2. **API Latency**
|
|
118
|
+
- Sequential client calls -> batch
|
|
119
|
+
- Missing caching (stale times, HTTP cache headers)
|
|
120
|
+
- Large payloads without pagination
|
|
121
|
+
|
|
122
|
+
3. **Bundle Size**
|
|
123
|
+
- Barrel exports blocking tree-shaking
|
|
124
|
+
- Large libs for single fns (lodash, moment)
|
|
125
|
+
- Missing dynamic imports for heavy components
|
|
126
|
+
|
|
127
|
+
4. **Render Perf**
|
|
128
|
+
- Expensive computations without useMemo
|
|
129
|
+
- Handlers recreated per render without useCallback
|
|
130
|
+
- Large lists without virtualization
|
|
131
|
+
- Context providers causing unnecessary re-renders
|
|
132
|
+
|
|
133
|
+
Per finding: What / Where (file:line) / Why (impact, quantified) / Fix / Severity (CRITICAL|HIGH|MEDIUM|LOW)
|
|
134
|
+
</task>",
|
|
135
|
+
subagent_type="general-purpose",
|
|
136
|
+
description="Performance optimization analysis"
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Architecture strategist prompt (deepening lens)
|
|
141
|
+
|
|
142
|
+
`full`: after Wave 1 (synthesizes + deepens). `deepen`: sole agent (no Wave 1).
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
Agent(
|
|
146
|
+
prompt="Arch strategist: Ousterhout deepening lens + cross-cutting issues. Use domain language from CONTEXT.md.
|
|
147
|
+
|
|
148
|
+
<wave1_findings>
|
|
149
|
+
{Wave 1 findings; empty in --deepen mode}
|
|
150
|
+
</wave1_findings>
|
|
151
|
+
|
|
152
|
+
<planning>
|
|
153
|
+
{PROJECT.md content}
|
|
154
|
+
{REQUIREMENTS.md content}
|
|
155
|
+
{CONTEXT.md content (domain glossary)}
|
|
156
|
+
{decisions/*.md content (ADRs constraining refactor space)}
|
|
157
|
+
</planning>
|
|
158
|
+
|
|
159
|
+
<vocabulary>
|
|
160
|
+
- **Module**: construct with interface + impl (fn, class, package, slice)
|
|
161
|
+
- **Interface**: everything caller must know (types, invariants, error modes, ordering, config)
|
|
162
|
+
- **Depth**: leverage at interface. Deep = high leverage. Shallow = interface ~ impl.
|
|
163
|
+
- **Seam**: where interface lives; alterable without in-place editing.
|
|
164
|
+
- **Locality**: change, bug, knowledge concentrated in one location.
|
|
165
|
+
- **Deletion test**: deleting module makes complexity vanish across N callers -> earning keep.
|
|
166
|
+
</vocabulary>
|
|
167
|
+
|
|
168
|
+
<task>
|
|
169
|
+
TWO sections:
|
|
170
|
+
|
|
171
|
+
A) **Cross-cutting** (skip in --deepen):
|
|
172
|
+
1. Recurring Wave 1 patterns -> structural problem
|
|
173
|
+
2. Frontend-backend coupling
|
|
174
|
+
3. Inconsistent patterns (server actions vs API routes)
|
|
175
|
+
4. Missing abstractions (pattern repeated 3+ times)
|
|
176
|
+
5. Dead code / unused exports
|
|
177
|
+
|
|
178
|
+
B) **Deepening candidates** (always):
|
|
179
|
+
Per candidate:
|
|
180
|
+
- **Files**: file:line ranges
|
|
181
|
+
- **Problem**: what's shallow, what leaks
|
|
182
|
+
- **Solution**: new interface, what gets hidden
|
|
183
|
+
- **Benefits**: locality, leverage, testability
|
|
184
|
+
- **Deletion test**: deleting X -> N callers no longer need what?
|
|
185
|
+
- **Domain terms**: CONTEXT.md terms touched or surfaced
|
|
186
|
+
- **Severity**: CRITICAL | HIGH | MEDIUM | LOW
|
|
187
|
+
|
|
188
|
+
Look for:
|
|
189
|
+
- Shallow wrappers (interface ~ impl)
|
|
190
|
+
- Pure fns extracted for testability only (no locality)
|
|
191
|
+
- Concept-bouncing (1 concept -> 5+ files)
|
|
192
|
+
- Cross-seam coupling (private detail leaking)
|
|
193
|
+
- Untested/untestable sections (bad seams)
|
|
194
|
+
|
|
195
|
+
REFUSE: 'extract helper fn' failing deletion test. More shallow modules = disease.
|
|
196
|
+
|
|
197
|
+
Format: What/Where/Why/Fix/Severity.
|
|
198
|
+
</task>",
|
|
199
|
+
subagent_type="general-purpose",
|
|
200
|
+
description="Architecture synthesis + deepening"
|
|
201
|
+
)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Parallel interface design prompt (`--deepen` Wave 3, fan-out × 3)
|
|
205
|
+
|
|
206
|
+
Spawn 3 agents in the SAME response turn. Each gets the same candidate but a *different* design constraint so the alternatives differ structurally. Use this verbatim — the per-agent constraint is the only variable:
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
Agent(
|
|
210
|
+
prompt="Interface designer (variant {1|2|3}/3). Produce ONE radically different
|
|
211
|
+
interface for this deep-module candidate. Other variants are running in parallel
|
|
212
|
+
with different constraints — yours is uniquely framed by your design lens.
|
|
213
|
+
|
|
214
|
+
<candidate>
|
|
215
|
+
{candidate block from arch strategist: files, problem, current shallow signature}
|
|
216
|
+
</candidate>
|
|
217
|
+
|
|
218
|
+
<context>
|
|
219
|
+
{INLINE .planning/CONTEXT.md (domain glossary — USE these terms verbatim)}
|
|
220
|
+
{INLINE .planning/decisions/*.md (ADRs constraining the design space)}
|
|
221
|
+
</context>
|
|
222
|
+
|
|
223
|
+
<your_lens>
|
|
224
|
+
Variant 1 → functional / data-oriented (no classes; pure functions; explicit data flow)
|
|
225
|
+
Variant 2 → OOP / encapsulated (class with private state; methods on a stable receiver)
|
|
226
|
+
Variant 3 → event-driven / message-based (subscriber model; commands and events)
|
|
227
|
+
[Use whichever lens is assigned to YOU above — fan-out call passes only ONE]
|
|
228
|
+
</your_lens>
|
|
229
|
+
|
|
230
|
+
<task>
|
|
231
|
+
Design the interface only. Do NOT implement. Output:
|
|
232
|
+
|
|
233
|
+
1. **Interface sketch** (TypeScript signatures, 5-15 lines). Function/class/event
|
|
234
|
+
names use CONTEXT.md domain language. No invented synonyms.
|
|
235
|
+
|
|
236
|
+
2. **Locality gain** (1 sentence): what concentrates in this module's seam that
|
|
237
|
+
was previously scattered across N files?
|
|
238
|
+
|
|
239
|
+
3. **Testability** (1-3 lines): where do mocks / adapters live? What's a
|
|
240
|
+
1-line test name that would be easy to write against this interface?
|
|
241
|
+
|
|
242
|
+
4. **Migration cost** (1 line): rough count — how many callers need updating?
|
|
243
|
+
Are any breaking changes? Can it be staged incrementally?
|
|
244
|
+
|
|
245
|
+
5. **Trade-off** (1 sentence): what does THIS shape sacrifice compared to the
|
|
246
|
+
other two variants?
|
|
247
|
+
|
|
248
|
+
Constraints:
|
|
249
|
+
- Interface should be DEEP (high leverage per surface area). Refuse a shallow
|
|
250
|
+
wrapper that just renames the existing functions.
|
|
251
|
+
- The deletion test must pass: deleting this module makes complexity vanish at
|
|
252
|
+
N callers, not just relocate it.
|
|
253
|
+
- Use CONTEXT.md terms. Do NOT invent new vocabulary.
|
|
254
|
+
- Output exactly the 5 numbered sections above. No prose preamble.
|
|
255
|
+
</task>",
|
|
256
|
+
subagent_type="general-purpose",
|
|
257
|
+
description="Interface variant {N}/3 — {functional|OOP|event-driven} lens"
|
|
258
|
+
)
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
After all 3 return, present a comparison table to the user (see SKILL.md Step 5b). User picks 1, 2, 3, or hybrid. Then a single synthesizer agent writes the Refactor RFC to `.planning/REFACTOR-{slug}.md` honoring the user's pick.
|
|
262
|
+
|
|
263
|
+
**Token cost**: ~6K per variant × 3 variants = ~18K for the fan-out. Cached prefix (CONTEXT.md + ADRs + candidate block) is shared across the 3 spawns, so effective cost is closer to ~12K. The output rfc-pick stage adds ~3K. Total per-deepening-candidate: ~15K — well within Qualia's per-skill budget.
|
|
264
|
+
|
|
265
|
+
**Skip variants when one would obviously dominate**: if the codebase is heavily functional (e.g., Effect-based) the OOP variant adds zero value. Strategist may suggest 2 lenses instead of 3 in that case. Default is always 3 unless explicitly noted.
|