qualia-framework 4.5.0 → 5.1.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-review-2026-05-03.md +65 -0
- package/docs/playwright-loop-tester-prompt.md +213 -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-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 +202 -0
- package/skills/qualia-optimize/SKILL.md +72 -237
- 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 +302 -0
- package/skills/qualia-polish-loop/scripts/playwright-capture.mjs +197 -0
- package/skills/qualia-polish-loop/scripts/score.mjs +176 -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 +451 -7
- package/tests/state.test.sh +58 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: qualia-optimize
|
|
3
|
-
description: "Deep optimization pass — reads .planning/ AND codebase to find performance, design, UI, backend,
|
|
3
|
+
description: "Deep optimization pass — reads .planning/ AND codebase to find performance, design, UI, backend, frontend, AND architecture-deepening opportunities. Spawns parallel specialist agents. Use whenever the user says 'optimize', 'optimization pass', 'find issues', 'qualia-optimize', 'deep optimize', 'performance audit', 'design alignment check', 'speed up', 'slow', 'bundle size', 'refactor architecture', 'shallow modules', 'simplify', or wants a comprehensive quality sweep. Supports --perf, --ui, --backend, --alignment, --deepen, --fix flags."
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- Bash
|
|
6
6
|
- Read
|
|
@@ -13,30 +13,35 @@ allowed-tools:
|
|
|
13
13
|
|
|
14
14
|
# Qualia Optimize — Deep Codebase + Planning Optimization
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
## Reference templates
|
|
17
|
+
|
|
18
|
+
Detailed agent-prompt templates 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.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
Reads `.planning/` docs AND codebase. Never analyze one without the other.
|
|
17
23
|
|
|
18
24
|
## Usage
|
|
19
25
|
|
|
20
|
-
- `/qualia-optimize` — Full
|
|
26
|
+
- `/qualia-optimize` — Full (all 7 dimensions + architecture deepening)
|
|
21
27
|
- `/qualia-optimize --perf` — Performance only (queries, bundle, render, latency)
|
|
22
28
|
- `/qualia-optimize --ui` — Frontend/design/UI only
|
|
23
|
-
- `/qualia-optimize --backend` — Backend only (RLS, auth, queries, edge
|
|
24
|
-
- `/qualia-optimize --alignment` — Planning-code alignment
|
|
25
|
-
- `/qualia-optimize --
|
|
29
|
+
- `/qualia-optimize --backend` — Backend only (RLS, auth, queries, edge fns)
|
|
30
|
+
- `/qualia-optimize --alignment` — Planning-code alignment only
|
|
31
|
+
- `/qualia-optimize --deepen` — Architecture deepening only (Ousterhout: shallow modules, deeper interfaces)
|
|
32
|
+
- `/qualia-optimize --fix` — Auto-fix LOW/MEDIUM from existing OPTIMIZE.md
|
|
26
33
|
|
|
27
34
|
## Process
|
|
28
35
|
|
|
29
36
|
### Step 1: Parse Arguments
|
|
30
37
|
|
|
31
|
-
|
|
38
|
+
Mode from $ARGUMENTS. Default: `full`.
|
|
39
|
+
Modes: `full`, `perf`, `ui`, `backend`, `alignment`, `deepen`, `fix`.
|
|
40
|
+
`--fix` skips to Step 9 (requires `.planning/OPTIMIZE.md`).
|
|
32
41
|
|
|
33
|
-
|
|
42
|
+
### Step 2: Load Planning Context (MANDATORY)
|
|
34
43
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
### Step 2: Load Planning Context (MANDATORY — never skip)
|
|
38
|
-
|
|
39
|
-
Read ALL of these (skip silently if file doesn't exist, but always attempt):
|
|
44
|
+
Read all (skip silently if missing):
|
|
40
45
|
|
|
41
46
|
```bash
|
|
42
47
|
cat .planning/PROJECT.md 2>/dev/null || echo "NO_PROJECT"
|
|
@@ -58,15 +63,23 @@ cat .planning/STATE.md 2>/dev/null || echo "NO_STATE"
|
|
|
58
63
|
cat .planning/DESIGN.md 2>/dev/null || echo "NO_DESIGN"
|
|
59
64
|
```
|
|
60
65
|
|
|
61
|
-
|
|
66
|
+
```bash
|
|
67
|
+
cat .planning/CONTEXT.md 2>/dev/null || echo "NO_CONTEXT"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
ls .planning/decisions/ 2>/dev/null && cat .planning/decisions/*.md 2>/dev/null || echo "NO_ADRS"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Also read rules:
|
|
62
75
|
```bash
|
|
63
76
|
cat ~/.claude/rules/frontend.md 2>/dev/null
|
|
64
77
|
cat ~/.claude/rules/security.md 2>/dev/null
|
|
65
78
|
```
|
|
66
79
|
|
|
67
|
-
Store all
|
|
80
|
+
Store all; inline into agent prompts.
|
|
68
81
|
|
|
69
|
-
**
|
|
82
|
+
**No planning docs:** warn, proceed. Can optimize raw codebase; can't check alignment.
|
|
70
83
|
|
|
71
84
|
### Step 3: Discover Codebase
|
|
72
85
|
|
|
@@ -87,224 +100,49 @@ git diff --stat HEAD~10..HEAD 2>/dev/null | tail -5
|
|
|
87
100
|
ls -d app/ src/ pages/ components/ lib/ actions/ hooks/ supabase/ types/ 2>/dev/null
|
|
88
101
|
```
|
|
89
102
|
|
|
90
|
-
Classify
|
|
103
|
+
Classify: `web` | `voice` | `mobile` | `agent` | `edge-functions` | `unknown`
|
|
91
104
|
|
|
92
105
|
### Step 4: Spawn Wave 1 Agents (parallel)
|
|
93
106
|
|
|
94
|
-
|
|
107
|
+
Spawn in **single message** with multiple Agent() calls per mode:
|
|
95
108
|
|
|
96
109
|
| Mode | Agents |
|
|
97
110
|
|------|--------|
|
|
98
|
-
| `full` | frontend
|
|
99
|
-
| `perf` |
|
|
100
|
-
| `ui` | frontend
|
|
101
|
-
| `backend` | backend
|
|
102
|
-
| `alignment` |
|
|
103
|
-
|
|
104
|
-
**CRITICAL**: Inline ALL planning context into each agent prompt. `@` references don't work across Agent() boundaries.
|
|
105
|
-
|
|
106
|
-
#### Frontend Agent Prompt
|
|
111
|
+
| `full` | frontend + backend + perf-oracle (3 parallel), then arch-strategist (Wave 2) |
|
|
112
|
+
| `perf` | perf-oracle only |
|
|
113
|
+
| `ui` | frontend only |
|
|
114
|
+
| `backend` | backend only |
|
|
115
|
+
| `alignment` | alignment prompt only |
|
|
116
|
+
| `deepen` | arch-strategist only (skip Wave 1) |
|
|
107
117
|
|
|
108
|
-
|
|
109
|
-
Agent(
|
|
110
|
-
prompt="You are optimizing a project's frontend. Read the planning docs and codebase rules below, then analyze the actual code.
|
|
111
|
-
|
|
112
|
-
<planning>
|
|
113
|
-
{PROJECT.md content}
|
|
114
|
-
{REQUIREMENTS.md content}
|
|
115
|
-
{DESIGN.md content}
|
|
116
|
-
</planning>
|
|
117
|
-
|
|
118
|
-
<rules>
|
|
119
|
-
{rules/frontend.md content}
|
|
120
|
-
</rules>
|
|
121
|
-
|
|
122
|
-
<task>
|
|
123
|
-
Analyze the frontend codebase for issues in these categories:
|
|
124
|
-
|
|
125
|
-
1. **UI Quality**
|
|
126
|
-
- Loading states: every async operation should show a loading indicator
|
|
127
|
-
- Error states: every data-fetching component should handle errors gracefully
|
|
128
|
-
- Empty states: lists/tables should handle zero items with helpful messaging
|
|
129
|
-
- Responsive: check for fixed pixel widths on containers, missing breakpoint handling
|
|
130
|
-
- Accessibility: alt text on images, ARIA labels on interactive elements, keyboard navigation
|
|
131
|
-
|
|
132
|
-
2. **Design Alignment**
|
|
133
|
-
- Compare actual components against DESIGN.md decisions (colors, typography, spacing)
|
|
134
|
-
- Check rules/frontend.md compliance: distinctive fonts? sharp accents? transitions? No card grids or blue-purple gradients?
|
|
135
|
-
- Consistency: are the same patterns used throughout? (button styles, spacing, color usage)
|
|
136
|
-
|
|
137
|
-
3. **Frontend Performance**
|
|
138
|
-
- Bundle: large library imports that could be tree-shaken or dynamically imported
|
|
139
|
-
- Images: using next/image? width/height set? lazy loading below fold?
|
|
140
|
-
- Fonts: using next/font? No render-blocking font loads?
|
|
141
|
-
- CSS: unused Tailwind classes? conflicting styles?
|
|
142
|
-
- Rendering: unnecessary re-renders, missing React.memo on list items, heavy computations in render
|
|
143
|
-
|
|
144
|
-
For EVERY finding, output in this exact format:
|
|
145
|
-
- **What**: [description]
|
|
146
|
-
- **Where**: [file:line]
|
|
147
|
-
- **Why**: [impact on users/performance]
|
|
148
|
-
- **Fix**: [concrete fix suggestion]
|
|
149
|
-
- **Severity**: CRITICAL | HIGH | MEDIUM | LOW
|
|
150
|
-
</task>",
|
|
151
|
-
subagent_type="general-purpose",
|
|
152
|
-
description="Frontend optimization analysis"
|
|
153
|
-
)
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
#### Backend Agent Prompt
|
|
157
|
-
|
|
158
|
-
```
|
|
159
|
-
Agent(
|
|
160
|
-
prompt="You are optimizing a project's backend. Read the planning docs and security rules below, then analyze the actual code.
|
|
161
|
-
|
|
162
|
-
<planning>
|
|
163
|
-
{PROJECT.md content}
|
|
164
|
-
{REQUIREMENTS.md content}
|
|
165
|
-
</planning>
|
|
166
|
-
|
|
167
|
-
<rules>
|
|
168
|
-
{rules/security.md content}
|
|
169
|
-
</rules>
|
|
170
|
-
|
|
171
|
-
<task>
|
|
172
|
-
Analyze the backend codebase for issues:
|
|
173
|
-
|
|
174
|
-
1. **Security**
|
|
175
|
-
- RLS: every Supabase table must have ROW LEVEL SECURITY enabled with policies
|
|
176
|
-
- Service role: grep for service_role key usage in client-side code (app/, components/, src/) — should be ZERO
|
|
177
|
-
- Auth: all mutations use server-side auth check (supabase.auth.getUser())
|
|
178
|
-
- Validation: input validated with Zod before database operations
|
|
179
|
-
- No dangerouslySetInnerHTML or eval()
|
|
180
|
-
|
|
181
|
-
2. **Data Access Patterns**
|
|
182
|
-
- Server actions vs client mutations: data writes should use 'use server' actions, not direct Supabase client calls
|
|
183
|
-
- Proper error handling: try/catch with meaningful error messages
|
|
184
|
-
- Revalidation: revalidatePath/revalidateTag after mutations
|
|
185
|
-
|
|
186
|
-
3. **Edge Functions** (if supabase/functions/ exists)
|
|
187
|
-
- Cold start optimization: bundle size, dependency count
|
|
188
|
-
- Error handling and logging
|
|
189
|
-
- CORS configuration
|
|
190
|
-
- Timeout protection (maxDuration)
|
|
191
|
-
|
|
192
|
-
4. **API Quality**
|
|
193
|
-
- Rate limiting on public endpoints
|
|
194
|
-
- Proper HTTP status codes
|
|
195
|
-
- Consistent error response format
|
|
196
|
-
|
|
197
|
-
For EVERY finding, output:
|
|
198
|
-
- **What**: [description]
|
|
199
|
-
- **Where**: [file:line]
|
|
200
|
-
- **Why**: [impact]
|
|
201
|
-
- **Fix**: [concrete suggestion]
|
|
202
|
-
- **Severity**: CRITICAL | HIGH | MEDIUM | LOW
|
|
203
|
-
</task>",
|
|
204
|
-
subagent_type="general-purpose",
|
|
205
|
-
description="Backend optimization analysis"
|
|
206
|
-
)
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
#### Performance Oracle Prompt
|
|
118
|
+
**CRITICAL**: Inline ALL planning context into each prompt. `@` refs don't work across Agent() boundaries.
|
|
210
119
|
|
|
211
|
-
|
|
212
|
-
Agent(
|
|
213
|
-
prompt="You are analyzing cross-cutting performance issues. Read the project context, then analyze the codebase.
|
|
214
|
-
|
|
215
|
-
<planning>
|
|
216
|
-
{PROJECT.md content}
|
|
217
|
-
</planning>
|
|
218
|
-
|
|
219
|
-
<task>
|
|
220
|
-
Analyze for performance issues across the full stack:
|
|
221
|
-
|
|
222
|
-
1. **Database Queries**
|
|
223
|
-
- N+1 queries: Supabase .from() calls inside loops or .map()
|
|
224
|
-
- Missing indexes: .eq()/.filter()/.order() columns without corresponding indexes in migrations
|
|
225
|
-
- Sequential queries that could be parallel (Promise.all)
|
|
226
|
-
- Over-fetching: SELECT * when only specific columns needed
|
|
227
|
-
|
|
228
|
-
2. **API Latency**
|
|
229
|
-
- Sequential API calls from client that could be batched
|
|
230
|
-
- Missing caching (SWR/React Query stale times, HTTP cache headers)
|
|
231
|
-
- Large payloads without pagination
|
|
232
|
-
|
|
233
|
-
3. **Bundle Size**
|
|
234
|
-
- Barrel exports (index.ts re-exporting everything) preventing tree-shaking
|
|
235
|
-
- Large libraries imported for single functions (lodash, moment)
|
|
236
|
-
- Missing dynamic imports for heavy components (charts, editors, maps)
|
|
237
|
-
|
|
238
|
-
4. **Render Performance**
|
|
239
|
-
- Expensive computations in render path without useMemo
|
|
240
|
-
- Event handlers recreated on every render without useCallback
|
|
241
|
-
- Large lists without virtualization
|
|
242
|
-
- Context providers causing unnecessary re-renders
|
|
243
|
-
|
|
244
|
-
For EVERY finding, output:
|
|
245
|
-
- **What**: [description]
|
|
246
|
-
- **Where**: [file:line]
|
|
247
|
-
- **Why**: [performance impact, quantified if possible]
|
|
248
|
-
- **Fix**: [concrete suggestion]
|
|
249
|
-
- **Severity**: CRITICAL | HIGH | MEDIUM | LOW
|
|
250
|
-
</task>",
|
|
251
|
-
subagent_type="general-purpose",
|
|
252
|
-
description="Performance optimization analysis"
|
|
253
|
-
)
|
|
254
|
-
```
|
|
120
|
+
Spawn parallel: **frontend** (@REFERENCE.md "Frontend agent prompt"), **backend** (@REFERENCE.md "Backend agent prompt"), **perf oracle** (@REFERENCE.md "Performance oracle prompt").
|
|
255
121
|
|
|
256
|
-
### Step 5:
|
|
122
|
+
### Step 5: Wave 2 -- Architecture Strategist
|
|
257
123
|
|
|
258
|
-
|
|
124
|
+
`full`: after Wave 1 (synthesizes + deepens). `deepen`: sole agent (no Wave 1).
|
|
259
125
|
|
|
260
|
-
|
|
261
|
-
Agent(
|
|
262
|
-
prompt="You are synthesizing optimization findings from 3 specialist agents. Look for cross-cutting architectural issues.
|
|
263
|
-
|
|
264
|
-
<wave1_findings>
|
|
265
|
-
{All findings from frontend-agent, backend-agent, performance-oracle}
|
|
266
|
-
</wave1_findings>
|
|
267
|
-
|
|
268
|
-
<planning>
|
|
269
|
-
{PROJECT.md content}
|
|
270
|
-
{REQUIREMENTS.md content}
|
|
271
|
-
</planning>
|
|
272
|
-
|
|
273
|
-
<task>
|
|
274
|
-
1. Identify patterns across findings — recurring issues that point to a structural problem
|
|
275
|
-
2. Find coupling issues between frontend and backend
|
|
276
|
-
3. Check for inconsistent patterns (e.g., some routes use server actions, others use API routes)
|
|
277
|
-
4. Identify missing abstractions (same pattern repeated 3+ times)
|
|
278
|
-
5. Check for dead code and unused exports
|
|
279
|
-
|
|
280
|
-
Output:
|
|
281
|
-
- **Structural findings** (architectural issues, not covered by Wave 1)
|
|
282
|
-
- **Pattern consolidation** (where Wave 1 findings share a root cause)
|
|
283
|
-
- Each finding in the same format: What/Where/Why/Fix/Severity
|
|
284
|
-
</task>",
|
|
285
|
-
subagent_type="general-purpose",
|
|
286
|
-
description="Architecture synthesis"
|
|
287
|
-
)
|
|
288
|
-
```
|
|
126
|
+
Spawn **arch strategist** (@REFERENCE.md "Architecture strategist prompt (deepening lens)").
|
|
289
127
|
|
|
290
|
-
**Skip Wave 2 for single-mode
|
|
128
|
+
**Skip Wave 2 for single-mode** (`--perf`, `--ui`, `--backend`, `--alignment`). Run for `full` and `deepen`.
|
|
291
129
|
|
|
292
|
-
### Step 6: Alignment Check (
|
|
130
|
+
### Step 6: Alignment Check (`full` and `alignment` modes)
|
|
293
131
|
|
|
294
|
-
|
|
132
|
+
`alignment`: sole analysis. `full`: alongside Wave 1.
|
|
295
133
|
|
|
296
|
-
Read REQUIREMENTS.md
|
|
134
|
+
Read REQUIREMENTS.md + ROADMAP.md. Per req marked "Complete" or mapped to completed phase:
|
|
297
135
|
|
|
298
136
|
```bash
|
|
299
137
|
# Find completed requirements
|
|
300
138
|
grep -E "Complete|✓" .planning/REQUIREMENTS.md 2>/dev/null
|
|
301
139
|
```
|
|
302
140
|
|
|
303
|
-
|
|
304
|
-
- Grep
|
|
305
|
-
-
|
|
141
|
+
Per completed req:
|
|
142
|
+
- Grep for evidence (routes, components, endpoints)
|
|
143
|
+
- Not found: flag "Claimed complete but not implemented"
|
|
306
144
|
|
|
307
|
-
|
|
145
|
+
Orphan scan:
|
|
308
146
|
```bash
|
|
309
147
|
# Find all routes/pages
|
|
310
148
|
find app -name "page.tsx" -o -name "route.ts" 2>/dev/null
|
|
@@ -312,16 +150,15 @@ find app -name "page.tsx" -o -name "route.ts" 2>/dev/null
|
|
|
312
150
|
find app/api -name "route.ts" 2>/dev/null
|
|
313
151
|
```
|
|
314
152
|
|
|
315
|
-
Cross-
|
|
153
|
+
Cross-ref with REQUIREMENTS.md; route NOT in reqs: "Undocumented feature".
|
|
316
154
|
|
|
317
|
-
### Step 7: Collect and Score
|
|
155
|
+
### Step 7: Collect and Score
|
|
318
156
|
|
|
319
|
-
|
|
320
|
-
1. Deduplicate (same file:line
|
|
321
|
-
2. Sort
|
|
322
|
-
3. Group by dimension:
|
|
323
|
-
|
|
324
|
-
Count totals per severity.
|
|
157
|
+
All agents done:
|
|
158
|
+
1. Deduplicate (same file:line, keep most detailed)
|
|
159
|
+
2. Sort: CRITICAL first
|
|
160
|
+
3. Group by dimension: Perf, Design, UI, Backend, Frontend, Alignment, Architecture
|
|
161
|
+
4. Count per severity.
|
|
325
162
|
|
|
326
163
|
### Step 8: Write OPTIMIZE.md and Present Results
|
|
327
164
|
|
|
@@ -399,27 +236,25 @@ Run /qualia-optimize --fix to auto-fix LOW/MEDIUM findings.
|
|
|
399
236
|
|
|
400
237
|
### Step 9: --fix Mode
|
|
401
238
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
1. Read existing `.planning/OPTIMIZE.md` — if not found, error: "Run /qualia-optimize first"
|
|
405
|
-
2. Filter to LOW and MEDIUM findings only
|
|
406
|
-
3. For each finding with a clear, safe fix:
|
|
407
|
-
- Read the target file
|
|
408
|
-
- Apply the fix
|
|
409
|
-
- Verify it doesn't break (npx tsc --noEmit if TypeScript)
|
|
410
|
-
4. Update OPTIMIZE.md: mark fixed findings, recount severities
|
|
411
|
-
5. Commit changes
|
|
412
|
-
6. Report what was fixed and what remains
|
|
239
|
+
`--fix` mode:
|
|
413
240
|
|
|
414
|
-
|
|
241
|
+
1. Read `.planning/OPTIMIZE.md`; missing: "Run /qualia-optimize first"
|
|
242
|
+
2. Filter to LOW + MEDIUM only
|
|
243
|
+
3. Per finding with clear, safe fix:
|
|
244
|
+
- Read target file
|
|
245
|
+
- Apply fix
|
|
246
|
+
- Verify (npx tsc --noEmit if TS)
|
|
247
|
+
4. Update OPTIMIZE.md: mark fixed, recount severities
|
|
248
|
+
5. Commit
|
|
249
|
+
6. Report fixed vs remaining
|
|
415
250
|
|
|
416
|
-
|
|
251
|
+
**Never auto-fix CRITICAL/HIGH.** Require human judgment.
|
|
417
252
|
|
|
418
|
-
|
|
253
|
+
### Step 10: Gap Phase Creation (user picks option 1)
|
|
419
254
|
|
|
420
|
-
1. Read ROADMAP.md, find current phase
|
|
421
|
-
2. Insert
|
|
422
|
-
3. Map CRITICAL
|
|
255
|
+
1. Read ROADMAP.md, find current phase
|
|
256
|
+
2. Insert `Phase {N}.1: Optimization Fixes (INSERTED)`
|
|
257
|
+
3. Map CRITICAL + HIGH findings as success criteria
|
|
423
258
|
4. Update STATE.md
|
|
424
259
|
5. Commit
|
|
425
260
|
6. Suggest: "Fix phase created. Run `/qualia-plan {N}.1`"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: qualia-plan
|
|
3
|
-
description: "
|
|
3
|
+
description: "Plans the current phase by spawning a planner agent to break it into executable tasks with waves, then validates via a plan-checker revision loop (max 2 cycles). Supports gap-closure mode for verification failures. Use when the user says 'plan this phase', 'break this into tasks', 'create the plan', 'qualia-plan', 'plan phase 2', or after /qualia-new sets up the journey."
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- Bash
|
|
6
6
|
- Read
|
|
@@ -15,15 +15,15 @@ allowed-tools:
|
|
|
15
15
|
|
|
16
16
|
# /qualia-plan — Plan a Phase
|
|
17
17
|
|
|
18
|
-
Spawn
|
|
18
|
+
Spawn planner to break phase into tasks, validate with checker (max 2 revision cycles), route to build.
|
|
19
19
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
22
|
-
`/qualia-plan` — plan
|
|
22
|
+
`/qualia-plan` — plan next unplanned phase
|
|
23
23
|
`/qualia-plan {N}` — plan specific phase N
|
|
24
24
|
`/qualia-plan {N} --gaps` — plan fixes for verification failures
|
|
25
|
-
`/qualia-plan {N} --skip-check` — skip
|
|
26
|
-
`/qualia-plan {N} --auto` — plan +
|
|
25
|
+
`/qualia-plan {N} --skip-check` — skip plan-checker loop (not recommended)
|
|
26
|
+
`/qualia-plan {N} --auto` — plan + chain into `/qualia-build {N} --auto` (no human gate)
|
|
27
27
|
|
|
28
28
|
## Process
|
|
29
29
|
|
|
@@ -38,9 +38,9 @@ node ~/.claude/bin/knowledge.js load patterns
|
|
|
38
38
|
node ~/.claude/bin/knowledge.js load client
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
No phase number → current phase from STATE.md.
|
|
42
42
|
|
|
43
|
-
**
|
|
43
|
+
**Phase-specific context (if exists):**
|
|
44
44
|
```bash
|
|
45
45
|
cat .planning/phase-{N}-context.md 2>/dev/null # from /qualia-discuss
|
|
46
46
|
cat .planning/phase-{N}-research.md 2>/dev/null # from /qualia-research
|
|
@@ -48,19 +48,17 @@ cat .planning/phase-{N}-research.md 2>/dev/null # from /qualia-research
|
|
|
48
48
|
|
|
49
49
|
### 2. Optional: Suggest Deeper Prep
|
|
50
50
|
|
|
51
|
-
**If ROADMAP.md
|
|
51
|
+
**If ROADMAP.md flagged phase for research AND no phase-{N}-research.md:**
|
|
52
52
|
|
|
53
53
|
- header: "Research first?"
|
|
54
|
-
- question: "
|
|
54
|
+
- question: "Phase flagged for research. Run /qualia-research {N} first?"
|
|
55
55
|
- options:
|
|
56
|
-
- "Yes, research first"
|
|
57
|
-
- "Skip, plan directly"
|
|
56
|
+
- "Yes, research first"
|
|
57
|
+
- "Skip, plan directly"
|
|
58
58
|
|
|
59
|
-
**If phase
|
|
59
|
+
**If phase has compliance/regulatory/architectural stakes AND no phase-{N}-context.md:**
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Don't force it. Some phases don't need it.
|
|
61
|
+
Suggest: *"Run /qualia-discuss {N} first to lock decisions? Optional."*
|
|
64
62
|
|
|
65
63
|
### 3. Spawn Planner (Fresh Context)
|
|
66
64
|
|
|
@@ -69,12 +67,9 @@ node ~/.claude/bin/qualia-ui.js banner plan {N} "{phase name from ROADMAP.md}"
|
|
|
69
67
|
node ~/.claude/bin/qualia-ui.js spawn planner "Breaking phase into tasks..."
|
|
70
68
|
```
|
|
71
69
|
|
|
72
|
-
Spawn the planner:
|
|
73
|
-
|
|
74
70
|
```
|
|
75
71
|
Agent(prompt="
|
|
76
|
-
|
|
77
|
-
Grounding + rubrics: @~/.claude/rules/grounding.md
|
|
72
|
+
Role: @~/.claude/agents/planner.md
|
|
78
73
|
|
|
79
74
|
<project_context>
|
|
80
75
|
@.planning/PROJECT.md
|
|
@@ -89,86 +84,84 @@ Phase {N} from ROADMAP.md:
|
|
|
89
84
|
@.planning/ROADMAP.md
|
|
90
85
|
|
|
91
86
|
Goal: {goal from ROADMAP.md}
|
|
92
|
-
|
|
87
|
+
Reqs: {REQ-IDs from ROADMAP.md}
|
|
93
88
|
Success criteria: {success criteria from ROADMAP.md}
|
|
94
89
|
</phase_details>
|
|
95
90
|
|
|
96
91
|
<locked_decisions>
|
|
97
|
-
{
|
|
92
|
+
{phase-{N}-context.md Locked Decisions if exists, else 'none'}
|
|
98
93
|
</locked_decisions>
|
|
99
94
|
|
|
100
95
|
<research_findings>
|
|
101
|
-
{
|
|
96
|
+
{phase-{N}-research.md recommendation if exists, else 'none'}
|
|
102
97
|
</research_findings>
|
|
103
98
|
|
|
104
|
-
{
|
|
99
|
+
{--gaps → read @.planning/phase-{N}-verification.md failures. Create gap-closure plan.}
|
|
105
100
|
|
|
106
101
|
<relevant_learnings>
|
|
107
|
-
{
|
|
102
|
+
{applicable patterns from knowledge/learned-patterns.md}
|
|
108
103
|
</relevant_learnings>
|
|
109
104
|
|
|
110
|
-
|
|
105
|
+
Output: .planning/phase-{N}-plan.md (or phase-{N}-gaps-plan.md for --gaps).
|
|
111
106
|
", subagent_type="qualia-planner", description="Plan phase {N}")
|
|
112
107
|
```
|
|
113
108
|
|
|
114
|
-
### 4. Validate
|
|
109
|
+
### 4. Validate Plan (unless --skip-check)
|
|
115
110
|
|
|
116
|
-
Read
|
|
111
|
+
Read generated plan. Spawn checker:
|
|
117
112
|
|
|
118
113
|
```
|
|
119
114
|
Agent(prompt="
|
|
120
|
-
|
|
121
|
-
Grounding + rubrics: @~/.claude/rules/grounding.md
|
|
115
|
+
Role: @~/.claude/agents/plan-checker.md
|
|
122
116
|
|
|
123
117
|
<plan_path>.planning/phase-{N}-plan.md</plan_path>
|
|
124
118
|
<phase_goal>{goal from ROADMAP.md}</phase_goal>
|
|
125
119
|
<success_criteria>{criteria from ROADMAP.md}</success_criteria>
|
|
126
120
|
<project_context>@.planning/PROJECT.md</project_context>
|
|
127
121
|
|
|
128
|
-
Validate against
|
|
122
|
+
Validate against 7 rules. Return PASS or REVISE with structured issues.
|
|
129
123
|
", subagent_type="qualia-plan-checker", description="Check plan phase {N}")
|
|
130
124
|
```
|
|
131
125
|
|
|
132
|
-
**Revision loop (max 2
|
|
126
|
+
**Revision loop (max 2):**
|
|
133
127
|
|
|
134
|
-
-
|
|
135
|
-
-
|
|
128
|
+
- Iter 1: Check → REVISE → re-spawn planner with checker issues
|
|
129
|
+
- Iter 2: Re-check → REVISE/BLOCKED → escalate to user
|
|
136
130
|
|
|
137
|
-
|
|
131
|
+
(74→86% after 1 round, 88% after 3. Iter 3 adds only 2pp; not worth extra spawn.)
|
|
138
132
|
|
|
139
|
-
|
|
133
|
+
Per revision:
|
|
140
134
|
|
|
141
135
|
```
|
|
142
136
|
Agent(prompt="
|
|
143
|
-
|
|
137
|
+
Role: @~/.claude/agents/planner.md
|
|
144
138
|
|
|
145
139
|
<revision_mode>true</revision_mode>
|
|
146
140
|
<current_plan>@.planning/phase-{N}-plan.md</current_plan>
|
|
147
141
|
<checker_feedback>
|
|
148
|
-
{
|
|
142
|
+
{REVISE output from plan-checker}
|
|
149
143
|
</checker_feedback>
|
|
150
144
|
|
|
151
|
-
Revise
|
|
152
|
-
— only fix what the checker flagged.
|
|
145
|
+
Revise in place. Address every issue. Do NOT add tasks or change scope; fix only what checker flagged.
|
|
153
146
|
", subagent_type="qualia-planner", description="Revise plan phase {N}")
|
|
154
147
|
```
|
|
155
148
|
|
|
156
|
-
After revision, spawn
|
|
149
|
+
After revision, re-spawn checker. Max 2 total cycles.
|
|
157
150
|
|
|
158
|
-
**
|
|
151
|
+
**BLOCKED after 2 cycles:**
|
|
159
152
|
|
|
160
153
|
```bash
|
|
161
154
|
node ~/.claude/bin/qualia-ui.js fail "Plan failed validation after 2 revisions"
|
|
162
155
|
```
|
|
163
156
|
|
|
164
|
-
Show
|
|
165
|
-
- "Skip validation
|
|
166
|
-
- "Adjust
|
|
167
|
-
- "Adjust
|
|
157
|
+
Show remaining issues. Options:
|
|
158
|
+
- "Skip validation" (`--skip-check`)
|
|
159
|
+
- "Adjust roadmap" (scope wrong)
|
|
160
|
+
- "Adjust phase goal" (criteria under-specified)
|
|
168
161
|
|
|
169
162
|
### 5. Present Final Plan
|
|
170
163
|
|
|
171
|
-
Render
|
|
164
|
+
Render story-file dashboard:
|
|
172
165
|
|
|
173
166
|
```bash
|
|
174
167
|
node ~/.claude/bin/qualia-ui.js plan-summary .planning/phase-{N}-plan.md
|
|
@@ -184,19 +177,19 @@ If "adjust" — get feedback, re-spawn planner with revision context, re-validat
|
|
|
184
177
|
node ~/.claude/bin/state.js transition --to planned --phase {N}
|
|
185
178
|
```
|
|
186
179
|
|
|
187
|
-
|
|
180
|
+
Error → show, stop. Do NOT edit STATE.md or tracking.json manually.
|
|
188
181
|
|
|
189
182
|
### 7. Route (auto-chain aware)
|
|
190
183
|
|
|
191
|
-
|
|
184
|
+
**`--auto`:** invoke `/qualia-build {N} --auto` inline. User approved at `/qualia-new`; no per-phase gate.
|
|
192
185
|
|
|
193
186
|
```bash
|
|
194
187
|
node ~/.claude/bin/qualia-ui.js info "Auto mode — chaining into /qualia-build {N}"
|
|
195
188
|
```
|
|
196
189
|
|
|
197
|
-
Then invoke
|
|
190
|
+
Then invoke `qualia-build` inline with `--auto`.
|
|
198
191
|
|
|
199
|
-
**
|
|
192
|
+
**Guided mode:** stop, show next step:
|
|
200
193
|
|
|
201
194
|
```bash
|
|
202
195
|
node ~/.claude/bin/qualia-ui.js end "PHASE {N} PLANNED" "/qualia-build {N}"
|
|
@@ -204,22 +197,22 @@ node ~/.claude/bin/qualia-ui.js end "PHASE {N} PLANNED" "/qualia-build {N}"
|
|
|
204
197
|
|
|
205
198
|
## Gap Closure Mode (`--gaps`)
|
|
206
199
|
|
|
207
|
-
|
|
200
|
+
With `--gaps`, planner enters gap-closure mode:
|
|
208
201
|
|
|
209
|
-
1. Read `.planning/phase-{N}-verification.md`
|
|
210
|
-
2.
|
|
211
|
-
- **Files:** specific files that failed
|
|
212
|
-
- **Action:** specific fix (not "fix auth"
|
|
213
|
-
- **
|
|
214
|
-
3. Do NOT re-plan passing items.
|
|
215
|
-
4.
|
|
216
|
-
5. All gap tasks
|
|
217
|
-
6. Plan-checker still validates
|
|
202
|
+
1. Read `.planning/phase-{N}-verification.md` → extract ONLY FAIL items
|
|
203
|
+
2. Per FAIL, create targeted fix task:
|
|
204
|
+
- **Files:** specific files that failed
|
|
205
|
+
- **Action:** specific fix (not "fix auth"; "add session persistence check in src/lib/auth.ts signIn fn")
|
|
206
|
+
- **AC:** failed criterion restated as observable behavior
|
|
207
|
+
3. Do NOT re-plan passing items. No new features. Surgical only.
|
|
208
|
+
4. Output: `.planning/phase-{N}-gaps-plan.md`
|
|
209
|
+
5. All gap tasks Wave 1 (parallel) unless they share files
|
|
210
|
+
6. Plan-checker still validates; same 7 rules
|
|
218
211
|
|
|
219
212
|
## Rules
|
|
220
213
|
|
|
221
|
-
1. **Plan-checker
|
|
222
|
-
2. **Max 3 revision cycles.**
|
|
223
|
-
3. **Honor locked decisions.**
|
|
224
|
-
4. **One plan file per phase.**
|
|
225
|
-
5. **Revision is surgical.**
|
|
214
|
+
1. **Plan-checker mandatory by default.** Skip only with `--skip-check`.
|
|
215
|
+
2. **Max 3 revision cycles.** 3 fails → escalate; scope probably wrong.
|
|
216
|
+
3. **Honor locked decisions.** phase-{N}-context.md locked decisions non-negotiable.
|
|
217
|
+
4. **One plan file per phase.** No phase-1-plan-v2.md. Edit in place.
|
|
218
|
+
5. **Revision is surgical.** Fix only what checker flagged; no scope creep.
|