qualia-framework 5.3.0 → 5.4.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 (47) hide show
  1. package/README.md +50 -26
  2. package/agents/builder.md +8 -0
  3. package/agents/plan-checker.md +10 -1
  4. package/agents/planner.md +1 -1
  5. package/agents/qa-browser.md +10 -0
  6. package/agents/research-synthesizer.md +10 -0
  7. package/agents/researcher.md +38 -2
  8. package/agents/roadmapper.md +10 -0
  9. package/agents/verifier.md +15 -3
  10. package/agents/visual-evaluator.md +1 -1
  11. package/bin/install.js +42 -0
  12. package/bin/state.js +155 -133
  13. package/docs/archive/session-report-2026-04-18.md +199 -0
  14. package/docs/archive/v4.0.0-review.md +288 -0
  15. package/docs/instruction-budget-audit.md +113 -0
  16. package/guide.md +11 -4
  17. package/hooks/session-start.js +1 -1
  18. package/package.json +5 -2
  19. package/rules/architecture.md +125 -0
  20. package/rules/infrastructure.md +1 -2
  21. package/rules/speed.md +55 -0
  22. package/skills/qualia-help/SKILL.md +1 -1
  23. package/skills/qualia-map/SKILL.md +1 -1
  24. package/skills/qualia-milestone/SKILL.md +1 -1
  25. package/skills/qualia-new/SKILL.md +2 -2
  26. package/skills/qualia-optimize/REFERENCE.md +2 -2
  27. package/skills/qualia-optimize/SKILL.md +1 -1
  28. package/skills/qualia-polish/SKILL.md +3 -3
  29. package/skills/qualia-polish-loop/REFERENCE.md +1 -1
  30. package/skills/qualia-polish-loop/SKILL.md +3 -3
  31. package/skills/qualia-polish-loop/fixtures/broken.html +2 -2
  32. package/skills/qualia-polish-loop/scripts/score.mjs +1 -1
  33. package/skills/qualia-postmortem/SKILL.md +1 -1
  34. package/skills/qualia-quick/SKILL.md +1 -1
  35. package/skills/qualia-research/SKILL.md +5 -3
  36. package/skills/qualia-road/SKILL.md +15 -5
  37. package/skills/qualia-task/SKILL.md +1 -1
  38. package/templates/PRODUCT.md +1 -1
  39. package/tests/bin.test.sh +3 -3
  40. package/tests/skills.test.sh +143 -0
  41. package/tests/slop-detect.test.sh +160 -0
  42. /package/{rules → qualia-design}/design-brand.md +0 -0
  43. /package/{rules → qualia-design}/design-laws.md +0 -0
  44. /package/{rules → qualia-design}/design-product.md +0 -0
  45. /package/{rules → qualia-design}/design-reference.md +0 -0
  46. /package/{rules → qualia-design}/design-rubric.md +0 -0
  47. /package/{rules → qualia-design}/frontend.md +0 -0
@@ -0,0 +1,288 @@
1
+ # v4.0.0 — Review & Publish Handoff
2
+
3
+ **Date:** 2026-04-18
4
+ **Branch:** `feature/full-journey`
5
+ **Release tag:** v4.0.0 (not yet tagged, not yet pushed)
6
+ **Status:** Ready for review. Tests 156/156 green. Needs human eyeball before `git push` + `npm publish`.
7
+
8
+ This document is the single source of truth for what shipped in v4.0.0 and what the next agent/reviewer needs to verify before the release goes public.
9
+
10
+ ---
11
+
12
+ ## TL;DR
13
+
14
+ The Qualia Framework v4.0.0 makes `/qualia-new` produce the **entire project journey** (all milestones → Handoff) upfront, enables **end-to-end auto-chaining** of the Road with `--auto`, locks down the **milestone/phase/task hierarchy**, and **rebuilds `/qualia-idk` as a real diagnostician** instead of a router alias.
15
+
16
+ 10 commits on `feature/full-journey` (8 feature + 1 docs + 1 release-state fix). ~28 files touched. 156/156 tests green.
17
+
18
+ Two local branches, neither pushed:
19
+
20
+ | Branch | HEAD | Ships |
21
+ |---|---|---|
22
+ | `feature/story-file-plans` | `8ae5b0e` | v3.7.0 — story-file plan format (independent, useful on its own) |
23
+ | `feature/full-journey` | `f790554` | v4.0.0 — full journey, auto-chain, diagnostic idk (includes v3.7.0) |
24
+
25
+ ---
26
+
27
+ ## The commits on `feature/full-journey`
28
+
29
+ ```
30
+ 94bc119 fix(v4): correct v4.0.0 — fold qualia-idk changelog entries into initial release
31
+ ea9e7f3 docs(v4): README, guide.md, SESSION_REPORT updated for v4.0.0 + V4_REVIEW.md handoff
32
+ f790554 release(v4.0.0): full journey — kickoff to handoff on rails
33
+ f62e753 fix(v4/phase-g): milestone summary cumulative task count + smoke tests
34
+ b41a52d feat(v4/phase-f): build_count + deploy_count bump, ERP v4 payload, handoff 4-deliverables
35
+ 74dd26e feat(v4/phase-d-e): builder pre-inline + journey visualization
36
+ 400cd17 feat(v4/phase-c): auto-chain wiring across Road skills
37
+ 87af253 feat(v4/phase-b): roadmapper + qualia-new full-journey output
38
+ 2e371c2 feat(v4/phase-a): model foundation — milestones[] + readiness guards
39
+ 8ae5b0e release(v3.7.0): story-file plan format (from feature/story-file-plans)
40
+ ```
41
+
42
+ **Release-point:** `94bc119` is the canonical v4.0.0 HEAD (package.json = "4.0.0", CHANGELOG has a single [4.0.0] section with `/qualia-idk` folded in). Tag v4.0.0 at this commit.
43
+
44
+ ---
45
+
46
+ ## What v4.0.0 actually changes
47
+
48
+ ### Hierarchy (locked down)
49
+ ```
50
+ Project
51
+ └─ Journey (all milestones defined upfront)
52
+ └─ Milestone (a release — 2-5 total, Handoff is always last)
53
+ └─ Phase (2-5 tasks per phase)
54
+ └─ Task (one commit, one verification contract)
55
+ ```
56
+
57
+ - Hard floor: 2 milestones. Hard ceiling: 5.
58
+ - Final milestone is **always literally named "Handoff"** with 4 fixed phases (Polish, Content + SEO, Final QA, Handoff).
59
+ - Every non-Handoff milestone needs **≥ 2 phases** (guarded by `state.js close-milestone`).
60
+ - Milestone numbering is **contiguous** — no skipped numbers.
61
+
62
+ ### New artifact: `.planning/JOURNEY.md`
63
+ The North Star. Lists every milestone with why-now + exit criteria + phase sketches. Written once during `/qualia-new`, consulted at every milestone boundary.
64
+
65
+ ### Auto mode (`--auto` flag)
66
+ ```
67
+ /qualia-new --auto
68
+ → research runs automatically
69
+ → JOURNEY.md written
70
+ → SINGLE human approval on the whole journey
71
+ → plan 1 → build 1 → verify 1 → plan 2 → build 2 → verify 2 → ...
72
+ → [milestone boundary — HUMAN GATE: "Continue to M{N+1}?"]
73
+ → ... repeat until Handoff last phase ...
74
+ → /qualia-ship → /qualia-handoff → /qualia-report → DONE
75
+ ```
76
+
77
+ **Two human gates total per project** (journey approval + each milestone boundary). Plus one halt if gap-cycle limit exceeded on a failed phase.
78
+
79
+ ### `/qualia-idk` now diagnostic (not a router alias)
80
+ Spawns two isolated `Explore` subagents in parallel:
81
+ 1. **Plan view** — reads only `.planning/*`, reports what plan says we are + what should be TRUE
82
+ 2. **Code view** — reads only source code, reports what's built + what compiles + what's stubbed, cites file:line
83
+
84
+ Main skill synthesizes: "What I see / The mismatch / What I think is happening / What to do next."
85
+
86
+ ### `/qualia` description scoped back to state routing
87
+ Previously claimed "idk / stuck / lost / confused" triggers. Those now route to `/qualia-idk`. `/qualia` keeps "what next / what now / next command."
88
+
89
+ ### Schema changes (all additive, backward compatible)
90
+ `tracking.json` gains:
91
+ - `milestone_name` — human name of current milestone
92
+ - `milestones[]` — array of closed milestone summaries (for ERP tree render)
93
+ - `build_count`, `deploy_count` — now actually incremented on transitions
94
+
95
+ `state.js` check output gains `milestone_name` + `milestones`.
96
+
97
+ `qualia-report` ERP payload now includes all v4 fields.
98
+
99
+ ---
100
+
101
+ ## How to verify before publishing
102
+
103
+ ### 1. Run the test suite
104
+ ```bash
105
+ cd /home/qualiasolutions/qualia-framework
106
+ node --test tests/runner.js
107
+ ```
108
+ Expected: `# pass 156 / # fail 0`.
109
+
110
+ ### 2. Visual smoke test of new UI commands
111
+ ```bash
112
+ # Make a fake project
113
+ TMP=/tmp/qualia-v4-visual && rm -rf $TMP && mkdir -p $TMP/.planning
114
+ cat > $TMP/.planning/JOURNEY.md <<'EOF'
115
+ ---
116
+ project: "Demo"
117
+ ---
118
+ ## Milestone 1 · Foundation
119
+ **Why now:** Base infra.
120
+ **Phases:**
121
+ 1. **Setup**
122
+ 2. **Auth**
123
+ ## Milestone 2 · Core Features
124
+ **Why now:** Value delivery.
125
+ **Phases:**
126
+ 1. **Feature A**
127
+ 2. **Feature B**
128
+ ## Milestone 3 · Handoff
129
+ **Phases:**
130
+ 1. **Polish**
131
+ 2. **Content + SEO**
132
+ 3. **Final QA**
133
+ 4. **Handoff**
134
+ EOF
135
+ cat > $TMP/.planning/tracking.json <<'EOF'
136
+ {"milestone":2,"milestone_name":"Core Features","milestones":[],"phase":1,"total_phases":2,"status":"built","lifetime":{"tasks_completed":4,"phases_completed":2,"milestones_completed":1}}
137
+ EOF
138
+ cat > $TMP/.planning/STATE.md <<'EOF'
139
+ ## Current Position
140
+ Phase: 1 of 2 — Feature A
141
+ Status: built
142
+ Assigned to: Reviewer
143
+
144
+ ## Roadmap
145
+ | # | Phase | Goal | Status |
146
+ |---|-------|------|--------|
147
+ | 1 | Feature A | x | built |
148
+ | 2 | Feature B | x | — |
149
+ EOF
150
+ (cd $TMP && node /home/qualiasolutions/qualia-framework/bin/qualia-ui.js journey-tree .planning/JOURNEY.md)
151
+ node /home/qualiasolutions/qualia-framework/bin/qualia-ui.js milestone-complete 1 "Foundation" "Core Features"
152
+ node /home/qualiasolutions/qualia-framework/bin/qualia-ui.js milestone-complete 3 "Handoff" ""
153
+ rm -rf $TMP
154
+ ```
155
+ Expected:
156
+ - Journey tree shows green dot on M1, teal diamond on M2 (CURRENT), dim circle on M3 (FINAL).
157
+ - First milestone-complete banner shows `Next: Core Features`.
158
+ - Second shows `PROJECT COMPLETE · last milestone reached`.
159
+
160
+ ### 3. State-machine end-to-end smoke
161
+ Covered by test case `tests/runner.js` "milestone summary captures cumulative tasks_completed" and "build_count bumps on each 'built' transition". Both pass.
162
+
163
+ ### 4. Manual eyeball of key files
164
+ Review these for v4 correctness:
165
+
166
+ | File | Why |
167
+ |---|---|
168
+ | `templates/journey.md` | New artifact schema — is the format clear and complete? |
169
+ | `agents/roadmapper.md` | Biggest agent rewrite — does it correctly describe the 3-file output (JOURNEY + REQUIREMENTS + ROADMAP)? |
170
+ | `skills/qualia-new/SKILL.md` | Core flow — is the 14-step process coherent? Is `--auto` wiring clear? |
171
+ | `skills/qualia-idk/SKILL.md` | New diagnostic — does the 2-pass isolation make sense? Is the synthesis format useful? |
172
+ | `skills/qualia-verify/SKILL.md` | Auto-chain decision table (PASS → next phase / last phase → milestone / last milestone → ship) |
173
+ | `skills/qualia-milestone/SKILL.md` | Reads next milestone from JOURNEY.md now, not user prompt |
174
+ | `skills/qualia-handoff/SKILL.md` | 4 mandatory deliverables enforced |
175
+ | `bin/state.js` lines ~975-1050 | close-milestone readiness guards + milestones[] summary append |
176
+ | `bin/qualia-ui.js` journey-tree + milestone-complete | New visualizations |
177
+ | `CHANGELOG.md` [4.0.0] section | Full feature list + migration notes |
178
+
179
+ ### 5. Backward-compat verification
180
+ The v4 changes are designed additive. Verify by:
181
+ ```bash
182
+ # tracking.json from an older project (no milestones[], no milestone_name)
183
+ # should still work with state.js check
184
+ echo '{"milestone":1,"phase":1,"total_phases":3,"status":"setup","lifetime":{"tasks_completed":0,"phases_completed":0,"milestones_completed":0,"total_phases":0}}' > /tmp/old-tracking.json
185
+ mkdir -p /tmp/old-project/.planning && mv /tmp/old-tracking.json /tmp/old-project/.planning/tracking.json
186
+ cat > /tmp/old-project/.planning/STATE.md <<'EOF'
187
+ Phase: 1 of 3 — Setup
188
+ Status: setup
189
+
190
+ ## Roadmap
191
+ | # | Phase | Goal | Status |
192
+ |---|-------|------|--------|
193
+ | 1 | Setup | x | ready |
194
+ | 2 | Feature | x | — |
195
+ | 3 | Ship | x | — |
196
+ EOF
197
+ (cd /tmp/old-project && node /home/qualiasolutions/qualia-framework/bin/state.js check | head -20)
198
+ rm -rf /tmp/old-project
199
+ ```
200
+ Expected: `check` succeeds, output includes `milestones: []` and `milestone_name: ""` (hydrated by `ensureLifetime`).
201
+
202
+ ---
203
+
204
+ ## Publish checklist
205
+
206
+ Once review passes:
207
+
208
+ ```bash
209
+ # 1. Push both branches
210
+ git push -u origin feature/story-file-plans
211
+ git push -u origin feature/full-journey
212
+
213
+ # 2. Merge v3.7.0 first (recommended — gives it a distinct tag in history)
214
+ git checkout main
215
+ git merge --ff-only feature/story-file-plans
216
+ git tag v3.7.0
217
+ git push origin main --tags
218
+
219
+ # 3. Merge v4.0.0
220
+ git merge --ff-only feature/full-journey
221
+ # If fast-forward fails (unlikely since v4 branched off story-file-plans HEAD):
222
+ # git merge feature/full-journey # creates a merge commit — also fine
223
+ git tag v4.0.0
224
+ git push origin main --tags
225
+
226
+ # 4. npm publish
227
+ npm publish
228
+ # Expected: qualia-framework@4.0.0 goes live. Auto-update hook notifies
229
+ # every team member's installed client on next session.
230
+
231
+ # 5. Verify
232
+ npm view qualia-framework version # should return 4.0.0
233
+ ```
234
+
235
+ ### Alternative: one combined release
236
+ If the team would rather have a single v4.0.0 release tag (skip the v3.7.0 tag):
237
+
238
+ ```bash
239
+ git checkout main
240
+ git merge --ff-only feature/full-journey
241
+ git tag v4.0.0
242
+ git push origin main --tags
243
+ npm publish
244
+ ```
245
+ (v3.7.0 work is still in the history, just not tagged as its own release.)
246
+
247
+ ---
248
+
249
+ ## Risk areas (eyeball these)
250
+
251
+ 1. **Auto-chain logic in `/qualia-verify`** — the decision table (PASS → next phase / last phase of milestone / last phase of Handoff / FAIL gap / FAIL limit) is described in the SKILL.md but relies on Claude to parse JOURNEY.md at runtime to detect "last phase of milestone." Smoke test didn't actually run the auto-chain because that requires live subagent invocation. **Recommended first test on merge**: run `/qualia-new --auto` on a throwaway project and watch how it handles the milestone boundary.
252
+
253
+ 2. **Roadmapper's new three-file output** — the rewritten agent prompt is long and complex. The roadmapper must:
254
+ - Generate JOURNEY.md with all milestones
255
+ - Assign requirements to milestones
256
+ - Only detail Milestone 1 in ROADMAP.md
257
+ - Pass `--milestone_name` to `state.js init`
258
+ Smoke test didn't exercise the roadmapper directly — it's only triggered by `/qualia-new`.
259
+
260
+ 3. **`/qualia-idk`'s two-pass isolation** — depends on `Explore` subagent correctly NOT crossing its scope. If an Explore agent reads .planning/ when told "code only" or vice versa, the diagnosis degrades. The SKILL.md has explicit "DO NOT read..." instructions but this is prompt-level enforcement, not hard boundary.
261
+
262
+ 4. **Builder pre-inline context** — saves tool calls but inflates prompt size. On very large projects (PROJECT.md + DESIGN.md + 5 context files could easily be 10k+ tokens), the builder's prompt might balloon. Acceptable for most projects; watch for issues on monorepos.
263
+
264
+ ---
265
+
266
+ ## Known limitations / deferred
267
+
268
+ - **No visual / mockup generation** (gstack's `/design-shotgun` or Superpowers' Visual Companion). Not in v4 — could be a v4.1 feature.
269
+ - **No cross-model review** (gstack's `/codex`). Not in v4.
270
+ - **No cross-project vector memory** (Claude-Flow's claude-mem pattern). Current `knowledge/` is still hand-authored markdown.
271
+ - **No IDE integration** (VS Code extension, JetBrains plugin). Claude Code CLI only.
272
+ - **No token-budget compression** (SuperClaude's ~70% compression claim). Qualia relies on fresh-context agents instead of compression.
273
+
274
+ These are all discussed in the competitive gap analysis done earlier in the session — see the chat transcript or memory for details.
275
+
276
+ ---
277
+
278
+ ## Questions for Fawzi before publish
279
+
280
+ 1. **Single v4.0.0 release or v3.7.0 + v4.0.0?** Default: both tags (v3.7.0 as a step release). Cleaner history. Alternative: fold into single v4.0.0.
281
+ 2. **Alpha/beta tag on npm?** `npm publish` without `--tag` goes to `latest` and every installed client auto-updates on next session. If you want a slower rollout, publish with `--tag beta` and the team opts in manually with `npm install qualia-framework@beta install`.
282
+ 3. **Do you want to dogfood v4 on an existing project before publish?** Running `npx qualia-framework@4.0.0-alpha install` locally on Sakani or another project is the safest way to verify end-to-end — especially the auto-chain which isn't covered by the unit tests.
283
+
284
+ Contact for questions: Fawzi Goussous — fawzi@qualiasolutions.net
285
+
286
+ ---
287
+
288
+ *Generated 2026-04-18 by the v4 build session. Review this doc + CHANGELOG.md [4.0.0] before publishing.*
@@ -0,0 +1,113 @@
1
+ # Instruction-Budget Audit
2
+
3
+ > **Date:** 2026-05-06
4
+ > **Trigger:** Re-study of *Skills and Strategies for Real Engineering with Claude Code* (Matt Pocock) and *Context and Tools: Mastering the AI Engineering Lifecycle* (Patrick Debois, Karpathy, Pocock, Mario Zechner).
5
+ > **Question:** Does Qualia Framework actually honor the "load on demand, not always" promise written in `CLAUDE.md`?
6
+
7
+ ## Finding 1 — `~/.claude/rules/*.md` is loaded eagerly by Claude Code
8
+
9
+ Claude Code auto-discovers and injects every Markdown file under `~/.claude/rules/` into the system prompt of every session. This is **harness behavior**, not framework behavior — there is no `@-import` declaration in `~/.claude/CLAUDE.md`, yet the rules appear in the system reminder verbatim.
10
+
11
+ **Measured cost (2026-05-06 install):**
12
+
13
+ | File | Lines | Notes |
14
+ |---|---|---|
15
+ | `design-reference.md` | 179 | Motion specs, WCAG checklist, breakpoints |
16
+ | `design-rubric.md` | 157 | 8-dimension verifier rubric |
17
+ | `design-laws.md` | 148 | OKLCH, color strategy, typography |
18
+ | `frontend.md` | 118 | Brand standards |
19
+ | `design-brand.md` | 114 | Brand register |
20
+ | `design-product.md` | 114 | Product register |
21
+ | `grounding.md` | 114 | Severity rubric, citation format |
22
+ | `infrastructure.md` | 87 | Stack, MCP servers, CLIs |
23
+ | `deployment.md` | 30 | Post-deploy checklist |
24
+ | `speed.md` | 23 | Speed rules |
25
+ | `context7.md` | 14 | Context7 trigger rule |
26
+ | `security.md` | 12 | RLS, auth, secrets |
27
+ | **Total** | **1110** | |
28
+
29
+ At ~4 chars/line average that is **~28 KB injected on every session**, regardless of whether the user is touching frontend, backend, infra, or nothing.
30
+
31
+ The rule files themselves are written under the assumption that a skill or agent will read them on demand (e.g., `agents/builder.md` line 139 says *"Security, design, and performance rules auto-load from `rules/*.md` based on the files you touch"*) — which is correct **inside subagent fork prompts** but **wrong for the user's main session**, where the harness loads them all preemptively.
32
+
33
+ ## Finding 2 — `CLAUDE.md` template is already disciplined
34
+
35
+ The framework `CLAUDE.md` template is 24 lines and ends with the right note:
36
+
37
+ > *"this file stays under 25 lines. Steering rules go into discoverable skills, not into the global system prompt. CLI preferences go into hooks. Stack/architecture details are trivially discoverable in package.json/config."*
38
+
39
+ This part is healthy. The leak is in `rules/`, not `CLAUDE.md`.
40
+
41
+ ## Finding 3 — Skill dedup hypothesis was wrong
42
+
43
+ A first pass suggested deleting `qualia-quick`, `qualia-road`, `qualia-help`, `qualia-handoff` as duplicates. Cross-reference check showed:
44
+
45
+ - `qualia-quick` is referenced from `bin/install.js`, `hooks/session-start.js`, `templates/help.html`, `README.md`, `guide.md`, `skills/qualia-prd/SKILL.md`, `skills/qualia-task/SKILL.md` — load-bearing.
46
+ - `qualia-road` is referenced from `CLAUDE.md`, `AGENTS.md`, `README.md`, `guide.md`, `skills/qualia-help/SKILL.md` description — load-bearing.
47
+ - `qualia-help` opens an HTML reference — distinct purpose from `qualia-road` (terminal map).
48
+ - `qualia-handoff` is the final delivery skill, referenced from `bin/state.js:490`, ship/verify, journey-demo — load-bearing.
49
+
50
+ **Each skill has a job.** No deletion is safe in this PR. The right fix is *boundary clarity in descriptions* (so the LLM picks correctly), not deletion.
51
+
52
+ ## Recommended follow-ups (deferred to separate PRs)
53
+
54
+ ### R1 — Move design rules to a lazy folder *(big, risky)*
55
+
56
+ ```
57
+ ~/.claude/rules/ # always-loaded (HARNESS)
58
+ ├── grounding.md (114) # KEEP — universal
59
+ ├── security.md (12) # KEEP — universal
60
+ ├── speed.md (23) # KEEP — universal
61
+ ├── context7.md (14) # KEEP — universal
62
+ └── infrastructure.md (87) # KEEP — universal stack
63
+ # total: ~250 lines
64
+
65
+ ~/.claude/qualia-design/ # explicit-load only
66
+ ├── design-laws.md (148)
67
+ ├── design-brand.md (114)
68
+ ├── design-product.md (114)
69
+ ├── design-reference.md (179)
70
+ ├── design-rubric.md (157)
71
+ ├── frontend.md (118)
72
+ └── deployment.md (30) # post-deploy checklist; loaded by /qualia-ship
73
+ # total: 860 lines, NOT auto-loaded
74
+ ```
75
+
76
+ Skills/agents that need design rules `Read` them on demand (already the pattern in `agents/builder.md` and `agents/verifier.md`). The save: **~28 KB → ~6 KB injected per session, ~22 KB recovered.**
77
+
78
+ Required changes:
79
+ 1. `bin/install.js` — install design rules to `~/.claude/qualia-design/` instead of `~/.claude/rules/`.
80
+ 2. Every skill/agent reference path `rules/design-*.md` → `qualia-design/design-*.md` or use `~/.claude/qualia-design/design-*.md` absolute.
81
+ 3. Update `hooks/session-start.js` `CRITICAL_FILES` health check.
82
+ 4. Migration step in `bin/install.js` to clean up old `~/.claude/rules/design-*.md` for existing installs.
83
+
84
+ **Effort:** M-L. **Impact:** ~80% reduction in always-loaded substrate.
85
+
86
+ ### R2 — Skill description sharpening *(small, safe)*
87
+
88
+ `qualia-quick` and `qualia-task` overlap in description. Tighten:
89
+ - `qualia-quick`: "≤1 hour, 1 file, no plan, no spawn — just do it."
90
+ - `qualia-task`: "1–3 hours, 1–5 files, fresh builder spawn, atomic commit, no phase plan."
91
+
92
+ `qualia-road` and `qualia-help` overlap. Clarify:
93
+ - `qualia-road`: "Terminal-rendered workflow map. Use over SSH or when no browser."
94
+ - `qualia-help`: "Browser-rendered HTML reference. Default."
95
+
96
+ ### R3 — Per-skill versioning + eval harness *(carry-over from notebook 1, source 6 — Debois)*
97
+
98
+ Each skill carries its own `version:` in frontmatter and a `tests/skills/{skill-name}.spec.sh` fixture. CI runs the fixture against the skill spec. Catches silent skill rot when CC behavior changes underneath.
99
+
100
+ ### R4 — MCP tier-list rule in `rules/speed.md` *(carry-over from notebook 1, source 5 — CLI vs MCP)*
101
+
102
+ Codify the "CLI-first" principle. Reference the existing `/supabase` skill replacing 32 supabase MCP tools as the canonical example.
103
+
104
+ ## What changed in *this* PR
105
+
106
+ This PR ships the changes that don't require user-state migration:
107
+
108
+ 1. **Citation enforcement preamble** in `agents/builder.md` and `agents/verifier.md` — closes notebook 2, source #9 (*Never Trust an LLM*). Builders and verifiers must cite `file:line — "quoted"` or write `INSUFFICIENT EVIDENCE`. No hedging, no narration.
109
+ 2. **`rules/architecture.md`** — net-new, deep-modules + scout-for-shallow-code from notebook 2 sources #5 + #12 (Pocock de-slop, codebase-not-ready-for-AI). Skill `/qualia-optimize --deepen` already exists; this rule formalizes the architectural taste it scouts for.
110
+ 3. **README warning** — "Never run Claude's `/init`" — direct users to `/qualia-new` or `/qualia-map`. Per notebook 2 sources #3 + #8.
111
+ 4. **This audit document** — anchors the deferred follow-ups so they don't get lost.
112
+
113
+ The relocation in R1 is the biggest single win available; it is intentionally deferred so this PR stays small and reversible.
package/guide.md CHANGED
@@ -1,8 +1,10 @@
1
- # Qualia Developer Guide (v5)
1
+ # Qualia Developer Guide (v5.3)
2
2
 
3
3
  > Follow the road. Type the commands. The framework handles the rest.
4
4
  > `--auto` chains the whole road end-to-end with only two human checkpoints per project.
5
5
 
6
+ **v5.3 ships three Matt-Pocock gap closures:** `/qualia-prd` (synthesize conversation → durable spec), `/qualia-hook-gen` (CLAUDE.md instruction → deterministic hook), `/qualia-optimize --deepen` Step 5b (3 parallel-interface design variants for refactor RFCs). Plus the visual-polish loop (`/qualia-polish-loop`) from v5.1 with reduced-motion + multi-route flags from v5.2.
7
+
6
8
  ## The Road
7
9
 
8
10
  ```
@@ -49,18 +51,23 @@ Append `--auto` to `/qualia-new` and the framework chains every step:
49
51
  |------|---------|-------------|
50
52
  | Starting | `/qualia-new` | Set up project with full journey (all milestones → Handoff) |
51
53
  | Starting (auto) | `/qualia-new --auto` | Same + chain through building automatically |
54
+ | Brownfield | `/qualia-map` | Map an existing codebase BEFORE `/qualia-new` |
55
+ | Mid-project spec | `/qualia-prd` | Synthesize the current conversation into a durable feature spec (v5.3+) |
52
56
  | Building | `/qualia-plan` | Plan the current phase |
53
57
  | | `/qualia-build` | Build it (parallel tasks) |
54
58
  | | `/qualia-verify` | Check it actually works |
55
59
  | Milestone | `/qualia-milestone` | Close current, open next from JOURNEY.md |
56
60
  | Quick fix | `/qualia-quick` | Skip planning, just do it |
57
- | Finishing | `/qualia-polish` | Design and UX pass |
61
+ | Finishing | `/qualia-polish` | Design and UX pass (scope-adaptive: component / route / app / redesign / critique / quick) |
62
+ | | `/qualia-polish-loop` | Autonomous visual-polish loop — screenshot → vision-eval → fix → repeat (v5.1+) |
58
63
  | | `/qualia-ship` | Deploy to production |
59
64
  | | `/qualia-handoff` | Deliver to client (4 mandatory deliverables) |
60
65
  | Reporting | `/qualia-report` | Log what you did (mandatory before clock-out) |
61
66
  | Zooming in | `/qualia-zoom` | Focus on a single file or function with full context |
62
- | Issues | `/qualia-issues` | Scan codebase for issues, tech debt, and improvement opportunities |
63
- | Triage | `/qualia-triage` | Prioritize and categorize a backlog of issues |
67
+ | Issues | `/qualia-issues` | Break a phase plan into vertical-slice GitHub issues |
68
+ | Triage | `/qualia-triage` | Triage open issues through the ready-for-agent state machine |
69
+ | Optimize | `/qualia-optimize --deepen` | Find shallow modules; v5.3+ spawns 3 parallel interface-design variants per candidate |
70
+ | Hook gen | `/qualia-hook-gen` | Convert a CLAUDE.md/rules instruction into a deterministic hook (v5.3+) |
64
71
  | Road view | `/qualia-road` | View and navigate journey/milestone/phase status |
65
72
  | Lost? | `/qualia` | Mechanical next-command router |
66
73
  | Confused? | `/qualia-idk` | Diagnostic — scans planning + code, explains what's going on |
@@ -34,8 +34,8 @@ const HEALTH_FILE = path.join(HOME, ".claude", ".qualia-install-health.json");
34
34
  const CRITICAL_FILES = [
35
35
  path.join(HOME, ".claude", "rules", "grounding.md"),
36
36
  path.join(HOME, ".claude", "rules", "security.md"),
37
- path.join(HOME, ".claude", "rules", "frontend.md"),
38
37
  path.join(HOME, ".claude", "rules", "deployment.md"),
38
+ path.join(HOME, ".claude", "qualia-design", "frontend.md"),
39
39
  path.join(HOME, ".claude", "bin", "state.js"),
40
40
  ];
41
41
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qualia-framework",
3
- "version": "5.3.0",
3
+ "version": "5.4.0",
4
4
  "description": "Claude Code workflow framework by Qualia Solutions. Plan, build, verify, ship.",
5
5
  "bin": {
6
6
  "qualia-framework": "./bin/cli.js"
@@ -28,14 +28,17 @@
28
28
  "test:hooks": "bash tests/hooks.test.sh",
29
29
  "test:bin": "bash tests/bin.test.sh",
30
30
  "test:lib": "bash tests/lib.test.sh",
31
+ "test:skills": "bash tests/skills.test.sh",
32
+ "test:slop-detect": "bash tests/slop-detect.test.sh",
31
33
  "test:statusline": "bash tests/statusline.test.sh",
32
- "test:shell": "bash tests/statusline.test.sh && bash tests/state.test.sh && bash tests/hooks.test.sh && bash tests/bin.test.sh && bash tests/lib.test.sh"
34
+ "test:shell": "bash tests/statusline.test.sh && bash tests/state.test.sh && bash tests/hooks.test.sh && bash tests/bin.test.sh && bash tests/lib.test.sh && bash tests/skills.test.sh && bash tests/slop-detect.test.sh"
33
35
  },
34
36
  "files": [
35
37
  "bin/",
36
38
  "agents/",
37
39
  "hooks/",
38
40
  "rules/",
41
+ "qualia-design/",
39
42
  "skills/",
40
43
  "templates/",
41
44
  "references/",
@@ -0,0 +1,125 @@
1
+ # Architecture Rules
2
+
3
+ How Qualia code stays navigable for future agents (human and AI). Read on architectural-judgment tasks: refactors, new module decisions, deep-module work, `/qualia-optimize --deepen`.
4
+
5
+ ## 1. Deep modules over shallow ones (Ousterhout)
6
+
7
+ A **deep module** hides significant complexity behind a small, stable interface. A **shallow module** exposes most of its internals — every caller has to know how it works to use it.
8
+
9
+ | | Deep | Shallow |
10
+ |---|---|---|
11
+ | Interface size (params, exports) | Small | Wide |
12
+ | Internal logic | Substantial | Trivial |
13
+ | Cost to change implementation | Low (callers don't notice) | High (every caller breaks) |
14
+ | Cost to read a caller | Low | High (must know module internals) |
15
+
16
+ Deep modules are the primary defense against AI-generated entropy. AI is excellent at generating implementation; humans (and AI under guidance) must defend the **interface**.
17
+
18
+ ### Smell — shallow code
19
+
20
+ If you spot any of these, the module is shallow and is a refactor candidate:
21
+
22
+ - A wrapper function that does only argument shuffling and a single inner call.
23
+ - A type-only file that re-exports types from elsewhere.
24
+ - A "service" that has 8 public methods and one private one.
25
+ - A util module where every export is used in exactly one place.
26
+ - A class whose every method is a one-liner pass-through.
27
+
28
+ `/qualia-optimize --deepen` is the skill that scouts for these and proposes interface consolidations.
29
+
30
+ ## 2. Locality over cleverness
31
+
32
+ Code that changes together should live together. The cost of a "DRY" abstraction is paid every time a future caller has to mentally fork to the abstraction's definition. Three similar lines beats a premature `extractCommon()` that everyone has to read twice.
33
+
34
+ Apply DRY only when:
35
+ - The duplication is exact (not just similar shape).
36
+ - The thing duplicated is unlikely to diverge.
37
+ - The caller doesn't need to know "the rule" to read the call site.
38
+
39
+ If any of those three is uncertain, leave the duplication. Pocock's rule of thumb: **three is the threshold, but only if all three would change in lock-step.**
40
+
41
+ ## 3. Adapters at seams
42
+
43
+ Wherever the system meets an external dependency (database, third-party API, AI provider, payment gateway), introduce an adapter. The adapter:
44
+
45
+ - Owns the dependency's specific shape (auth headers, response envelopes, error formats).
46
+ - Translates to a project-internal type that the rest of the code uses.
47
+ - Is the only file that needs to change when the dependency is swapped or upgraded.
48
+
49
+ This is the seam where tests inject fakes and where future migrations live. A codebase without adapters is a codebase that fights every dependency upgrade.
50
+
51
+ **Example seams** in a typical Qualia project:
52
+ - `lib/supabase/server.ts` — adapter over `@supabase/supabase-js`.
53
+ - `lib/openrouter/client.ts` — adapter over OpenRouter REST API.
54
+ - `lib/retell/agent.ts` — adapter over Retell AI SDK.
55
+ - `lib/zoho/contacts.ts` — adapter over Zoho Books API.
56
+
57
+ Direct calls to vendor SDKs from feature code are a smell. Move them through an adapter.
58
+
59
+ ## 4. Progressive disclosure of complexity
60
+
61
+ A reader entering the codebase from a fresh clone should be able to follow this path:
62
+
63
+ ```
64
+ README.md → app/ or src/index → one feature folder → one route → one component → one util
65
+ ```
66
+
67
+ At each step the depth increases. The top is breadth (what does this app do?), the bottom is depth (how does this specific util compute X?). Skipping levels is a smell:
68
+
69
+ - An entry point that imports 30 modules from across the tree → the tree is shallow.
70
+ - A route handler that calls a database directly → no service layer; logic and IO are entangled.
71
+ - A component that owns its own data fetching, mutation logic, error handling, and rendering → no hook abstraction; the component will be impossible to test or replace.
72
+
73
+ The pattern that tells a fresh reader where to go next is **layered service boundaries**:
74
+ 1. **Routes / pages** — wiring only. No business logic.
75
+ 2. **Features / use cases** — business logic. Calls services.
76
+ 3. **Services** — orchestration. Calls adapters.
77
+ 4. **Adapters** — IO. The only layer that talks to vendors.
78
+ 5. **Domain types** — pure. No imports of the above.
79
+
80
+ Inversions of this order (domain types importing adapters, services calling components) are bugs in shape.
81
+
82
+ ## 5. Interface stability beats internal elegance
83
+
84
+ Once an interface has callers, changing it is expensive. Internal refactors are cheap. **Optimize for the cost of change.**
85
+
86
+ When in doubt:
87
+ - A new public function: write it conservatively. Defaults are a liability — every default is a future migration.
88
+ - An internal function: write it expressively. Internal callers can be fixed in one sweep.
89
+
90
+ Pocock's heuristic from de-slop: *the interface is the thing the AI shouldn't change without you. The implementation is the thing the AI can rewrite at will.*
91
+
92
+ ## 6. Test the seam, not the function
93
+
94
+ Unit tests that pin internal function signatures rot fast — every refactor breaks them. Tests against the **adapter** or **service interface** survive refactors.
95
+
96
+ Order of test value (high → low):
97
+ 1. **End-to-end / user-flow** — tests at the route level. Survive everything except feature changes.
98
+ 2. **Service-level** — tests at the use-case boundary. Survive most refactors.
99
+ 3. **Adapter-level** — tests with the vendor mocked. Survive vendor swaps.
100
+ 4. **Unit / function-level** — tests against a single internal function. Last resort. Only for genuinely tricky algorithms.
101
+
102
+ The pyramid in older textbooks (lots of unit, few e2e) inverted in the AI era. AI generates internal functions cheaply; the seam tests are the ones that survive AI-driven refactors.
103
+
104
+ ## 7. The codebase IS the documentation
105
+
106
+ Per Pocock's *"Never run /init"*: static documentation rots within weeks. The agents and humans should be able to **explore** to discover, not **memorize** to recall.
107
+
108
+ Practical rules:
109
+ - README.md: orientation only — what is this app, how do I run it, where is the source of truth for the rest. Not API docs, not architecture diagrams that will lie within a sprint.
110
+ - `.planning/CONTEXT.md`: domain glossary, append-only as terms emerge. Discovered, not maintained.
111
+ - ADRs in `.planning/decisions/`: hard-to-reverse calls, dated, immutable. Future archaeology, not current spec.
112
+ - Anything else: it lives in code or it doesn't exist. If you need a diagram, generate it from the code at read-time.
113
+
114
+ A skill or agent that needs context should `Read` the relevant code, not a synopsis of it written six months ago.
115
+
116
+ ## 8. When to apply this rule file
117
+
118
+ Read this file (auto-load via skill or `@rules/architecture.md`) when:
119
+
120
+ - Planning a new module or feature with multiple components.
121
+ - The user requests `/qualia-optimize --deepen` or `--alignment`.
122
+ - A verifier is scoring "Container depth & nesting" (per `rules/design-rubric.md` dimension 8).
123
+ - An ADR is being drafted for an architectural fork.
124
+
125
+ Do **not** auto-load this on quick fixes, copy edits, single-component touch-ups — that wastes instruction budget. Use judgment.
@@ -8,8 +8,7 @@ Standard services across all Qualia projects. Use these unless the project expli
8
8
 
9
9
  ## Database: Supabase (every project)
10
10
  - Every project uses Supabase for auth, database, and storage
11
- - **CLI:** `npx supabase` migrations, type generation, local dev
12
- - **MCP:** Supabase MCP server is available in Claude Code for direct database operations
11
+ - **CLI-first** — prefer `npx supabase` (migrations, type generation, local dev, SQL) over the Supabase MCP server. The MCP imposes a token tax on every turn; the CLI hits the same API at zero token cost. Use the MCP only when you need a feature the CLI doesn't expose (e.g., interactive branch management).
13
12
  - Always enable RLS on every table (see `rules/security.md`)
14
13
  - Use `lib/supabase/server.ts` for server-side, `lib/supabase/client.ts` for client-side
15
14
  - Run `npx supabase gen types` after schema changes