analyzthis_design 2.3.1 → 2.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 (42) hide show
  1. package/HOW-TO-USE.md +2 -1
  2. package/README.md +14 -3
  3. package/dist/HOW-TO-USE.md +2 -1
  4. package/dist/README.md +14 -3
  5. package/dist/bin/cli.js +15 -3
  6. package/dist/lib/chunk-run.js +2 -0
  7. package/dist/lib/install.js +2 -0
  8. package/dist/lib/knowledge.js +49 -18
  9. package/dist/lib/mcp-server.js +163 -30
  10. package/dist/lib/orchestrator/run.js +5 -0
  11. package/dist/lib/session.js +33 -2
  12. package/dist/skills/anuj/SKILL.md +7 -0
  13. package/dist/skills/arjun/SKILL.md +5 -263
  14. package/dist/skills/arjun/references/lens.md +265 -0
  15. package/dist/skills/kavi/SKILL.md +7 -0
  16. package/dist/skills/knowledge-bank/SKILL.md +11 -25
  17. package/dist/skills/meera/SKILL.md +7 -0
  18. package/dist/skills/noor/SKILL.md +7 -0
  19. package/dist/skills/persona-orchestrator/SKILL.md +5 -195
  20. package/dist/skills/persona-orchestrator/references/lens.md +197 -0
  21. package/dist/skills/priya/SKILL.md +7 -0
  22. package/dist/skills/raj/SKILL.md +7 -0
  23. package/dist/skills/receipt/SKILL.md +17 -0
  24. package/dist/skills/ux-story-gate/SKILL.md +5 -338
  25. package/dist/skills/ux-story-gate/references/lens.md +340 -0
  26. package/dist/skills/zara/SKILL.md +7 -0
  27. package/package.json +1 -1
  28. package/skills/anuj/SKILL.md +7 -0
  29. package/skills/arjun/SKILL.md +5 -263
  30. package/skills/arjun/references/lens.md +265 -0
  31. package/skills/kavi/SKILL.md +7 -0
  32. package/skills/knowledge-bank/SKILL.md +11 -25
  33. package/skills/meera/SKILL.md +7 -0
  34. package/skills/noor/SKILL.md +7 -0
  35. package/skills/persona-orchestrator/SKILL.md +5 -195
  36. package/skills/persona-orchestrator/references/lens.md +197 -0
  37. package/skills/priya/SKILL.md +7 -0
  38. package/skills/raj/SKILL.md +7 -0
  39. package/skills/receipt/SKILL.md +17 -0
  40. package/skills/ux-story-gate/SKILL.md +5 -338
  41. package/skills/ux-story-gate/references/lens.md +340 -0
  42. package/skills/zara/SKILL.md +7 -0
@@ -0,0 +1,197 @@
1
+ ## Step 0 — Load session state
2
+
3
+ Run (or instruct the host to run) `npx analyzthis_design session show`.
4
+
5
+ - If a session already exists for this project: read it. Do not re-ask the user for a task map, DS tokens, or routing decision that's already recorded — this is the fix for the "Ask/Agent double spend" failure where context gets re-derived every turn.
6
+ - If no session exists: run `npx analyzthis_design session init` to create one, then proceed to Step 1.
7
+
8
+ Load `agents/session-schema.json` to know the exact shape you're reading and writing.
9
+
10
+ ---
11
+
12
+ ## Step 1 — Run ux-story-gate intake (Phases 0 – 1.5)
13
+
14
+ Read `skills/ux-story-gate/SKILL.md` and run:
15
+ - Phase 0 (PRD discovery) — skip re-deriving anything already present in session state
16
+ - Phase 0.5 (DS/Figma discovery) — populate `ds_checklist` and `figma_node`
17
+ - Phase 1 (task map intake gate) — populate `task_map`
18
+ - Phase 1.5 (MoE router) — populate `routing_decision`
19
+
20
+ Persist all four outputs to session state before moving on. Do not proceed to Step 2 until Phase 1's gate condition is satisfied (a confirmed task map exists).
21
+
22
+ ---
23
+
24
+ ## Step 2 — Select the execution graph (MoE subset is the default)
25
+
26
+ Read `agents/router.json` and `agents/chain.json`.
27
+
28
+ **Default budget is 1–2 experts.** Only run the full `default_chain` (Arjun → Meera → Priya → Zara) when one of these is explicitly true:
29
+ - The routing decision's `problem_type` is `full_screen_review`, OR
30
+ - The user explicitly asked for a "full critique", "full review", "design-critic", or "run all personas"
31
+
32
+ Otherwise:
33
+ - **Narrower problem type:** run only the expert(s) listed in the matching `agents/router.json` rule's `route_to`, in the order their `chain_position` implies. Never include a persona listed under that rule's `never_route_to`.
34
+ - **Ideation / concept-generation ask:** use `ideation_chain` from `agents/chain.json` instead (Meera → Noor + Anuj → Arjun → Zara → Priya; Raj on stalemate only), matching `skills/ux-ideator/SKILL.md`.
35
+
36
+ **Early DS exit (before running the chain):** if `ds_checklist` has any item marked "at risk" from Phase 0.5, and the ask is not itself a DS/brand remediation ask, stop the graph at the DS Gate remediation path — run only DS Gate checks + Arjun in `arjun_color_system_only` scope. Do not run Meera, Priya, or Zara until the DS Gate clears, unless the user explicitly overrides with "run everything anyway."
37
+
38
+ **Parallel execution:** check each persona's manifest for `parallel_safe_with`. If two selected experts list each other there (e.g. Meera and Priya), run them independently — do not require one's output before starting the other. Only sequence experts that actually need a prior handoff.
39
+
40
+ Announce the selected graph and why it's smaller than the full chain, one line: *"Running [chain name] with [persona list] (budget: N) — excluding [excluded personas] per the router. Full chain not run because [reason]."*
41
+
42
+ ---
43
+
44
+ ## Step 3 — Execute adversarial deliberation (v1.19)
45
+
46
+ Read `deliberation-protocol` from your host skills dir (sibling preferred), e.g. `~/.cursor/skills/deliberation-protocol/SKILL.md`, `~/.claude/skills/deliberation-protocol/SKILL.md`, `~/.grok/skills/deliberation-protocol/SKILL.md`, `~/.agents/skills/deliberation-protocol/SKILL.md`, or legacy `~/.claude/commands/deliberation-protocol.md` **first**. Personas **debate** — they do not pass generic handoff documents.
47
+
48
+ **Preferred (CLI):** `npx analyzthis_design run --task "..." [--full] [--satisfaction 0.4] [--max-rounds 3]` — enforces parallel groups, objection rounds, Raj escalation, and writes `deliberation.round_log` to session.
49
+
50
+ **Chat workflow** when not using CLI:
51
+
52
+ 1. Build **context pack** from session: `task_map`, `ds_checklist`, `information_hierarchy`, knowledge bank excerpts
53
+ 2. Run **deliberation groups** from `agents/chain.json` → `deliberation_groups` (critique / ideation / lite)
54
+ 3. **Review mode (rounds 0..N-1):** each persona reads prior outputs, raises grounded objections, asks contextual questions. Default `accepts_prior: false`. Output deliberation JSON block per `agents/deliberation-schema.json`
55
+ 4. **Parallel pairs:** Noor∥Anuj, Meera∥Priya — critique each other's claims in the same round
56
+ 5. **Produce mode (final round):** full output schema only after objections resolve or Raj rules
57
+ 6. After each persona: append to `persona_outputs`, update `digest.prior_scores`, append to `deliberation.round_log`
58
+ 7. **Raj** on stalemate: 2+ blocking objections, repeated claims, or round >= `escalate_to_raj_after_round`
59
+
60
+ Forbidden in review rounds: generic handoff lines without citing a specific prior claim; rewriting full wireframes/critiques before deliberation closes.
61
+
62
+ For reference data: `npx analyzthis_design retrieve --file <csv> --column <col> --keywords <a,b>`
63
+
64
+ Legacy sequential mode: `npx analyzthis_design run --no-deliberate` or skip deliberation-protocol in chat (not recommended).
65
+
66
+ ---
67
+
68
+ ## Step 4 — Hard gates
69
+
70
+ Run in this order, after the chain completes:
71
+
72
+ 1. **DS Gate** — re-check the DS Token Checklist from Phase 0.5. If any item is still "at risk," this blocks a SHIP verdict regardless of composite score.
73
+ 2. **Information Hierarchy Gate** — read `skills/design-critic/SKILL.md`'s Information Hierarchy Gate section and run it against Arjun's Visual Hierarchy grade and Meera's Hierarchy check (only if both ran).
74
+ 3. **Verify Gate** — run `ux-story-gate` Phase 4.5 (browser automation) against the primary task. Record `verify_results` in session state.
75
+
76
+ Any gate failure is inserted into the Top 3 actionable changes automatically, same as the Information Hierarchy Gate rule in `design-critic`.
77
+
78
+ ---
79
+
80
+ ## Step 5 — Synthesize verdict
81
+
82
+ Produce the Task × Finding table (format from `ux-story-gate` Phase 5) or the Composite Score block (format from `design-critic` Phase 5), depending on which graph ran. Include:
83
+
84
+ ```
85
+ ## Orchestrator Run Summary
86
+ Graph: [default_chain / ideation_chain / MoE subset: persona list]
87
+ Experts run: [N] (budget) — [persona list]
88
+ DS Gate: [PASS / FAIL — item(s) at risk]
89
+ Hierarchy Gate: [PASS / FAIL]
90
+ Verify Gate: [pass / fail / not_run]
91
+ Verdict: [SHIP / REVISE / BLOCK]
92
+ Mode: [assess_only / build_approved]
93
+ Est. tokens: [input/output estimate — see metrics in session state]
94
+ ```
95
+
96
+ Update `session-state.json` (`metrics`): `llm_calls`, `experts_run`, `input_tokens_est`, `output_tokens_est`, `cache_hits`, `mode`.
97
+
98
+ If any gate failed or the verdict is BLOCK, escalate to Raj per `design-critic`'s BLOCK escalation rules.
99
+
100
+ **Delta re-evaluation (mandatory on any follow-up after REVISE):** when the user applies changes and asks for a re-check, do NOT re-run the full graph. Read `session-state.json`'s prior `persona_outputs` and Top 3 actionable changes, then run only the persona(s) assigned to those Top 3 items, per `skills/design-critic/SKILL.md`'s Re-evaluation Protocol. Update only the affected `digest.prior_scores` entries and re-check the Information Hierarchy Gate. This is not optional — re-running the full chain on every follow-up is the token-waste failure this system exists to prevent.
101
+
102
+ ---
103
+
104
+ ## Step 6 — Respect assess-only mode
105
+
106
+ Run `ux-story-gate` Phase 5.5. If `mode: assess_only`, stop here — do not write or edit code. If `mode: build_approved`, proceed to implement the P0/P1 fixes named in the synthesis.
107
+
108
+ ---
109
+
110
+ ## Step 6.5 — Capture user corrections and outcomes (v1.16 / v1.21)
111
+
112
+ When the user is **unhappy** with a persona's output or **rewrites/corrects** it, record that signal so future training can learn from mistakes:
113
+
114
+ ```bash
115
+ npx analyzthis_design feedback record --persona arjun --rating 2 \
116
+ --comment "What was wrong" \
117
+ --correction "What they wanted instead" \
118
+ --tags wrong_hierarchy,invented_tokens
119
+ ```
120
+
121
+ Or in one step when rejecting:
122
+
123
+ ```bash
124
+ npx analyzthis_design session accept --persona arjun --reject \
125
+ --comment "..." --correction "..." --rating 2 --tags off_brief
126
+ ```
127
+
128
+ Suggest this when the user says things like *"that's not what I meant,"* *"use our tokens,"* or *"the hierarchy is wrong."* Tags hint: `wrong_hierarchy`, `invented_tokens`, `missed_ds`, `too_verbose`, `bad_ia`, `off_brief`.
129
+
130
+ List or export later: `feedback list`, `feedback export --persona arjun --all`.
131
+
132
+ **Track whether the advice actually shipped.** After the user implements changes, confirm the outcome so the evolution loop can learn:
133
+
134
+ ```bash
135
+ npx analyzthis_design outcome --confirm --persona arjun --result shipped
136
+ # or: revised, blocked_correctly, missed
137
+ ```
138
+
139
+ **Default execution is chunked (v2.0).** `npx analyzthis_design run --task "..."` now uses a frontier planner + cheap chunk models. Use `/run-unchunked` or `npx analyzthis_design run-unchunked` only when you explicitly want the legacy single-pass deliberation chain.
140
+
141
+ **Set visual direction with the team.** Use `/mood-board` when the user wants references and a team-deliberated direction:
142
+
143
+ ```bash
144
+ npx analyzthis_design moodboard create --task "B2B fintech dashboard, trustworthy, high-contrast" --auto
145
+ npx analyzthis_design moodboard critique --board <boardId>
146
+ ```
147
+
148
+ References are tagged, design-system patterns are pulled, and Arjun/Meera/Priya/Zara/Noor deliberate with Honeycomb scoring until consensus.
149
+
150
+ **Evolve the team.** Periodically (e.g., weekly), run:
151
+
152
+ ```bash
153
+ npx analyzthis_design evolve --extract --dry-run # preview proposed patches
154
+ npx analyzthis_design evolve --extract # write patch files for review
155
+ npx analyzthis_design evolve --apply <patchId> --dry-run # preview a patch
156
+ npx analyzthis_design evolve --apply <patchId> # apply after review
157
+ ```
158
+
159
+ This harvests accepted outputs + confirmed outcomes, extracts lessons into `~/.analyzthis_design/lessons/`, and proposes patches to:
160
+ - persona SKILL.md / cards (new canonical failure patterns),
161
+ - `skills/design-reference/*.csv` rows (new product-type guidance),
162
+ - `agents/router.json` rules (task_type → best-performing expert).
163
+
164
+ Patches are **dry-run by default** and require human review before apply.
165
+
166
+ **Share with maintainers (opt-in):** after recording, suggest `npx analyzthis_design feedback submit --yes` so anonymized corrections help improve personas for everyone. Preview first with `--dry-run`.
167
+
168
+ ---
169
+
170
+ ## What this skill is not
171
+
172
+ - **Not a persona.** It has no design opinion — it routes to the ones that do.
173
+ - **Not a replacement for `ux-story-gate` or `design-critic`.** It calls them; it doesn't duplicate their logic.
174
+ - **Not a code generator by default.** Respects assess-only mode like every other skill in this system.
175
+
176
+ ---
177
+
178
+ ## Files this depends on
179
+
180
+ - `agents/router.json` — MoE routing rules
181
+ - `agents/chain.json` — default and ideation chains, deliberation_groups, gate ordering, token caps
182
+ - `agents/deliberation-schema.json` — objection/satisfaction output contract
183
+ - `deliberation-protocol` skill — adversarial review rules (v1.19); host path e.g. `~/.claude/skills/deliberation-protocol/SKILL.md`
184
+ - `agents/session-schema.json` — session state shape, including `digest` and `metrics`
185
+ - `agents/manifests/*.json` — per-persona allowed/forbidden jobs, hard gates, `system_card`, `tier`, `max_output_tokens`
186
+ - `agents/cards/*.md` — short persona system prompts used by default instead of full SKILL.md
187
+ - `skills/ux-story-gate/SKILL.md` — intake phases 0 – 1.5, 4.5, 5.5
188
+ - `skills/design-critic/SKILL.md` — chain handoff format, Information Hierarchy Gate, BLOCK escalation, Re-evaluation Protocol
189
+ - `npx analyzthis_design session init|show|reset` — session state CLI
190
+ - `npx analyzthis_design research --url|--query` — writes `web-context.md` into the session; also load this file alongside the knowledge bank before Step 1. In Cursor/Claude, if the CLI research stub is empty, use WebSearch/WebFetch/Figma MCP and append the result to the same `web-context.md` path.
191
+
192
+ ## Efficiency defaults
193
+
194
+ - Default to the **MoE subset**, not the full chain — see Step 2.
195
+ - Default to **cards + lite schema**, not full SKILL.md + deep schema — see Step 3.
196
+ - Default to **delta re-evaluation** on follow-ups, not a full re-run — see Step 5.
197
+ - Skip Phase 4.5 browser verify when `mode: assess_only` and no running URL is available; record `verify_results.primary_task: "not_run"` rather than skipping silently.
@@ -20,6 +20,13 @@ You are Priya. Senior full-stack engineer, 8+ years in complex SaaS. Blunt, prec
20
20
 
21
21
  **Assess-only:** if the user asked to assess/propose/critique rather than build/implement/ship, stop at the feasibility analysis — do not edit code.
22
22
 
23
+
24
+ ## Lite output (default)
25
+
26
+ Verdict or one moment. Top three fixes (or one delight). One evidence line.
27
+ Use the full output schema below only if the user says expand.
28
+ You cannot know host tokens. Do not invent a dollar figure.
29
+
23
30
  ## Lens
24
31
 
25
32
  1. **Technical complexity** — CRUD vs state machine vs new infrastructure
@@ -22,6 +22,13 @@ You are Raj. 10+ years product strategy across SaaS, marketplace, and workflow a
22
22
 
23
23
  **Assess-only:** if the user asked to assess/propose/critique rather than build/implement/ship, stop at the arbitration verdict — do not edit code.
24
24
 
25
+
26
+ ## Lite output (default)
27
+
28
+ Verdict or one moment. Top three fixes (or one delight). One evidence line.
29
+ Use the full output schema below only if the user says expand.
30
+ You cannot know host tokens. Do not invent a dollar figure.
31
+
25
32
  ## When to activate (Stalemate Protocol)
26
33
 
27
34
  ONLY when one of these conditions is met:
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: receipt
3
+ description: Show inferred token spend for this project's last slash and MCP turns. Not a bill. Use after a critique when you want to see tokens-per-verdict.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Receipt
8
+
9
+ You cannot know Claude’s real usage from slash alone. Do not invent a dollar figure.
10
+
11
+ ## What to do
12
+
13
+ 1. Run `npx analyzthis_design receipt` in this project, or call the MCP tool `analyzthis_receipt`.
14
+ 2. Report the printed inferred tokens and tokens-per-verdict exactly.
15
+ 3. Label them **inferred**, never verified, never a monthly dollar.
16
+
17
+ If there is no session yet: `npx analyzthis_design session init`, then run a critique, then receipt.
@@ -11,343 +11,10 @@ The personas (Noor, Anuj, Arjun) are the rooms. This is the front door.
11
11
 
12
12
  ---
13
13
 
14
- ## Phase 0 — PRD Discovery (runs before anything else)
14
+ ## Lite output (default)
15
15
 
16
- Before asking the user for anything, scan for existing context in this order:
16
+ Verdict or one moment. Top three fixes (or one delight). One evidence line.
17
+ Expand the full schema only if the user says expand.
18
+ Call retrieve for the rest of this skill (kind=skill). You cannot know host tokens. Do not invent a dollar figure.
17
19
 
18
- ### 0a Check the knowledge bank
19
-
20
- Read the knowledge-bank skill from your host's skills dir (sibling `knowledge-bank` preferred), e.g. `~/.cursor/skills/knowledge-bank/SKILL.md`, `~/.claude/skills/knowledge-bank/SKILL.md`, `~/.grok/skills/knowledge-bank/SKILL.md`, `~/.agents/skills/knowledge-bank/SKILL.md`, or legacy `~/.claude/commands/knowledge-bank.md`.
21
-
22
- Look for sections containing:
23
- - User stories (`As a [persona], I want to...`, `Given / When / Then`)
24
- - Acceptance criteria, PRD sections, requirements
25
- - Named user personas with roles and tasks
26
- - Epics, features, job-to-be-done statements
27
- - Any section titled or tagged: PRD, requirements, user-stories, specs, product-context
28
-
29
- If the knowledge bank contains relevant content for the screen being reviewed: **extract it into a draft task map** (see format in Phase 1). Mark each entry with `[source: knowledge-bank]`.
30
-
31
- ### 0b — Scan the current repo
32
-
33
- Look for files matching these patterns in the project root and common sub-directories:
34
- - `PRD*.md`, `*prd*.md`, `*requirements*.md`, `*user-stories*.md`, `*specs*.md`
35
- - `docs/**/*.md`, `specs/**/*.md`, `requirements/**/*.md`, `planning/**/*.md`
36
- - Any `.md` file containing keywords: "user story", "acceptance criteria", "as a [role]", "given when then", "persona", "job to be done", "JTBD", "done when", "fails when"
37
-
38
- Read all matching files. Extract task-relevant content. Mark each entry with `[source: filename]`.
39
-
40
- ### 0c — Build a draft task map from discovered content
41
-
42
- From everything found in 0a and 0b, construct a draft task map using the format:
43
-
44
- ```
45
- PERSONA: [named role from the PRD / story]
46
- TASK: [verb + object — extracted or inferred from acceptance criteria]
47
- FREQUENCY: [daily / weekly / one-time / first-time-only — from PRD or inferred]
48
- DONE WHEN: [success condition from acceptance criteria, or inferred]
49
- FAILS WHEN: [failure condition from acceptance criteria, or inferred]
50
- SOURCE: [knowledge-bank / filename]
51
- ```
52
-
53
- Present the draft task map to the user:
54
-
55
- > "I found the following tasks relevant to this screen in [sources]. Does this capture what the screen needs to support? Add, remove, or correct anything before I proceed — I'll run the critique against your confirmed version, not my guess."
56
-
57
- If the user confirms: proceed to Phase 1 with the confirmed task map.
58
- If the user corrects: apply corrections, confirm again, then proceed.
59
-
60
- ### 0d — If no PRD context found anywhere
61
-
62
- If no relevant content is found in the knowledge bank or the repo, switch to the manual intake mode from Phase 1 below.
63
-
64
- If the user has a vault but hasn't synced it:
65
-
66
- > "I don't see a knowledge bank connected. If you have PRDs or user stories in an Obsidian vault or docs folder, run `npx analyzthis_design connect --vault /path/to/vault && npx analyzthis_design sync` to make them available. I'll read them automatically next time.
67
- > For now — tell me the tasks this screen needs to support:"
68
-
69
- ---
70
-
71
- ## Phase 0.5 — Design System & Figma Discovery (GATE)
72
-
73
- **Purpose:** No persona touches brand color, contrast, or component styling before the design system is on the table. This is the fix for personas inventing hex values or patching contrast with `!important`.
74
-
75
- ### 0.5a — Figma discovery (if a Figma URL is present in the ask)
76
-
77
- If the user shared a `figma.com` URL, this is **mandatory before any persona speaks**:
78
- 1. Call the Figma MCP `get_screenshot` for the linked node — this is the visual ground truth.
79
- 2. Call the Figma MCP `get_variable_defs` for the linked node — this is the token ground truth (colors, type scale, spacing).
80
- 3. Write both to session state (`figma_node.url`, `figma_node.confirmed: true`) via `npx analyzthis_design session init` / the session file directly.
81
-
82
- If no Figma URL is present, proceed without this step and note `figma_node.confirmed: false`.
83
-
84
- ### 0.5b — Brand / design-system tokens
85
-
86
- Read the `## Brand & Design Guidelines` section of the knowledge bank (`~/.cursor/skills/knowledge-bank/SKILL.md` or platform equivalent).
87
-
88
- - **If found:** extract the token set (colors, type scale, spacing scale, component library) into the DS Token Checklist below.
89
- - **If missing:** flag it and ask the user directly:
90
-
91
- > "I don't see brand or design-system tokens in the knowledge bank. Before I let any persona touch color, spacing, or component choices, I need your token source — a Figma variables link, a design-tokens file, or a short list of approved hex/spacing values. Without this, Arjun's Color System and Style Fit grades will be marked unverified."
92
-
93
- ### 0.5c — DS Token Checklist (exit criteria for this phase)
94
-
95
- Output before proceeding, and re-check it after any visual fix is proposed:
96
-
97
- ```
98
- ## DS Token Checklist
99
- No invented hex / no !important overrides: [ ] confirmed / [ ] at risk
100
- Kit components preferred over custom CSS: [ ] confirmed / [ ] at risk
101
- Light/dark surfaces sourced from tokens only: [ ] confirmed / [ ] at risk
102
- Contrast checked against WCAG: [cite ux-guidelines row, or "not yet checked"]
103
- ```
104
-
105
- Persist this to `session-state.json` (`ds_checklist`). Any item left "at risk" travels with the task map into Phase 4 routing — it forces the **DS Gate** route from Phase 1.5, not a direct Zara or Noor-alone pass.
106
-
107
- ---
108
-
109
- ## Phase 1 — Task Map Intake (GATE)
110
-
111
- **Used when Phase 0 finds no context, or to supplement what was found.**
112
-
113
- A valid task map must contain, for each task:
114
-
115
- ```
116
- PERSONA: [named persona — Retailer Admin / Media Sales / Ad Ops Manager / etc.]
117
- TASK: [verb + object — "Import a Google audience by ID"]
118
- FREQUENCY: [daily / weekly / one-time / first-time-only]
119
- DONE WHEN: [the user knows the task succeeded because...]
120
- FAILS WHEN: [the user knows something went wrong because...]
121
- ```
122
-
123
- **If a valid task map is present (from Phase 0 or user input):** proceed to Phase 2.
124
-
125
- **If no task map is present:** do NOT proceed. Ask:
126
-
127
- > "Before I run any critique, I need the task map for this screen. For each user task this screen should support, tell me:
128
- > - Which persona? (e.g. Retailer Admin, Media Sales)
129
- > - What task? (verb + object)
130
- > - How often? (daily / weekly / one-time)
131
- > - Done when? (one sentence)
132
- > - Fails when? (one sentence)
133
- >
134
- > Once I have these, I'll route to the right personas grounded in your tasks — not abstract principles."
135
-
136
- Never assume a task map. Never infer tasks from the screen description alone. If PRD context was found but incomplete, ask only for the missing fields — not the whole form.
137
-
138
- ---
139
-
140
- ## Phase 1.5 — Problem-Type Router (MoE)
141
-
142
- **Purpose:** Pick the right expert(s) for the problem, not the loudest persona for the screen type. This is a Mixture-of-Experts router: it classifies the ask into a problem type, then reads `agents/router.json` to select which personas run and which are explicitly excluded.
143
-
144
- 1. Classify the confirmed task map + DS Token Checklist into one or more problem types using the table below (mirrors `agents/router.json`):
145
-
146
- | Problem signal | Route to | Never route to |
147
- |---|---|---|
148
- | Structure / IA / nested UI | **Noor** | Zara |
149
- | UX friction / accessibility / responsive | **Arjun** | Zara for contrast fixes |
150
- | Brand / tokens / contrast / DS compliance | **DS Gate** then Arjun Color System only | Zara, Noor alone |
151
- | Business priority / metric alignment | **Meera** | — |
152
- | Build size / modal vs wizard | **Priya** | — |
153
- | Delight / onboarding peak moment | **Zara** (only after DS Gate passes) | — |
154
- | Daily-use density / bulk actions | **Anuj** (only if Frequency = daily/weekly) | — |
155
- | Stalemate / BLOCK | **Raj** | — |
156
-
157
- 2. Write the routing decision to `session-state.json` (`routing_decision: { problem_type, experts, reason }`) — e.g. via the session file, so later phases and persona hand-offs don't re-derive it.
158
- 3. Announce the decision in one line per persona:
159
-
160
- > "Routing to **Arjun** — Task 2 has an unresolved contrast risk (DS Gate item 'at risk'). **Zara excluded** — delight is out of scope until the DS Gate clears."
161
-
162
- If any DS Token Checklist item is "at risk," the DS Gate route takes precedence over any other route for that task — no persona touches color/contrast/tokens until it clears. This also means: **do not run Meera, Priya, or Zara yet** — stop at DS Gate remediation + Arjun's Color System dimension only, and resume the rest of the chain once the checklist clears (or the user explicitly says to proceed anyway).
163
-
164
- **Expert budget:** default to the smallest expert set that covers the routed problem type(s) — usually 1–2 personas. Only expand to the full Noor+Anuj+Arjun+Meera+Zara routing table in Phase 4 below when the ask is a genuine full-screen review, not a narrow question.
165
-
166
- ---
167
-
168
- ## Phase 2 — Field Veto Pass
169
-
170
- **Purpose:** Catch fields and elements that exist without a task owner before personas evaluate them.
171
-
172
- Scan the screen description for every distinct field, button, label, and section. For each, run the veto test:
173
-
174
- > *"Which persona, in which task from the confirmed task map, would fail if this element didn't exist?"*
175
-
176
- Output: a Field Veto Table.
177
-
178
- ```
179
- | Element | Task it serves | Verdict |
180
- |------------------|--------------------|-----------------|
181
- | Cohort Name | Task 1, Task 2 | ✅ Keep |
182
- | Tags (max 3) | None | ❌ Cut / Justify|
183
- | Audience ID | Task 2 | ✅ Keep |
184
- | Description | [task unclear] | ⚠️ Clarify |
185
- ```
186
-
187
- Three verdicts only:
188
- - **✅ Keep** — maps to at least one task
189
- - **❌ Cut** — no task owner; recommend removal before personas run
190
- - **⚠️ Clarify** — ambiguous; ask the user to confirm which task this serves before proceeding
191
-
192
- Do not remove fields. Flag and ask. User confirms. Then proceed.
193
-
194
- ---
195
-
196
- ## Phase 3 — Scale & States Declaration
197
-
198
- **Purpose:** Force the two questions most commonly skipped in story-writing.
199
-
200
- **Scale question (required for any screen with a list or table):**
201
-
202
- > "At how many rows does this screen need to work? (e.g. 10 / 100 / 1000+)"
203
- > "Does the list need sorting? If yes, which columns and what's the default order?"
204
- > "Does the list need filtering? If yes, which filters, and should selected state persist across sessions?"
205
-
206
- If scale is not declared, flag: *"Scale not specified. Personas will note this as unverified and may give incomplete Usable scores."*
207
-
208
- **States checklist (required for every screen):**
209
-
210
- Check the input for all four states. Flag any that are missing before personas run.
211
-
212
- ```
213
- EMPTY STATE: [what the user sees at zero data — does it teach the next action?]
214
- ERROR STATE: [what the user sees when input is wrong — is recovery actionable?]
215
- LOADING STATE: [skeleton / spinner / nothing — is perceived latency acceptable?]
216
- EDGE STATE: [what the user sees at max scale / stale data / partial data]
217
- ```
218
-
219
- If a state is missing: *"[State] not defined. Arjun will flag this as untested — defining it now will produce a more accurate Credible score."*
220
-
221
- Can proceed with undefined states, but mark them explicitly as gaps that will surface in persona output.
222
-
223
- ---
224
-
225
- ## Phase 4 — Persona Routing
226
-
227
- **Purpose:** Select the right personas for the task map, not for the screen type. This refines the Phase 1.5 MoE decision down to per-task assignments.
228
-
229
- Read the confirmed task map and route based on task characteristics:
230
-
231
- | Task characteristic | Route to |
232
- |---|---|
233
- | Any creation / form / IA structure task | Noor |
234
- | Any daily-use / list / scan / sort / filter task (Frequency = daily or weekly) | Anuj |
235
- | Any task with a named error / empty / loading state risk | Arjun |
236
- | Any task involving pricing, access control, or business rules | Flag for Meera |
237
- | Any task involving a first-time / onboarding experience | Flag for Zara |
238
-
239
- Always route to at least **Noor + Arjun**. Add **Anuj** whenever any task has Frequency = daily or weekly.
240
-
241
- Announce routing decisions — one line each:
242
-
243
- > "Routing to **Noor** — Tasks 1 and 2 are creation flows with IA structure decisions.
244
- > Routing to **Anuj** — Tasks 4 and 5 are daily-use list tasks at 100+ rows.
245
- > Routing to **Arjun** — Task 2 has an unrecovered error state risk; Task 1 has an undefined empty state."
246
-
247
- Each persona receives:
248
- 1. The confirmed task map (not the raw screen description)
249
- 2. The Field Veto Table with verdicts
250
- 3. The Scale declaration
251
- 4. The States checklist with gaps flagged
252
- 5. The instruction: *"Evaluate only against the tasks in this map. Do not evaluate against abstract principles unless they directly explain a task failure."*
253
-
254
- ---
255
-
256
- ## Phase 4.5 — Verify Gate (Browser Automation)
257
-
258
- **Purpose:** No screen is declared done on the strength of a critique alone. This is the fix for bugs that personas miss and users catch — the critique must be checked against a running browser, not just read off a screenshot.
259
-
260
- Run this after the persona chain completes, before Phase 5 synthesis:
261
-
262
- 1. **Navigate** to the screen under review (`browser_navigate`).
263
- 2. **Snapshot** the page (`browser_snapshot`) to confirm structure matches what personas critiqued.
264
- 3. **Click through the primary task** from the confirmed task map — the highest-priority task, end to end (`browser_click`, `browser_type`, etc.).
265
- 4. **Screenshot** at both mobile and desktop viewports.
266
- 5. Record the result in `session-state.json` (`verify_results: { primary_task: "pass" | "fail", screenshots: [...] }`).
267
-
268
- **FAIL conditions — do not declare the screen done if any of these are true:**
269
- - The primary interaction is broken (e.g. state cycling incorrectly, stuck loading, dead click)
270
- - Modal/dialog roles are missing or focus is not trapped
271
- - Contrast visibly fails at either viewport despite the DS Gate marking it "confirmed"
272
-
273
- If verification fails, loop back: flag the specific broken step, do not proceed to Phase 5 synthesis until it's fixed or explicitly deferred by the user.
274
-
275
- If browser tools are unavailable in the current environment, state this explicitly and mark `verify_results.primary_task: "not_run"` — do not silently skip the gate.
276
-
277
- **Skip condition (still explicit, not silent):** if `mode: assess_only` (see Phase 5.5) and no running URL is available to navigate to, do not attempt this phase — record `verify_results.primary_task: "not_run"` with the reason "assess_only, no URL" and move to Phase 5. This avoids burning a browser-automation pass on a proposal nobody asked to be built yet.
278
-
279
- ---
280
-
281
- ## Phase 5 — Synthesis Output
282
-
283
- After all routed personas complete their critiques, synthesise into a Task × Finding table:
284
-
285
- ```
286
- | Task | Status | Noor | Anuj | Arjun | Priority |
287
- |------|--------|------|------|-------|----------|
288
- | Task 1: Create My Cohort | ❌ | Paths not built | No bulk import | Empty state undefined | P0 |
289
- | Task 2: Import by ID | ⚠️ | — | — | No format hint, silent fail | P0 |
290
- | Task 3: Set pricing | ✅ | Remove asterisks | — | — | P1 |
291
- | Task 4: Daily list scan | ❌ | — | 6 columns missing, no sort | Credible D at 100+ rows | P0 |
292
- | Task 5: Filter / persist | ❌ | — | No persisted state | — | P0 |
293
- ```
294
-
295
- Priority is set by the gate, not by any persona:
296
- - **P0** — task cannot be completed at all, or fails on first attempt
297
- - **P1** — task can be completed but with significant friction
298
- - **P2** — task completes but with minor friction or missing polish
299
-
300
- End with a build-ready verdict:
301
-
302
- > *"[N] tasks are P0 — these must be resolved before the screen ships. [N] tasks are P1 — these should ship in the same sprint. [N] tasks are P2 — these can follow."*
303
-
304
- ---
305
-
306
- ## Phase 5.5 — Assess-Only Mode
307
-
308
- **Purpose:** Fix the "Ask/Agent double spend" failure — a user who asked for an assessment should not wake up to code changes they didn't approve.
309
-
310
- Check the original ask for intent before writing or editing any code:
311
-
312
- - If the user's language was **assess / propose / critique / review / what's wrong / evaluate**: this is `assess_only` mode. Output stops at the Phase 5 synthesis and the proposed fixes. Set `session-state.json` (`mode: "assess_only"`). Do not touch code.
313
- - If the user's language was **build / implement / apply / fix it / ship it**: this is `build_approved` mode. Proceed to implement the P0/P1 fixes from the synthesis table. Set `mode: "build_approved"`.
314
- - If intent is ambiguous, default to `assess_only` and ask: *"I've completed the assessment above — want me to implement the P0 fixes now, or would you like to review the proposal first?"*
315
-
316
- This gate applies to every persona downstream, not just the gate itself — restate `mode` when handing off to `design-critic` or any individual persona.
317
-
318
- ---
319
-
320
- ## Trigger phrases
321
-
322
- Use this skill when you see:
323
- - "Review this screen" / "What's wrong with this?" / "Critique this"
324
- - "Are we building this right?"
325
- - "Does this match the user task?"
326
- - "Run the personas on this"
327
- - "Evaluate this before we build"
328
- - Any Figma link, screenshot, or screen description shared without a task map
329
-
330
- ---
331
-
332
- ## What this skill is not
333
-
334
- - **Not a persona.** No design opinion of its own.
335
- - **Not a PRD generator.** Does not write stories. Validates that stories were written correctly before design evaluation begins.
336
- - **Not a replacement for the personas.** Noor, Anuj, and Arjun still run in full. This ensures they run on the right input.
337
- - **Not optional.** If someone invokes `/noor`, `/anuj`, or `/arjun` directly without a task map, they bypass the gate. Use this as the entry point for any screen evaluation. For a fully agentic run (routing + chain + gates + session state in one call), prefer `/persona-orchestrator`.
338
-
339
- ---
340
-
341
- ## Persona skills this depends on
342
-
343
- - `~/.cursor/skills/noor/SKILL.md`
344
- - `~/.cursor/skills/anuj/SKILL.md`
345
- - `~/.cursor/skills/arjun/SKILL.md`
346
- - `~/.cursor/skills/knowledge-bank/SKILL.md` (for Phase 0 PRD discovery)
347
-
348
- ## Agentic layer this depends on
349
-
350
- - `agents/router.json` — MoE routing table used in Phase 1.5
351
- - `agents/session-schema.json` — shape of the session state written throughout this gate
352
- - `npx analyzthis_design session init|show|reset` — CLI for reading/writing session state between turns
353
- - For a fully orchestrated run instead of using this gate directly, use `skills/persona-orchestrator/SKILL.md`
20
+ Retrieve the full lens: `analyzthis_retrieve` kind=skill file=ux-story-gate (or `npx analyzthis_design retrieve` after MCP).