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.
Files changed (66) hide show
  1. package/AGENTS.md +24 -0
  2. package/CLAUDE.md +12 -75
  3. package/README.md +23 -16
  4. package/agents/builder.md +9 -21
  5. package/agents/planner.md +8 -0
  6. package/agents/verifier.md +8 -0
  7. package/agents/visual-evaluator.md +132 -0
  8. package/bin/cli.js +54 -18
  9. package/bin/install.js +369 -29
  10. package/bin/qualia-ui.js +208 -1
  11. package/bin/slop-detect.mjs +5 -0
  12. package/bin/state.js +34 -1
  13. package/docs/install-redesign-builder-prompt.md +290 -0
  14. package/docs/install-redesign-pilot.md +234 -0
  15. package/docs/playwright-loop-builder-prompt.md +185 -0
  16. package/docs/playwright-loop-design-notes.md +108 -0
  17. package/docs/playwright-loop-pilot-results.md +170 -0
  18. package/docs/playwright-loop-tester-prompt.md +213 -0
  19. package/docs/polish-loop-supervised-run.md +111 -0
  20. package/docs/reviews/matt-pocock-skills-analysis.md +300 -0
  21. package/guide.md +9 -5
  22. package/hooks/env-empty-guard.js +74 -0
  23. package/hooks/pre-compact.js +19 -9
  24. package/hooks/pre-deploy-gate.js +8 -2
  25. package/hooks/pre-push.js +26 -12
  26. package/hooks/supabase-destructive-guard.js +62 -0
  27. package/hooks/vercel-account-guard.js +91 -0
  28. package/package.json +2 -1
  29. package/rules/design-brand.md +4 -0
  30. package/rules/design-laws.md +4 -0
  31. package/rules/design-product.md +4 -0
  32. package/rules/design-rubric.md +4 -0
  33. package/rules/grounding.md +4 -0
  34. package/skills/qualia-build/SKILL.md +40 -46
  35. package/skills/qualia-discuss/SKILL.md +51 -68
  36. package/skills/qualia-handoff/SKILL.md +1 -0
  37. package/skills/qualia-hook-gen/SKILL.md +206 -0
  38. package/skills/qualia-issues/SKILL.md +151 -0
  39. package/skills/qualia-map/SKILL.md +78 -35
  40. package/skills/qualia-new/REFERENCE.md +139 -0
  41. package/skills/qualia-new/SKILL.md +45 -121
  42. package/skills/qualia-optimize/REFERENCE.md +265 -0
  43. package/skills/qualia-optimize/SKILL.md +92 -232
  44. package/skills/qualia-plan/SKILL.md +58 -65
  45. package/skills/qualia-polish-loop/REFERENCE.md +265 -0
  46. package/skills/qualia-polish-loop/SKILL.md +201 -0
  47. package/skills/qualia-polish-loop/fixtures/broken.html +117 -0
  48. package/skills/qualia-polish-loop/fixtures/clean.html +196 -0
  49. package/skills/qualia-polish-loop/scripts/loop.mjs +323 -0
  50. package/skills/qualia-polish-loop/scripts/playwright-capture.mjs +206 -0
  51. package/skills/qualia-polish-loop/scripts/score.mjs +176 -0
  52. package/skills/qualia-prd/SKILL.md +199 -0
  53. package/skills/qualia-report/SKILL.md +141 -200
  54. package/skills/qualia-research/SKILL.md +28 -33
  55. package/skills/qualia-road/SKILL.md +103 -0
  56. package/skills/qualia-ship/SKILL.md +1 -0
  57. package/skills/qualia-task/SKILL.md +1 -1
  58. package/skills/qualia-test/SKILL.md +50 -2
  59. package/skills/qualia-triage/SKILL.md +152 -0
  60. package/skills/qualia-verify/SKILL.md +63 -104
  61. package/skills/qualia-zoom/SKILL.md +51 -0
  62. package/skills/zoho-workflow/SKILL.md +1 -1
  63. package/templates/CONTEXT.md +36 -0
  64. package/templates/decisions/ADR-template.md +30 -0
  65. package/tests/bin.test.sh +598 -7
  66. package/tests/state.test.sh +58 -0
@@ -0,0 +1,103 @@
1
+ ---
2
+ name: qualia-road
3
+ description: "Show the Qualia workflow map in the terminal — Project → Journey → Milestones → Phases → Tasks. Lists every command, when to use it, and how phases chain. Use when user asks 'how does Qualia work', 'what's the workflow', 'show me the road', 'what command does X', 'how do projects flow', or is new to the framework. (For an interactive HTML reference instead, use /qualia-help.)"
4
+ disable-model-invocation: true
5
+ allowed-tools:
6
+ - Read
7
+ ---
8
+
9
+ # The Qualia Road — Project Workflow Map
10
+
11
+ **Hierarchy:** Project → Journey → Milestones (2–5, Handoff always last) → Phases (2–5 tasks each) → Tasks (one commit, one verification contract).
12
+
13
+ ```
14
+ /qualia-new → kickoff + parallel research + JOURNEY.md (all milestones upfront)
15
+ add --auto to chain the whole road end-to-end
16
+
17
+ For each milestone, for each phase:
18
+ /qualia-plan → plan the phase (planner + plan-checker revision loop, fresh context)
19
+ /qualia-build → build it (builder subagents per task, wave-based parallel)
20
+ /qualia-verify → goal-backward check (verifier agent, fresh context)
21
+
22
+ /qualia-milestone → close milestone, archive artifacts, prep next (human gate)
23
+ ↓ (repeat for each milestone until Handoff)
24
+
25
+ Final milestone = Handoff:
26
+ /qualia-polish → final design pass (whole app)
27
+ (content + SEO) → Phase 2
28
+ (final QA) → Phase 3
29
+ /qualia-ship → deploy to production (quality gates → deploy → verify)
30
+ /qualia-handoff → 4 deliverables: credentials, doc, final update, report
31
+
32
+ Done.
33
+ ```
34
+
35
+ ## Design as a thread (v4.5.0+)
36
+ Every road agent loads `PRODUCT.md + DESIGN.md + design-laws.md` substrate. Builders run `slop-detect` on every frontend commit. Verifiers score 8 design dimensions per phase.
37
+
38
+ ## /qualia-polish is scope-adaptive
39
+ ```
40
+ /qualia-polish src/components/Button.tsx ~30s component touch-up
41
+ /qualia-polish app/dashboard ~3m section pass
42
+ /qualia-polish ~12m whole app, fan-out
43
+ /qualia-polish --redesign ~30m ground-up redesign
44
+ /qualia-polish --critique read-only scored audit
45
+ /qualia-polish --quick ~1m gates only
46
+ ```
47
+
48
+ ## /qualia-polish-loop -- autonomous visual QA (v5.1+)
49
+ ```
50
+ /qualia-polish-loop http://localhost:3000 screenshot + eval + fix loop
51
+ /qualia-polish-loop {url} --max 4 cap iterations
52
+ /qualia-polish-loop {url} --ref design.png anchor to reference image
53
+ ```
54
+ Screenshots at 3 viewports (375/768/1440), scores 8 design dimensions using vision, fixes issues, re-screenshots, loops until all dims >= 3 or kill-switch triggers. Per-iteration git commits for clean revert.
55
+
56
+ ## Alignment substrate (v5.0+)
57
+ Before high-stakes phases, run alignment skills against `.planning/CONTEXT.md` (domain glossary) and `.planning/decisions/` (ADRs):
58
+
59
+ ```
60
+ /qualia-discuss → relentless one-question interview, updates CONTEXT.md inline
61
+ /qualia-zoom → map an unfamiliar code area using glossary terms
62
+ /qualia-optimize --deepen → find shallow modules, propose Ousterhout-style refactors
63
+ /qualia-test --tdd → vertical-slice red→green→refactor for one feature
64
+ /qualia-issues → break a phase plan into independent GH issues
65
+ /qualia-triage → label + route open issues (ready-for-agent vs human)
66
+ /qualia-map → adapt Qualia to an existing brownfield repo's conventions (5th onboarding agent)
67
+ ```
68
+
69
+ ## Auxiliary commands
70
+ ```
71
+ Lost? → /qualia (state router — tells you the next command)
72
+ Stuck/weird? → /qualia-idk (diagnostic — spawns plan-view + code-view agents in parallel)
73
+ Quick fix? → /qualia-quick (skip planning for small tasks)
74
+ Paused? → /qualia-resume (restore from .continue-here.md or STATE.md)
75
+ End of day? → /qualia-report (mandatory before clock-out; writes ERP payload)
76
+ Debug bug? → /qualia-debug (feedback-loop-first investigation)
77
+ Unsure plan? → /qualia-discuss (capture decisions before planning)
78
+ ```
79
+
80
+ ## Human gates
81
+ Journey approval after `/qualia-new`, then one at each milestone boundary via `/qualia-milestone`. `--auto` runs everything between gates automatically.
82
+
83
+ ## Context isolation
84
+ Every task runs in a fresh subagent context. Task 50 gets the same quality as Task 1.
85
+ - Planner gets: PROJECT.md + CONTEXT.md + phase requirements
86
+ - Builder gets: single task from plan + PROJECT.md + CONTEXT.md
87
+ - Verifier gets: success criteria + codebase access
88
+
89
+ No accumulated garbage. No context rot.
90
+
91
+ ## Quality gates (always active via hooks)
92
+ - **Frontend guard** — Read `.planning/DESIGN.md` before any frontend changes
93
+ - **Deploy guard** — tsc + lint + build + tests must pass before deploy
94
+ - **Migration guard** — Catches dangerous SQL (DROP without IF EXISTS, DELETE without WHERE, CREATE TABLE without RLS)
95
+ - **Slop-detect** — Em-dash and AI-tells check on every UI commit
96
+ - **Intent verification** — Confirm before modifying 3+ files (OWNER role: just do it)
97
+
98
+ ## Tracking
99
+ `.planning/tracking.json` is updated on every push. The ERP reads it via git.
100
+ Never edit tracking.json manually — hooks update it from STATE.md.
101
+
102
+ ## Compaction — ALWAYS preserve
103
+ Project path/name, branch, current phase, modified files, decisions, test results, in-progress work, errors, tracking.json state.
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  name: qualia-ship
3
+ disable-model-invocation: true
3
4
  description: "Deploy to production — state-guard, full security scan, quality gates, commit, push, deploy, verify. Trigger on 'deploy', 'ship it', 'go live', 'push to prod', 'launch', 'release to production'."
4
5
  allowed-tools:
5
6
  - Bash
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: qualia-task
3
- description: "Build a single task more structured than /qualia-quick, lighter than /qualia-build. Spawns a fresh builder agent for one focused task."
3
+ description: "Builds a single focused task in a fresh builder context with atomic commit and validation. More structured than /qualia-quick, lighter than /qualia-build (no phase plan needed). Use when the user says 'build this one thing', 'add a component', 'implement this feature', 'qualia-task', or for any 1-5 file change outside a full phase."
4
4
  allowed-tools:
5
5
  - Bash
6
6
  - Read
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: qualia-test
3
- description: "Generate or run tests for client projects. Trigger on 'write tests', 'add tests', 'test this', 'run tests', 'test coverage', 'need tests for'."
3
+ description: "Generate tests for existing code, run tests, OR drive a feature test-first via --tdd vertical-slice loop (red→green→refactor, one test→one impl→repeat). Trigger on 'write tests', 'add tests', 'test this', 'run tests', 'test coverage', 'need tests for', 'tdd this', 'test-driven', 'red green refactor'."
4
4
  allowed-tools:
5
5
  - Bash
6
6
  - Read
@@ -20,6 +20,7 @@ Generate tests for client project code. Detect framework, classify targets, writ
20
20
  - `/qualia-test {file}` — Generate tests for a specific file
21
21
  - `/qualia-test --run` — Run existing tests and report
22
22
  - `/qualia-test --coverage` — Run with coverage report
23
+ - `/qualia-test --tdd "{feature description}"` — Drive the feature test-first via vertical-slice loop
23
24
 
24
25
  ## Process
25
26
 
@@ -132,7 +133,54 @@ git add {test files}
132
133
  git commit -m "test: add tests for {files}"
133
134
  ```
134
135
 
135
- ## Rules
136
+ ## --tdd mode (vertical-slice red→green→refactor)
137
+
138
+ When `--tdd "{feature}"` is passed, run this loop instead of the after-the-fact generator. Stops the user from accumulating untested code.
139
+
140
+ ### The non-negotiable rules
141
+
142
+ 1. **Vertical slices only.** ANTI-PATTERN: write all tests first, then all implementation. Correct: one test → one minimal implementation → repeat.
143
+
144
+ ```
145
+ WRONG (horizontal): RED test1-5 → GREEN impl1-5
146
+ RIGHT (vertical): RED→GREEN test1→impl1, then test2→impl2, ...
147
+ ```
148
+
149
+ 2. **Test through the public interface only.** If the test reaches into private state, the test will die on the first refactor. Test what callers see.
150
+ 3. **Only enough code to pass the current test.** No speculative features. No "while we're here." Resist scope creep — the next test will demand it if it's needed.
151
+ 4. **Never refactor while red.** Green first. THEN refactor (with tests still green as the safety net).
152
+ 5. **Each cycle is a commit.** `test: {behavior}` for the red, `feat: {minimal impl}` for the green. Tiny commits = revertable units.
153
+
154
+ ### Loop
155
+
156
+ #### Phase 1 — Plan the slices
157
+ 1. Read `.planning/CONTEXT.md` if it exists — use domain glossary terms in test names
158
+ 2. Decompose `"{feature}"` into the smallest vertical slices that each deliver an observable behavior
159
+ 3. Show the slice list to the user. Get approval before writing the first test.
160
+
161
+ #### Phase 2 — Tracer bullet (slice 1)
162
+ 1. **RED**: write ONE test against the public interface that the feature would expose. Run it — it must fail (no implementation yet)
163
+ 2. **GREEN**: write the MINIMUM code to make it pass. Run all tests — green
164
+ 3. **COMMIT**: `git commit -m "test+feat({slug}): {slice 1 behavior}"`
165
+
166
+ #### Phase 3 — Incremental loop
167
+ For each remaining slice:
168
+ 1. **RED**: one test, one behavior, fails
169
+ 2. **GREEN**: minimal code, all tests pass
170
+ 3. **REFACTOR** (only if tests still green): extract duplication, apply SOLID where the code asks for it, run tests after each step
171
+ 4. **COMMIT**
172
+
173
+ #### Phase 4 — Per-cycle checklist (run on every slice)
174
+ - [ ] Test describes a behavior, not an implementation detail
175
+ - [ ] Test uses only the public interface
176
+ - [ ] Test would survive a reasonable internal refactor
177
+ - [ ] Implementation is minimal — no speculative features
178
+ - [ ] Test name reads as a sentence
179
+
180
+ #### Phase 5 — Hand off
181
+ When all slices are green, suggest: `/qualia-verify {N}` (if part of a phase) or `/qualia-optimize --deepen` (if the implementation accumulated shallow modules during the loop).
182
+
183
+ ## Rules (apply to all modes)
136
184
 
137
185
  1. **Test behavior, not implementation.** Don't test internal state — test what the user/caller sees.
138
186
  2. **No snapshot tests.** They're brittle and meaningless.
@@ -0,0 +1,152 @@
1
+ ---
2
+ name: qualia-triage
3
+ description: "State machine over open GH issues — labels each as needs-triage, needs-info, ready-for-agent, ready-for-human, or wontfix. Optionally routes ready-for-agent issues into an autonomous /qualia-build run. Pairs with /qualia-issues to enable the autonomous Ralph-Wiggum loop where agents pull work from the queue without human-in-loop. Use when user says 'triage', 'qualia-triage', 'route the queue', 'pull next from backlog', 'what's ready for the agent'. Hard dependency: requires .planning/agents/labels.md — run /qualia-map first if missing."
4
+ allowed-tools:
5
+ - Bash
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Grep
10
+ - Glob
11
+ - AskUserQuestion
12
+ ---
13
+
14
+ # /qualia-triage — Issue Queue State Machine
15
+
16
+ Walks the open issue queue, applies state labels, optionally routes `ready-for-agent` issues into autonomous build runs.
17
+
18
+ ## The state machine
19
+
20
+ Every issue carries exactly one **category** label and exactly one **state** label.
21
+
22
+ **Category labels** (mutually exclusive):
23
+ - `bug` — something is broken
24
+ - `enhancement` — new feature or improvement
25
+
26
+ **State labels** (exactly one per issue):
27
+ - `needs-triage` — initial state, awaiting maintainer evaluation
28
+ - `needs-info` — clarification needed from reporter
29
+ - `ready-for-agent` — fully specified, autonomous build can pull this
30
+ - `ready-for-human` — requires human implementation (judgment, sensitive area, scope unclear)
31
+ - `wontfix` — rejected
32
+
33
+ **Flow:**
34
+
35
+ ```
36
+ unlabeled → needs-triage → ┬→ needs-info → (response) → needs-triage
37
+ ├→ ready-for-agent → (autonomous build) → closed
38
+ ├→ ready-for-human → (human picks up) → closed
39
+ └→ wontfix → closed
40
+ ```
41
+
42
+ ## Hard dependencies
43
+
44
+ This skill cannot work meaningfully without:
45
+ - `.planning/agents/labels.md` — canonical-role-to-existing-label mapping
46
+ - `.planning/agents/tracker.md` — tells it where the queue lives
47
+ - `gh` CLI authenticated (if tracker is GitHub)
48
+
49
+ If missing, halt: "Run `/qualia-map` first to scan your repo and write the adapter config."
50
+
51
+ ## Process
52
+
53
+ ### 1. Load substrate
54
+
55
+ ```bash
56
+ cat .planning/agents/labels.md
57
+ cat .planning/agents/tracker.md
58
+ cat .planning/CONTEXT.md 2>/dev/null
59
+ ```
60
+
61
+ If labels are missing in the tracker, create them per the canonical mapping.
62
+
63
+ ### 2. List the queue
64
+
65
+ ```bash
66
+ gh issue list --state open --limit 50 --json number,title,body,labels --jq '.'
67
+ ```
68
+
69
+ ### 3. Classify each unlabeled / needs-triage issue
70
+
71
+ For each issue:
72
+
73
+ **Read the body. Then assign one state per these criteria:**
74
+
75
+ | State | Criteria |
76
+ |---|---|
77
+ | `ready-for-agent` | Acceptance criteria are explicit + observable. Touches files Qualia knows. No business-judgment calls. No security-sensitive areas without explicit ADR backing. |
78
+ | `ready-for-human` | Requires judgment Qualia shouldn't make. Touches security/auth/payments without ADR. Scope is fuzzy. Risk is high. |
79
+ | `needs-info` | Reporter left out reproduction steps, expected behavior, or scope is too vague to act on. |
80
+ | `wontfix` | Out of project scope per PROJECT.md. Already implemented. Duplicate of #N. Conflicts with locked ADR. |
81
+
82
+ For each issue, also assign category (`bug` if behavior is broken vs spec, `enhancement` otherwise).
83
+
84
+ ### 4. Apply labels
85
+
86
+ ```bash
87
+ gh issue edit {N} --add-label "{state},{category}" --remove-label "needs-triage"
88
+ ```
89
+
90
+ For `needs-info`, also post a comment with the specific questions. Use `--body-file` (never heredoc-interpolate) — issue text is user-controlled and could contain shell metacharacters or a rogue `EOF`:
91
+
92
+ ```bash
93
+ COMMENT_FILE=$(mktemp -t qualia-triage.XXXXXX.md)
94
+ cat > "$COMMENT_FILE" <<EOF_TEMPLATE
95
+ Need a few more details to triage this:
96
+
97
+ 1. {specific question 1}
98
+ 2. {specific question 2}
99
+
100
+ Once these are answered I'll re-triage.
101
+ EOF_TEMPLATE
102
+
103
+ gh issue comment {N} --body-file "$COMMENT_FILE"
104
+ rm -f "$COMMENT_FILE"
105
+ ```
106
+
107
+ ### 5. Show the queue snapshot
108
+
109
+ ```
110
+ Triaged {N} issues:
111
+
112
+ ready-for-agent: {count} ─ #123, #124, #126
113
+ ready-for-human: {count} ─ #125, #127
114
+ needs-info: {count} ─ #128
115
+ wontfix: {count} ─ #129
116
+ ```
117
+
118
+ ### 6. Optional autonomous loop
119
+
120
+ ```
121
+ {N} issues ready-for-agent. Pull the next one into autonomous build?
122
+ ```
123
+
124
+ `AskUserQuestion`:
125
+ - header: "Auto-pull?"
126
+ - question: "Pull #{first ready-for-agent} into autonomous /qualia-build?"
127
+ - options:
128
+ - "Pull it" — feed the issue into a fresh /qualia-build run, then re-triage when done
129
+ - "Pause" — stop here, user picks up manually
130
+
131
+ If "Pull it":
132
+ 1. Read the issue body fully
133
+ 2. Spawn `/qualia-build` with the issue body as task input
134
+ 3. After build completes and verifies green, comment the closing PR/commit on the issue and `gh issue close {N}`
135
+ 4. Loop back to step 6 (next ready-for-agent issue)
136
+
137
+ The loop continues until the queue empties or the user pauses.
138
+
139
+ ### 7. Final report
140
+
141
+ ```bash
142
+ node ~/.claude/bin/qualia-ui.js end "QUEUE TRIAGED" "/qualia or /qualia-build {next}"
143
+ ```
144
+
145
+ ## Rules
146
+
147
+ 1. **One category, one state — always.** No issue without both labels (after triage). No issue with two of either.
148
+ 2. **`ready-for-agent` is conservative.** When in doubt, `ready-for-human`. Wrong agent-pull is more expensive than a human picking it up.
149
+ 3. **`needs-info` posts a comment.** Don't just label and walk away — the reporter must know what's blocking.
150
+ 4. **`wontfix` cites a reason.** Body or comment must say WHY (out of scope per PROJECT.md, conflicts with ADR-NNNN, duplicate of #N).
151
+ 5. **Autonomous loop is opt-in per session.** Don't auto-loop without the user pressing "Pull it" each cycle (until they explicitly ask for a continuous run).
152
+ 6. **Re-triage on response.** When `needs-info` issues get a reply, they return to `needs-triage` for re-evaluation.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: qualia-verify
3
- description: "Goal-backward verification checks if the phase ACTUALLY works, not just if tasks completed. Spawns verifier agent."
3
+ description: "Goal-backward verification of a built phase. Spawns a fresh verifier agent that greps the actual codebase against acceptance criteria, scores the design rubric, and optionally runs an adversarial second pass. Use when the user says 'verify this phase', 'check if it works', 'run verification', 'did the build pass', 'qualia-verify', or after /qualia-build completes."
4
4
  allowed-tools:
5
5
  - Bash
6
6
  - Read
@@ -13,13 +13,13 @@ allowed-tools:
13
13
 
14
14
  # /qualia-verify — Verify a Phase
15
15
 
16
- Spawn a verifier agent to check if the phase goal was achieved. Does NOT trust build summaries greps the actual codebase.
16
+ Spawn verifier to check phase goal. Does NOT trust build summaries; greps codebase.
17
17
 
18
18
  ## Usage
19
- `/qualia-verify` — verify the current built phase
19
+ `/qualia-verify` — verify current built phase
20
20
  `/qualia-verify {N}` — verify specific phase
21
- `/qualia-verify {N} --auto` — verify + auto-chain: PASS → next phase (or milestone close); FAIL → gap closure; gap limit → halt with escalation
22
- `/qualia-verify {N} --adversarial` — run a SECOND verifier in fresh context with an adversarial prompt ("find what's wrong, not what's right"). Union the findings. Recommended for high-stakes phases (Handoff milestone, payment/auth/migration code) where a biased single-pass review would silently approve a bad change. v4.3.0+.
21
+ `/qualia-verify {N} --auto` — verify + auto-chain: PASS → next phase/milestone; FAIL → gap closure; gap limit → halt
22
+ `/qualia-verify {N} --adversarial` — second verifier in fresh context with adversarial prompt. Union findings. Recommended for high-stakes phases (Handoff, payment/auth/migration). v4.3.0+.
23
23
 
24
24
  ## Process
25
25
 
@@ -41,25 +41,19 @@ node ~/.claude/bin/qualia-ui.js spawn verifier "Goal-backward check..."
41
41
 
42
42
  ```
43
43
  Agent(prompt="
44
- Read your role: @~/.claude/agents/verifier.md
45
- Grounding + rubrics: @~/.claude/rules/grounding.md
44
+ Role: @~/.claude/agents/verifier.md
46
45
 
47
- Project conventions (MUST consult before scoring Quality):
48
- @.planning/PROJECT.md
46
+ Project: @.planning/PROJECT.md
47
+ Plan + AC + validation: @.planning/phase-{N}-plan.md
48
+ {Re-verify → previous gaps: @.planning/phase-{N}-verification.md}
49
49
 
50
- Phase plan with success criteria AND verification contracts:
51
- @.planning/phase-{N}-plan.md
52
-
53
- {If re-verification: Previous verification with gaps:}
54
- {@.planning/phase-{N}-verification.md}
55
-
56
- Verify this phase. Apply the Grounding Protocol — every finding needs file:line evidence. Use the Severity Rubric for all severity labels. Write report to .planning/phase-{N}-verification.md
50
+ Verify phase. Every finding needs file:line evidence. Severity Rubric for all labels. Output: .planning/phase-{N}-verification.md
57
51
  ", subagent_type="qualia-verifier", description="Verify phase {N}")
58
52
  ```
59
53
 
60
54
  ### 2b. Browser QA (if phase touched frontend)
61
55
 
62
- If the phase plan's Files section includes any `.tsx`, `.jsx`, `.css`, `.scss`, or `app/`/`pages/`/`components/` paths, ALSO spawn the browser QA agent in parallel:
56
+ If plan Files include `.tsx`/`.jsx`/`.css`/`.scss` or `app/`/`pages/`/`components/` paths, spawn browser QA parallel:
63
57
 
64
58
  ```bash
65
59
  # Detect frontend touch
@@ -70,26 +64,20 @@ If frontend:
70
64
 
71
65
  ```
72
66
  Agent(prompt="
73
- Read your role: @~/.claude/agents/qa-browser.md
67
+ Role: @~/.claude/agents/qa-browser.md
74
68
 
75
- Phase plan: @.planning/phase-{N}-plan.md
76
- Existing verification: @.planning/phase-{N}-verification.md
69
+ Plan: @.planning/phase-{N}-plan.md
70
+ Verification: @.planning/phase-{N}-verification.md
77
71
 
78
- Drive the running dev server and test the routes this phase touched. Append a '## Browser QA' section to the verification file.
72
+ Drive dev server, test routes phase touched. Append '## Browser QA' to verification file.
79
73
  ", subagent_type="qualia-qa-browser", description="Browser QA phase {N}")
80
74
  ```
81
75
 
82
- Wait for both the main verifier and the QA browser agent before moving to step 3. If Playwright MCP is unavailable, the QA browser agent returns BLOCKED that's not a phase failure, just a note in the report.
76
+ Wait for both verifier + QA before step 3. Playwright MCP unavailable QA returns BLOCKED (note, not phase failure).
83
77
 
84
78
  ### 2c. Adversarial Second Opinion (--adversarial flag, optional)
85
79
 
86
- When `--adversarial` is in the args, OR when the current milestone is
87
- `Handoff` OR the phase plan touches files matching `auth|payment|migration|rls|service_role`, spawn a SECOND verifier in fresh context with an
88
- adversarial prompt. This is the "kid-grading-their-own-homework"
89
- mitigation — a single verifier instance trained on the same rubric the
90
- planner+builder optimized against gets ~70% fewer real findings than a
91
- fresh-context adversarial pass (Cole Medin, NotebookLM 2026-04-25, citing
92
- PR-acceptance studies).
80
+ `--adversarial` in args, OR milestone is `Handoff`, OR plan touches `auth|payment|migration|rls|service_role` → spawn SECOND verifier in fresh context. Mitigates self-grading bias (~70% fewer findings without adversarial pass).
93
81
 
94
82
  ```bash
95
83
  node ~/.claude/bin/qualia-ui.js spawn verifier "Adversarial pass — find what's wrong"
@@ -97,66 +85,48 @@ node ~/.claude/bin/qualia-ui.js spawn verifier "Adversarial pass — find what's
97
85
 
98
86
  ```
99
87
  Agent(prompt="
100
- Read your role: @~/.claude/agents/verifier.md
101
- Grounding + rubrics: @~/.claude/rules/grounding.md
102
-
103
- You are an ADVERSARIAL reviewer. Your job is to find what's WRONG with
104
- this phase, not to confirm it works. Assume the previous verifier missed
105
- something. Use the same Severity Rubric, the same evidence-citation
106
- requirement, but bias your search toward edge cases the cooperative
107
- verifier would skip:
108
- • What untested error path exists?
109
- What input would crash this?
110
- What concurrent access pattern is unhandled?
111
- What downstream consumer breaks if this contract changes?
112
- • Where is a security assumption (auth, RLS, secrets) implicit
113
- instead of enforced?
114
-
115
- Project conventions: @.planning/PROJECT.md
116
- Phase plan: @.planning/phase-{N}-plan.md
117
- Cooperative verifier's report (do NOT re-find what they found, find
118
- what they MISSED): @.planning/phase-{N}-verification.md
119
-
120
- Append a '## Adversarial Findings' section to the verification file.
121
- Empty section is fine if you genuinely found nothing — better that than
122
- inventing findings to look productive.
88
+ Role: @~/.claude/agents/verifier.md
89
+
90
+ ADVERSARIAL reviewer. Find what's WRONG. Assume cooperative verifier missed something. Same Severity Rubric + evidence-citation req. Bias toward edge cases:
91
+ - Untested error paths?
92
+ - Crash-inducing input?
93
+ - Unhandled concurrent access?
94
+ - Downstream breaks if contract changes?
95
+ - Security assumption (auth, RLS, secrets) implicit not enforced?
96
+
97
+ Project: @.planning/PROJECT.md
98
+ Plan: @.planning/phase-{N}-plan.md
99
+ Cooperative report (find what they MISSED): @.planning/phase-{N}-verification.md
100
+
101
+ Append '## Adversarial Findings' to verification file. Empty section fine if nothing found.
123
102
  ", subagent_type="qualia-verifier", description="Adversarial verify phase {N}")
124
103
  ```
125
104
 
126
- Findings from the adversarial pass merge into the main verification
127
- report. The combined PASS/FAIL is the union: if either pass found a
128
- CRITICAL or HIGH gap, the phase is FAIL.
105
+ Findings merge into main report. Union PASS/FAIL: either pass found CRITICAL/HIGH phase FAIL.
129
106
 
130
107
  ### 3. Present Results
131
108
 
132
- Read the verification report. Present:
109
+ Read verification report. Present:
133
110
 
134
- **If PASS:**
111
+ **PASS:**
135
112
  ```bash
136
113
  node ~/.claude/bin/qualia-ui.js ok "All {count} criteria passed"
137
114
  node ~/.claude/bin/qualia-ui.js end "PHASE {N} VERIFIED" "/qualia-plan {N+1}"
138
115
  ```
139
- (If phase == total phases, use `/qualia-polish` as the next command.)
116
+ (Last phase `/qualia-polish` as next command.)
140
117
 
141
- **If FAIL:**
118
+ **FAIL:**
142
119
  ```bash
143
120
  node ~/.claude/bin/qualia-ui.js ok "Passed: {pass_count}"
144
121
  node ~/.claude/bin/qualia-ui.js fail "Failed: {fail_count}"
145
122
  ```
146
123
 
147
- Then for each gap:
124
+ Per gap:
148
125
  ```bash
149
126
  node ~/.claude/bin/qualia-ui.js fail "{gap description}"
150
127
  ```
151
128
 
152
- **Self-healing layer (v4.3.0+):** before re-planning the gaps, run a
153
- postmortem so the framework itself learns from the miss. This is Cole
154
- Medin's pillar 5: don't just fix the bug, fix the AI-layer file that
155
- should have caught it. The postmortem writes a report to
156
- `.planning/phase-{N}-postmortem.md` for review — it does NOT auto-apply
157
- deltas to agents/rules unless the user runs `/qualia-postmortem --apply`
158
- explicitly. Without this loop, the same class of bug ships in PR-3, PR-7,
159
- PR-11 of the next project.
129
+ **Self-healing (v4.3.0+):** before re-planning gaps, run postmortem so framework learns from miss. Writes `.planning/phase-{N}-postmortem.md`. Does NOT auto-apply deltas unless user runs `/qualia-postmortem --apply`.
160
130
 
161
131
  ```
162
132
  /qualia-postmortem --phase {N}
@@ -172,68 +142,57 @@ node ~/.claude/bin/qualia-ui.js end "PHASE {N} GAPS FOUND" "/qualia-plan {N} --g
172
142
  ```bash
173
143
  node ~/.claude/bin/state.js transition --to verified --phase {N} --verification {pass|fail}
174
144
  ```
175
- If PASS and more phases in this milestone: state.js auto-advances to the next phase.
176
- If FAIL and gap_cycles >= limit: state.js returns GAP_CYCLE_LIMIT escalate.
177
- If FAIL and gap_cycles < limit: proceed to `/qualia-plan {N} --gaps`.
178
- Do NOT manually edit STATE.md or tracking.json state.js handles both.
145
+ PASS + more phases state.js auto-advances.
146
+ FAIL + gap_cycles >= limit GAP_CYCLE_LIMIT, escalate.
147
+ FAIL + gap_cycles < limit `/qualia-plan {N} --gaps`.
148
+ Do NOT edit STATE.md or tracking.json manually; state.js handles both.
179
149
 
180
- After state transition, capture the new state for auto-chain routing:
150
+ Capture new state for auto-chain routing:
181
151
 
182
152
  ```bash
183
153
  NEW_STATE=$(node ~/.claude/bin/state.js check)
184
- # Parse: .phase (new current phase), .total_phases, .status, .verification
185
- # Also read .planning/JOURNEY.md to know if this was the last phase of a milestone
154
+ # Parse: .phase, .total_phases, .status, .verification
155
+ # Read .planning/JOURNEY.md to check if last phase of milestone
186
156
  ```
187
157
 
188
158
  ### 4b. Route (auto-chain aware)
189
159
 
190
- **In `--auto` mode**, the router decides the next step based on verify result + journey position:
160
+ **`--auto` mode** router decides next step based on result + journey position:
191
161
 
192
162
  | Result | Journey position | Action |
193
163
  |---|---|---|
194
- | PASS | More phases remain in current milestone | Inline invoke `/qualia-plan {N+1} --auto` |
195
- | PASS | Last phase of current milestone (not Handoff) | Inline invoke `/qualia-milestone --auto` |
196
- | PASS | Last phase of Handoff milestone | Inline invoke `/qualia-ship`, then `/qualia-handoff`, then `/qualia-report` |
197
- | FAIL | gap_cycles < limit | Inline invoke `/qualia-plan {N} --gaps --auto` |
198
- | FAIL | gap_cycles >= limit | **HALT** — show escalation message, require human intervention |
164
+ | PASS | More phases in milestone | `/qualia-plan {N+1} --auto` |
165
+ | PASS | Last phase of milestone (not Handoff) | `/qualia-milestone --auto` |
166
+ | PASS | Last phase of Handoff | `/qualia-ship` `/qualia-handoff` `/qualia-report` |
167
+ | FAIL | gap_cycles < limit | `/qualia-plan {N} --gaps --auto` |
168
+ | FAIL | gap_cycles >= limit | **HALT** — escalation, require human |
199
169
 
200
- Detect "last phase of current milestone":
201
- ```bash
202
- # tracking.json.milestone gives current milestone number
203
- # .planning/JOURNEY.md describes phases per milestone
204
- # If the just-verified phase's number == total phases of current milestone → last phase
205
- ```
170
+ Last phase: verified phase == total from JOURNEY.md.
171
+ Handoff: milestone name == "Handoff" AND last phase.
206
172
 
207
- Detect "last phase of Handoff milestone":
208
- ```bash
209
- # If the current milestone's name in JOURNEY.md is "Handoff" AND this was its last phase
210
- ```
211
-
212
- **Halt case (gap cycle limit)** — stop auto-chain and show:
173
+ **Halt (gap cycle limit):**
213
174
 
214
175
  ```bash
215
- node ~/.claude/bin/qualia-ui.js fail "Phase {N} has failed verification {cycles} times gap limit reached"
176
+ node ~/.claude/bin/qualia-ui.js fail "Phase {N} failed verification {cycles} times -- gap limit reached"
216
177
  node ~/.claude/bin/qualia-ui.js warn "Human intervention required. Options:"
217
- echo " 1. Re-plan this phase from scratch: /qualia-plan {N}"
218
- echo " 2. Adjust the roadmap — phase scope may be wrong"
219
- echo " 3. Escalate to Fawzi (for EMPLOYEE role)"
178
+ echo " 1. Re-plan from scratch: /qualia-plan {N}"
179
+ echo " 2. Adjust roadmap (scope wrong)"
180
+ echo " 3. Escalate to Fawzi (EMPLOYEE role)"
220
181
  ```
221
182
 
222
- **Default (guided mode)** behavior is unchanged — show the next command and stop:
183
+ **Guided mode:**
223
184
 
224
185
  ```bash
225
- # PASS
186
+ # PASS (or "/qualia-milestone" if last phase, "/qualia-polish" if overall last)
226
187
  node ~/.claude/bin/qualia-ui.js end "PHASE {N} VERIFIED" "/qualia-plan {N+1}"
227
- # (or "/qualia-milestone" if last phase of milestone, "/qualia-polish" if overall last phase)
228
-
229
188
  # FAIL
230
189
  node ~/.claude/bin/qualia-ui.js end "PHASE {N} GAPS FOUND" "/qualia-plan {N} --gaps"
231
190
  ```
232
191
 
233
192
  ### 5. Passive Knowledge Capture (on FAIL)
234
193
 
235
- When verification fails, after showing the gaps, ask the user:
194
+ On FAIL, after showing gaps:
236
195
 
237
- > *"Was any of this a recurring issue worth saving to common-fixes.md? (yes / no / which ones)"*
196
+ > *"Any recurring issue worth saving to common-fixes.md? (yes / no / which ones)"*
238
197
 
239
- If yes, for each flagged gap spawn a brief `/qualia-learn` flow with type=`fix` the gap title and fix direction from the verification report become the entry. Do NOT save every failure automatically — only the ones the user flags. The point is to build a real knowledge base, not a log of every mistake.
198
+ Yes spawn `/qualia-learn` with type=`fix` per flagged gap. Do NOT auto-save every failure; only user-flagged.