baldart 3.15.0 → 3.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,60 @@ All notable changes to BALDART will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.17.0] - 2026-05-23
9
+
10
+ The `/prd` skill gains a third option in the design phase. Until v3.16.0, when a user reached Step 3 without having provided mockups (`mockups.status: none`), the only path forward was internal generation via the `ui-design` skill (3 HTML options → iteration → save). With Claude Design now offering a design-system-sync'd visual generator, users who prefer iterating in that surface had to abandon the PRD flow halfway, work externally, and then re-enter as if they'd had mockups from the start. This release adds **Step 3.0 — Mockup Source Decision**: when `mockups.status: none` AND UI impact ≠ N/A, the skill explicitly asks "internal generation or handoff to Claude Design?". The handoff branch generates a context-rich prompt (discovery + brand voice + design-system tokens + screens in scope + stack target) ready to paste, then STOPs. On user re-entry with local paths, it re-uses the existing Step 1.6 Mockup Intake verbatim — copy → analyze → populate state — and Step 3 falls naturally into Hybrid mode. Zero code paths downstream of the bivio are new; the entire feature is a decision point + a prompt generator on top of pre-existing infrastructure.
11
+
12
+ ### Added — PRD Step 3.0 Mockup Source Decision
13
+
14
+ - **§ Step 3.0 in [framework/.claude/skills/prd/references/ui-design-phase.md](framework/.claude/skills/prd/references/ui-design-phase.md)** before the precondition decision tree. Activates only when `mockups.status: none` AND UI impact ≠ N/A. Poses the binary question (Internal `ui-design` vs Handoff Claude Design) with explicit STOP gate — silence or ambiguity re-asks rather than defaulting silently. Branch A sets `mockups.source: internal` and falls through unchanged. Branch B collects context from state file + `baldart.config.yml` + `.baldart/overlays/prd.md` + `${paths.design_system}/INDEX.md` + `tokens-reference.md` (when `features.has_design_system: true`), renders the handoff prompt template, presents it inside a fenced code-block with copy-paste instructions, persists `mockups.status: pending_external` + `mockups.source: claude-design` + `mockups.handoff_prompt_path` in the state file (prompt saved to `${paths.prd_dir}/<slug>/handoff/claude-design-prompt.md` for session-restart survival), and STOPs.
15
+ - **Re-entry handler in same file**. When the user returns with local paths after handoff, the skill invokes the existing Step 1.6 Mockup Intake procedure verbatim (no code duplication) — copy into `mockups/` with collision-safe rename, run Mockup analysis schema, populate `## UI Design`. Then flips `mockups.status` from `pending_external` to `provided` or `partial` based on coverage of `screens_in_scope[]`, keeps `mockups.source: claude-design` as audit trail, and falls through to the precondition decision tree which routes to Hybrid mode unchanged.
16
+ - **Precondition decision tree extended** with two new rows: `mockups.status: pending_external` ⇒ STOP (handoff in flight); `mockups.status: none` AND user picked Branch A ⇒ Full (preserves backwards-compatible default). The existing `provided` / `partial` ⇒ Hybrid and UI = N/A ⇒ Skip rows are unchanged.
17
+ - **New template asset [framework/.claude/skills/prd/assets/claude-design-handoff-prompt.template.md](framework/.claude/skills/prd/assets/claude-design-handoff-prompt.template.md)**. Seven-section structure populated at runtime: (1) feature objective, (2) user flow + personas, (3) screens in scope with required states + primary actions + data shown, (4) brand & voice (conditional on overlay), (5) design system constraints with tokens excerpt + registered primitives + numeric tables from `framework/agents/design-system-protocol.md` (conditional on `features.has_design_system: true`), (6) stack target + output format preference derived from `stack.framework`, (7) deliverable spec (PNG exports per state + code/Figma + inline notes on new components / token deviations / layout decisions). Generic and project-agnostic — all project-specific content is injected as placeholders.
18
+ - **Hard Rule 16 note in [framework/.claude/skills/prd/SKILL.md](framework/.claude/skills/prd/SKILL.md)** added to the existing Mockup Intake rule. Codifies that a NO answer at intake routes through Step 3.0 (not directly to Full mode), with cross-reference to the ui-design-phase section. The rule itself remains unchanged for backwards compatibility — Step 3.0 is purely additive.
19
+
20
+ ### Notes
21
+
22
+ - **No new `baldart.config.yml` keys** — the schema-change propagation rule does not apply to this release. The bivio is runtime-only per the user's preference (zero persistent flag); no template/configure/update/doctor updates needed. All context for the handoff prompt is read from existing config keys (`paths.*`, `stack.*`, `features.has_design_system`).
23
+ - **Backwards compatibility.** PRDs in flight on v3.16.x finish on v3.16.x semantics. New PRD sessions started on v3.17.0+ see Step 3.0 only when they actually reach Step 3 with `mockups.status: none` — the default (Branch A) preserves the v3.16.x behavior exactly. Existing PRDs that already provided mockups never enter Step 3.0.
24
+ - **`ui-design` skill is unchanged** — Step 3.0 sits in front of it, doesn't modify it. The Full pipeline (3a → 3d) is reached identically when the user picks Branch A or when no mockup-related state exists at all. The `ui-expert` agent and `huashu-design`/`frontend-design` skills are equally untouched.
25
+ - **`mockup_analysis` schema is unchanged** — the new `pending_external` value of `mockups.status` is purely transitional and is overwritten by `provided` / `partial` on user re-entry, so existing PRD templates and state files keep validating without migration.
26
+ - **Files modified outside the Step 3.0 scope** (`card-template.yml`, `backlog-phase.md`, `validation-phase.md`, `prd-card-writer.md`, `framework/.claude/skills/new/SKILL.md`) are the v3.16.0 in-flight release (agent routing + UI specialist briefing — see entry below) and are NOT part of v3.17.0. v3.16.0 should be tagged and pushed before v3.17.0 in the release sequence.
27
+ - **Verification is manual** (no test suite). Dogfood scenarios: (1) `/prd` with mockups provided at intake → never enters Step 3.0, Hybrid mode as today (regression check); (2) `/prd` without mockups, answer "A" at Step 3.0 → Full mode runs identically to v3.16.x; (3) `/prd` without mockups, answer "B" → prompt rendered with discovery + tokens + screens + stack, saved to `handoff/`, state shows `pending_external`, skill STOPs; (4) simulate re-entry with a PNG path → file copied to `mockups/`, status flips to `provided`, Step 3 enters Hybrid mode invoking `ui-design` only for uncovered screens; (5) `features.has_design_system: false` → § 5 of the rendered prompt is omitted entirely; (6) no overlay present → § 4 brand voice omitted.
28
+
29
+ ## [3.16.0] - 2026-05-23
30
+
31
+ The `/new` orchestrator becomes specialist-aware: it now reads `owner_agent` from each card YAML and dispatches the right implementation agent — `coder` for backend/logic, `ui-expert` for UI cards, with `plan`/`visual-designer`/`motion-expert` reserved as stubs that fall back to `coder` with a WARN. UI cards (`owner_agent: ui-expert`) receive a dedicated mission briefing that enforces the registry-first BLOCKING cascade (read `${paths.design_system}/INDEX.md` + `tokens-reference.md` + per-component specs BEFORE coding), the implementation-only constraint (no mockup redesign — STOP and ask on registry conflicts), and the Post-Intervention Coherence Check (reconcile INDEX + components + tokens in the same commit). The PRD side enforces the contract end-to-end: `owner_agent` is now a mandatory enum on every child card, UI cards have UI-only scope (logic moves to a sibling `coder` card), and the validation phase blocks commit on enum violations + warns on mixed-scope UI cards.
32
+
33
+ Until now, every card from `/new` was spawned to the generic `coder` agent regardless of `owner_agent`, and mockups arrived as a textual "match this reference" hint without triggering the registry/tokens/specs cascade that `ui-expert` mandates. The symptom reported by users: graphical code generated from mockups was "not quite right" — wrong shadows, off-scale font sizes, off-palette colors. Root cause: the right specialist existed and PRD cards declared it (`owner_agent: ui-expert`), but the dispatcher never read the field.
34
+
35
+ ### Added — Agent router + UI specialist briefing
36
+
37
+ - **§ Agent Routing section in [framework/.claude/skills/new/SKILL.md](framework/.claude/skills/new/SKILL.md)** between Pre-flight and Per-card pipeline. Documents the `owner_agent` → spawn-target mapping in a single table (coder | ui-expert | plan | visual-designer | motion-expert → resolved agent + briefing variant) with a cross-reference list of the 5 layers that must stay in lockstep (template, prd.md enum, prd-card-writer rule, validation-phase check, REGISTRY.md decision tree).
38
+ - **Step 6b "Agent dispatch (router)" in Phase 2** of [framework/.claude/skills/new/SKILL.md](framework/.claude/skills/new/SKILL.md). Reads `card.owner_agent`, resolves the spawn target via a switch with explicit fallbacks: `coder` → coder briefing; `ui-expert` → ui-expert briefing; `plan`/`visual-designer`/`motion-expert` → coder briefing + WARN ("specialized briefing not yet implemented"); empty/`claude`/missing → coder briefing + WARN; unknown value → HALT and ask the user. The resolved spawn + briefing pair is logged in the tracker as the audit trail.
39
+ - **`[UI-ONLY]` mission briefing sections** in Phase 2 step 7 of [framework/.claude/skills/new/SKILL.md](framework/.claude/skills/new/SKILL.md). Three new sections inserted between "Design Reference" and "File Permissions", included ONLY when the router resolves `briefing = "ui-expert"`:
40
+ - **Registry-first BLOCKING pre-work** — reproduces verbatim the cascade defined in [framework/.claude/agents/ui-expert.md](framework/.claude/agents/ui-expert.md) § "Registry-first pre-work (BLOCKING)": read `INDEX.md` + `tokens-reference.md` + `components/<Name>.md` for every primitive in scope, declare which Authority Matrix rows govern the card in the first response. Orchestrator rejects the implementation if the declaration is missing.
41
+ - **Implementation-only constraint** — explicit DO NOTs: don't redesign the mockup, don't silently adapt registry-conflicting details (STOP + `[DS-DRIFT] mockup-vs-registry` log + ask the user), don't extend scope into business logic / API / state / validation (split-into-sibling-card is upstream PRD concern).
42
+ - **Post-Intervention Coherence Check** — citation of [framework/agents/design-system-protocol.md](framework/agents/design-system-protocol.md) § "Post-Intervention Coherence Check": reconcile `INDEX.md` (drift code `DS_INDEX_DRIFT`) + `components/<Name>.md` (`DS_COMPONENT_STALE`) + `tokens-reference.md` (`DS_TOKENS_DRIFT`) in the same commit. The completion report MUST include a `design_system_coherence:` block enumerating the artifacts updated.
43
+ - **`[UI-ONLY]` design-system conformance step in Phase 2.5** of [framework/.claude/skills/new/SKILL.md](framework/.claude/skills/new/SKILL.md). New row in the Completeness Check verification depth, runs only when `briefing = "ui-expert"` AND `features.has_design_system: true`. Greps changed files for hardcoded design values that bypass the registry (hex colors, `rgb(`, inline `box-shadow:` offsets, raw px/rem `border-radius:`/`font-size:`/spacing); verifies the `design_system_coherence:` block in the completion report; verifies new primitives ship their `components/<Name>.md` spec in the same commit; verifies new tokens land in `tokens-reference.md`. Each gap classified Partial → fix-coder sub-loop.
44
+
45
+ ### Added — PRD-side enforcement (split-scope + mandatory enum)
46
+
47
+ - **§ MANDATORY Card Rules (Rule A + Rule B)** in [framework/.claude/skills/prd/references/backlog-phase.md](framework/.claude/skills/prd/references/backlog-phase.md). New section between MANDATORY Card Structure and Specialist Audits. **Rule A**: every child card MUST declare `owner_agent` with one of the five enum values; missing/empty/placeholder/non-enum BLOCKS commit. **Rule B**: cards with `owner_agent: ui-expert` MUST be UI-only — components, layout, styling, motion, accessibility — and MUST NOT bundle business logic, API integration, state management, validation logic, or backend changes; mixed steps split into a `ui-expert` card (visual, consumes mocked contract) + a `coder` card (logic, API, state) wired via `depends_on:`/`blocks:`. Ships a canonical Login feature split example (bad: single mixed card; good: `FEAT-XXXX-02` UI + `FEAT-XXXX-01` logic).
48
+ - **§ Agent Specialization Rules in [framework/.claude/agents/prd-card-writer.md](framework/.claude/agents/prd-card-writer.md)** before Card Atomicity Rules. The same Rule A + Rule B formulated from the agent writer's POV (which value to pick per work type, what NOT to bundle, when not to assign `ui-expert` to a tight-knit mixed card). Cross-references the backlog-phase split example for canonical guidance.
49
+ - **§ Step 6 Agent Specialization Audit (new step 0)** in [framework/.claude/skills/prd/references/validation-phase.md](framework/.claude/skills/prd/references/validation-phase.md). Runs FIRST, before the Field Name Audit. Step 0a: `owner_agent` enum check (BLOCKING) — halts the audit on missing/empty/placeholder/non-enum with an actionable message. Step 0b: UI-only scope heuristic (WARN, soft gate) — for each `ui-expert` card, greps `scope.summary` + `requirements` + `acceptance_criteria` for logic markers (`api call`, `endpoint`, `route handler`, `state machine`, `validation logic`, `business rule`, `database`, `migration`, `prisma`, `auth flow`, `token storage`, `webhook`, `cron`) and emits `[UI-SCOPE-WARN]` lines for human review. Intentionally soft: legitimate UI references to mocked contracts ("consumes `useAuth()` mock") don't trip the WARN thanks to the consume/mock/contract-reference exception.
50
+ - **§ Card-template fields updated** in [framework/.claude/skills/prd/assets/card-template.yml](framework/.claude/skills/prd/assets/card-template.yml). The placeholder `owner_agent: claude` is replaced with `owner_agent: <REQUIRED — coder | ui-expert | plan | visual-designer | motion-expert>` so a card left at the placeholder fails validation. A leading comment block documents each enum value (one line each) and a comment under `scope:` reminds the writer of the UI-only constraint for `ui-expert` cards.
51
+ - **§ Epic-template aligned to the tracker-only contract** in [framework/.claude/skills/prd/assets/epic-template.yml](framework/.claude/skills/prd/assets/epic-template.yml). `owner_agent` changes from the legacy `claude` placeholder to `""` (empty string) with an inline comment clarifying that epics are tracker-only — the dispatcher skips them and the validation-phase enum-check exempts them — so the empty value is the correct signal that no specialist is assigned to an epic. Prevents the false-positive of writing a child enum value (e.g. `coder`) on an epic and implying it carries implementation work.
52
+
53
+ ### Notes
54
+
55
+ - **No new `baldart.config.yml` keys** — the schema-change propagation rule does not apply to this release. The router consumes an existing field (`owner_agent`) already present in the PRD card schema.
56
+ - **Backwards compatibility for cards written before v3.16.0.** The dispatcher accepts `owner_agent: ""` / missing / legacy `claude` value via the WARN-and-fallback-to-coder branch, so existing backlogs keep working — the WARN surfaces the gap on first use without blocking. New PRD sessions on v3.16.0+ produce enum-compliant cards from the start; the validation phase's enum BLOCKER applies only to NEW cards generated under v3.16.0+.
57
+ - **Specialist briefings for `plan` / `visual-designer` / `motion-expert` are stubs** in this release — they fall back to the coder briefing with a WARN. Specialized briefings will follow in future iterations without further schema changes (the router structure is already in place).
58
+ - **`ui-expert` in `/new` is implementation-only by design** — refinement of the mockup remains a PRD-phase responsibility (the `ui-design-phase` skill handles design decisions). If the implementation step finds a mockup-vs-registry conflict, `ui-expert` STOPs and asks the user; it does not auto-adapt the mockup. This boundary is documented in the `[UI-ONLY] Implementation-only constraint` briefing section.
59
+ - **REGISTRY.md decision tree** in [framework/.claude/agents/REGISTRY.md](framework/.claude/agents/REGISTRY.md) gains a header note clarifying that `/new` dispatches by `owner_agent` (not by re-running the decision tree) — the tree remains authoritative for ad-hoc spawns and for `prd-card-writer`'s writing decisions, with a lockstep-with-skill warning to keep the 5 layers in sync.
60
+ - **Verification is manual** (no test suite — `npm test` remains a no-op stub). Dogfood scenarios to run after install: (1) `/new <CARD-ID>` on a card with `owner_agent: coder` → identical behavior to v3.15.x (no regression); (2) `/new <CARD-ID>` on a card with `owner_agent: ui-expert` + valorized `links.design` → `ui-expert` is spawned (not coder), the briefing contains the BLOCKING cascade verbatim, the implementation reads `INDEX.md` + `tokens-reference.md` + `components/<Name>.md` BEFORE coding, the completion report ships the `design_system_coherence:` block, the commit reconciles the three design-system sources; (3) `/new` on a legacy card with `owner_agent: claude` or missing field → fallback to coder + WARN line in tracker; (4) `/prd` on a feature involving login (UI + logic) → produces TWO cards (`UI-LOGIN-*` ui-expert + `LOGIC-LOGIN-*` coder) wired via `depends_on:` rather than one mixed coder card; (5) PRD validation phase on a card with `owner_agent: ""` → enum BLOCKER, commit refused.
61
+
8
62
  ## [3.15.0] - 2026-05-23
9
63
 
10
64
  Two changes ship together. **(1) PRD becomes mockup-aware** — formal intake of existing mockups between Kickoff and Discovery, with a per-screen decision tree in Step 3 that skips generation for screens already covered. **(2) Framework becomes stack-aware** — four new `stack.*` cardinal scalars (`database`, `auth_provider`, `framework`, `deployment`) drive vocabulary, gate sections, anti-pattern checklists, and deploy commands across `/prd`, `coder`, `api-perf-cost-auditor`, `/new`, `code-reviewer`, `security-reviewer`, `bug`. Project-identity assumptions previously hard-coded (mayo personas, real test credentials, Italian merchant business names) are removed from the framework and now resolved from `identity.audience_segments[]` + `.baldart/overlays/prd.md`. Sanitization sweep removed all PII (phone numbers, real usernames, real passwords, real store names) from the published payload.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 3.15.0
1
+ 3.17.0
@@ -37,6 +37,16 @@ Quick-reference for all custom agents. Use this to route tasks to the right spec
37
37
 
38
38
  ## Decision Tree
39
39
 
40
+ > **Note**: when invoked from the `/new` skill, agent assignment is NOT taken
41
+ > from this tree — `/new` reads `owner_agent` directly from each card YAML
42
+ > (enum: `coder | ui-expert | plan | visual-designer | motion-expert`, set
43
+ > by `prd-card-writer`). This tree is the source for HUMAN routing (when
44
+ > spawning an agent ad-hoc) and for prd-card-writer's WRITING decisions.
45
+ > If you change agent capabilities here, keep the enum in
46
+ > `framework/.claude/agents/prd.md:538` and the router in
47
+ > `framework/.claude/skills/new/SKILL.md` § Agent Routing in lockstep —
48
+ > drift between layers silently mis-routes cards.
49
+
40
50
  ```
41
51
  Need to understand existing code? --> codebase-architect (MANDATORY)
42
52
  Have a plan to review? --> plan-auditor
@@ -56,6 +56,69 @@ You produce:
56
56
  4. **Scan existing backlog** — `backlog/*.yml` to find the highest `FEAT-XXXX` number. Use Glob to list files, then Grep for `^id:` lines to extract IDs.
57
57
  5. **Read existing card conventions** — sample 2-3 recent cards from `backlog/` to match style.
58
58
 
59
+ ## Agent Specialization Rules (HARD RULE — zero tolerance)
60
+
61
+ These two rules govern HOW you assign work to specialist agents. They are
62
+ enforced by the validation phase of `/prd` (Step 6) and by the `/new`
63
+ dispatcher — getting them wrong silently routes work to the wrong agent.
64
+
65
+ ### Rule A — Set `owner_agent` on every child card (enum, no default)
66
+
67
+ Every child card you produce MUST set `owner_agent` to exactly one of:
68
+
69
+ ```
70
+ coder | ui-expert | plan | visual-designer | motion-expert
71
+ ```
72
+
73
+ `claude` is NOT a valid value (it is a legacy placeholder kept only for
74
+ backward compatibility in the dispatcher's fallback). Missing, empty, or
75
+ out-of-enum values fail validation.
76
+
77
+ **How to choose:**
78
+
79
+ - `coder` — backend, business logic, state management, data layer, API
80
+ handlers, scripts, CLI, hooks, anything that writes/reads persistence.
81
+ - `ui-expert` — UI implementation from an existing mockup (`links.design`):
82
+ components, layout, styling, motion, accessibility, registry-first
83
+ discipline (reads `${paths.design_system}/INDEX.md` + tokens-reference
84
+ + per-component specs BEFORE coding, runs Post-Intervention Coherence
85
+ Check after).
86
+ - `plan` — planning-only deliverables (no code edits): RFC, ADR draft,
87
+ research synopsis, sequencing doc.
88
+ - `visual-designer` — static visual asset generation (illustrations, icons,
89
+ hero images) via the visual-designer agent.
90
+ - `motion-expert` — motion specs (timing tables, easing curves,
91
+ micro-interaction storyboards) — NOT motion code implementation, which
92
+ is `ui-expert` work.
93
+
94
+ **Epic cards** use `owner_agent: ""` (empty string) because they are
95
+ trackers, not implementation. The dispatcher skips them.
96
+
97
+ ### Rule B — UI cards (`ui-expert`) have UI-ONLY scope
98
+
99
+ When you assign `owner_agent: ui-expert` to a card, its scope MUST cover
100
+ ONLY graphical concerns. The card MUST NOT bundle:
101
+
102
+ - business logic, domain rules, calculation
103
+ - API calls, data fetching, mutations
104
+ - state management beyond local UI state (`useState` for open/closed,
105
+ hover, focus — fine; global app state, cache invalidation, sync — not)
106
+ - validation LOGIC (rendering validation states is UI work; the rules and
107
+ side-effects are coder work)
108
+ - backend changes (routes, handlers, DB schema, migrations, indexes)
109
+
110
+ **If a step requires both UI and logic, you MUST split it into two cards**
111
+ and wire them via `depends_on:` / `blocks:` — a `ui-expert` card that
112
+ consumes a mocked or contract-stable interface, plus a `coder` card that
113
+ owns the logic side. Canonical example: see § "Split example — Login
114
+ feature" in `framework/.claude/skills/prd/references/backlog-phase.md`.
115
+
116
+ If you cannot reasonably split (e.g. because the UI and logic share <3
117
+ files and one file would be torn between two cards), prefer a single
118
+ `coder` card with UI work as one of its acceptance criteria — do NOT
119
+ assign `ui-expert` to a mixed card. The dispatcher's specialist routing
120
+ breaks down when scope is mixed.
121
+
59
122
  ## Card Atomicity Rules
60
123
 
61
124
  Cards MUST be as atomic as possible to enable parallel execution:
@@ -225,6 +225,38 @@ Before Phase 3.5, determine the QA profile for each card by reading its YAML met
225
225
 
226
226
  ---
227
227
 
228
+ ## Agent Routing (Phase 2 dispatcher)
229
+
230
+ Phase 2 reads the card's `owner_agent` field and dispatches to the matching
231
+ specialist. The enum is defined by the PRD card writer
232
+ (`framework/.claude/agents/prd.md:538` + `prd-card-writer.md § Agent
233
+ Specialization Rules`) and validated by the PRD validation phase
234
+ (`framework/.claude/skills/prd/references/validation-phase.md` Step 6 → 0).
235
+
236
+ | `owner_agent` | Dispatcher action in Phase 2 step 7 | Briefing variant |
237
+ |---|---|---|
238
+ | `coder` | Spawn `coder` | Standard coder briefing (default body below) |
239
+ | `ui-expert` | Spawn `ui-expert` | UI briefing — adds BLOCKING registry-first cascade + Post-Intervention Coherence Check (see step 7 § UI branch) |
240
+ | `plan` | Fallback to `coder` + WARN | Standard coder briefing + log `"[ROUTER] plan-only briefing not yet implemented — using coder"` |
241
+ | `visual-designer` | Fallback to `coder` + WARN | Standard coder briefing + same WARN format |
242
+ | `motion-expert` | Fallback to `coder` + WARN | Standard coder briefing + same WARN format |
243
+ | missing / `claude` / unknown | Fallback to `coder` + WARN | Standard coder briefing; for unknown value also log the literal value |
244
+
245
+ The three `plan` / `visual-designer` / `motion-expert` stubs exist so the
246
+ router never blocks a card; specialized briefings are tracked as a follow-up.
247
+
248
+ If you change which values are valid here, also update:
249
+
250
+ - `framework/.claude/agents/prd.md:538` (the canonical enum comment),
251
+ - `framework/.claude/skills/prd/assets/card-template.yml` (the placeholder),
252
+ - `framework/.claude/agents/prd-card-writer.md § Agent Specialization Rules`,
253
+ - `framework/.claude/skills/prd/references/validation-phase.md` Step 6 → 0a,
254
+ - `framework/.claude/agents/REGISTRY.md` decision-tree.
255
+
256
+ Keep them in lockstep — drift between any two layers silently mis-routes cards.
257
+
258
+ ---
259
+
228
260
  ## Per-card pipeline
229
261
 
230
262
  For each card, execute these phases in order:
@@ -262,7 +294,28 @@ For each card, execute these phases in order:
262
294
 
263
295
  ### Phase 2 — Implement (self-healing, up to 3 retries)
264
296
  6. **Update tracker**: phase = "2-implement".
265
- 7. Spawn the **coder** agent (or appropriate specialist from `.claude/agents/REGISTRY.md`) using this **standardized mission briefing** fill in each section from the card YAML, tracker, and codebase-architect findings:
297
+ 6b. **Agent dispatch (router)** read `owner_agent` from the card YAML and resolve the spawn target per the table in § Agent Routing above:
298
+
299
+ ```
300
+ Let raw = card.owner_agent (string, may be missing).
301
+ Switch on raw:
302
+ - "coder" → spawn = "coder", briefing = "coder"
303
+ - "ui-expert" → spawn = "ui-expert", briefing = "ui-expert"
304
+ - "plan" → spawn = "coder", briefing = "coder"
305
+ + log: "[ROUTER] plan-only briefing not yet implemented — using coder"
306
+ - "visual-designer" → spawn = "coder", briefing = "coder"
307
+ + log: "[ROUTER] visual-designer briefing not yet implemented — using coder"
308
+ - "motion-expert" → spawn = "coder", briefing = "coder"
309
+ + log: "[ROUTER] motion-expert briefing not yet implemented — using coder"
310
+ - "" | missing | "claude"
311
+ → spawn = "coder", briefing = "coder"
312
+ + log: "[ROUTER] card <ID> has no valid owner_agent (got '<raw>'); defaulting to coder"
313
+ - anything else → HALT. Log: "[ROUTER] card <ID> has unknown owner_agent '<raw>' — not in {coder, ui-expert, plan, visual-designer, motion-expert}. Ask the user how to proceed."
314
+ ```
315
+
316
+ Log the resolved `spawn` and `briefing` in the tracker (1 line: `"router: owner_agent=<raw> → spawn=<agent>, briefing=<variant>"`). This is the audit trail for which specialist actually handled the card.
317
+
318
+ 7. Spawn the **resolved agent** (from step 6b) using this **standardized mission briefing** — fill in each section from the card YAML, tracker, and codebase-architect findings. When `briefing = "ui-expert"`, ALSO include the additional UI sections marked **[UI-ONLY]** below:
266
319
 
267
320
  ```
268
321
  ## MISSION BRIEFING — <CARD-ID>
@@ -294,6 +347,70 @@ For each card, execute these phases in order:
294
347
  Read the design.html file and use it as the visual reference for your implementation.
295
348
  The design was approved by the user — your implementation MUST match it.
296
349
 
350
+ ### [UI-ONLY] Registry-first BLOCKING pre-work (include ONLY when briefing = "ui-expert")
351
+ You are spawned as `ui-expert`. Before writing any UI code, you MUST complete
352
+ the registry-first cascade defined in
353
+ `framework/.claude/agents/ui-expert.md` § "Authoritative Style Reference —
354
+ Registry-First Protocol" (the SSOT lives in
355
+ `framework/agents/design-system-protocol.md`). Reproduce its 5 steps
356
+ verbatim, do NOT paraphrase or skip:
357
+
358
+ 1. Read `${paths.design_system}/INDEX.md` (component index + Canonical
359
+ Authority Matrix).
360
+ 2. Read `${paths.ui_guidelines}` (visual language, typography,
361
+ accessibility, brand voice).
362
+ 3. Read `${paths.design_system}/tokens-reference.md` (token contract —
363
+ SSOT for every color / spacing / shadow / radius / motion value).
364
+ 4. For EACH primitive in scope on this card, read
365
+ `${paths.design_system}/components/<Name>.md`. "In scope" = any
366
+ component named in the mockup, the requirements, or `files_likely_touched`.
367
+ 5. For EACH pattern in scope, read the relevant
368
+ `${paths.design_system}/patterns/<topic>.md`.
369
+
370
+ State, in your first response, which Authority Matrix rows govern this
371
+ card, which component specs you read (step 4), and which patterns you
372
+ read (step 5). Skipping this declaration = the orchestrator will reject
373
+ the implementation and re-spawn.
374
+
375
+ The `features.has_design_system: true` flag in `baldart.config.yml` is
376
+ the precondition for the full cascade. When `features.has_design_system:
377
+ false`, only step 2 applies — log the gap, recommend `/design-system-init`
378
+ if drift is visible, and proceed with coder-level diligence (no cascade
379
+ enforced).
380
+
381
+ ### [UI-ONLY] Implementation-only constraint (include ONLY when briefing = "ui-expert")
382
+ This `/new` invocation gives you the role of IMPLEMENTER, not designer:
383
+
384
+ - DO NOT redesign the mockup. The mockup at `links.design` is the
385
+ user-approved visual contract for this card.
386
+ - DO NOT silently adapt a mockup detail that conflicts with the registry
387
+ (e.g. a custom shadow not in `tokens-reference.md`, a font size off the
388
+ type scale, a color outside the palette). If you find such a conflict:
389
+ STOP, log it in the tracker as `[DS-DRIFT] mockup-vs-registry`, and ask
390
+ the user which side to honor.
391
+ - DO NOT extend scope into business logic, API calls, state management, or
392
+ validation rules. Those belong to a sibling `coder` card (see
393
+ `backlog-phase.md § Rule B`). If a requirement appears to need logic,
394
+ STOP and ask — do not implement it.
395
+
396
+ ### [UI-ONLY] Post-Intervention Coherence Check (include ONLY when briefing = "ui-expert")
397
+ Before declaring the card done, you MUST reconcile the three design-system
398
+ sources in the SAME commit as your UI change, per
399
+ `framework/agents/design-system-protocol.md § Post-Intervention Coherence Check`:
400
+
401
+ - `${paths.design_system}/INDEX.md` — add / update entries for any primitive
402
+ introduced or modified. Drift code: `DS_INDEX_DRIFT`.
403
+ - `${paths.design_system}/components/<Name>.md` — ship the per-component
404
+ spec for any new primitive; update the spec when a primitive's API or
405
+ visual changes. Drift code: `DS_COMPONENT_STALE`.
406
+ - `${paths.design_system}/tokens-reference.md` — add / update token entries
407
+ when introducing new semantic tokens. Drift code: `DS_TOKENS_DRIFT`.
408
+
409
+ The four conditions defined in `design-system-protocol.md` are the SSOT —
410
+ reproduce them in your completion report under a `design_system_coherence:`
411
+ block listing which conditions applied and which artifacts you updated.
412
+ Omitting the block = the orchestrator treats the card as not done.
413
+
297
414
  ### File Permissions (ENFORCED — no exceptions)
298
415
  MAY EDIT — your files for this card:
299
416
  [list from ownership map for this card]
@@ -545,6 +662,27 @@ Before triggering any review, you MUST verify that the coder agent implemented *
545
662
  If the completion report has `items_skipped` that is not "none", immediately flag those
546
663
  items as Missing regardless of the agent's justification.
547
664
 
665
+ - **[UI-ONLY] Design-system conformance** → run ONLY when `briefing = "ui-expert"` from step 6b
666
+ AND `features.has_design_system: true` in `baldart.config.yml`:
667
+ - Grep the changed files for hardcoded design values that bypass the registry:
668
+ hex colors (`#[0-9a-fA-F]{3,8}`), `rgb(`/`rgba(`, `box-shadow:` with inline
669
+ offsets/blurs, `border-radius:` with px/rem literals, `font-size:` with raw
670
+ px/rem (outside the type scale), `padding`/`margin` with raw px (outside the
671
+ spacing scale). Each hit on a NEW or MODIFIED line = Partial — the value
672
+ should come from a token, not a literal.
673
+ - Verify the completion report includes the `design_system_coherence:` block
674
+ required by the UI-ONLY briefing. Missing block = Missing (orchestrator
675
+ cannot confirm Post-Intervention Coherence Check ran).
676
+ - For each new primitive declared by the report (or detected via Grep for new
677
+ components in `${paths.components_primitives}`), verify the matching
678
+ `${paths.design_system}/components/<Name>.md` spec was created in the same
679
+ commit. Missing spec = Partial — fix by re-spawning `ui-expert` with the
680
+ narrow instruction "ship the component spec for <Name> per
681
+ design-system-protocol.md".
682
+ - For each token change declared by the report, verify the entry exists in
683
+ `${paths.design_system}/tokens-reference.md`. Missing entry = Partial.
684
+ - If `features.has_design_system: false`, log "DS conformance skipped — flag is false" and continue.
685
+
548
686
  5. Classify each item:
549
687
  - **Done** — code exists AND satisfies the FULL scope of the requirement (not just partial).
550
688
  - **Partial** — some code exists but the criterion is not fully satisfied (e.g., UI renders but no error state, endpoint exists but wrong response shape).
@@ -101,6 +101,13 @@ message. You ask questions, wait for answers, and iterate.
101
101
  (`mockup_analysis.screens[].gaps[]`) DEVONO diventare domande mirate in Discovery o
102
102
  essere esplicitamente waivate.
103
103
 
104
+ **Nota — handoff esterno post-intake.** Se l'utente risponde NO al mockup intake, lo
105
+ Step 3.0 in UI Design gli chiederà se vuole generare i mockup internamente (workflow
106
+ `ui-design`) o fare handoff a **Claude Design**. Nel ramo handoff la skill genera un
107
+ prompt context-rich pronto da incollare, fa STOP, e al rientro con i path locali
108
+ riusa esattamente questa stessa procedura di Step 1.6 → Step 3 entra in Hybrid mode.
109
+ Vedi [ui-design-phase.md](references/ui-design-phase.md) § "Step 3.0 — Mockup Source Decision".
110
+
104
111
  ---
105
112
 
106
113
  ## TEMPLATES
@@ -6,7 +6,16 @@ id: {{FEAT-ID}}
6
6
  title: "{{Full descriptive title}}"
7
7
  status: TODO
8
8
  priority: {{HIGH|MEDIUM|LOW}}
9
- owner_agent: claude
9
+
10
+ # owner_agent — REQUIRED, no implicit default. One of:
11
+ # coder → backend / logic / state / data layer / scripts
12
+ # ui-expert → UI implementation (mockup → code, registry-first); UI-ONLY scope
13
+ # plan → planning-only card (no code edits)
14
+ # visual-designer → static visual assets (illustrations, icons, hero images)
15
+ # motion-expert → animation specs (timing, easing, micro-interactions)
16
+ # The /new orchestrator dispatches by this field (see new/SKILL.md § Agent Routing).
17
+ # Validation phase BLOCKS commit if value is missing or outside this enum.
18
+ owner_agent: <REQUIRED — coder | ui-expert | plan | visual-designer | motion-expert>
10
19
  execution_mode: local
11
20
 
12
21
  group:
@@ -29,6 +38,12 @@ business_rationale: |
29
38
  Aiuta gli agenti implementatori a comprendere l'intento strategico.}}
30
39
 
31
40
  scope:
41
+ # UI-only constraint (when owner_agent: ui-expert):
42
+ # The scope MUST cover ONLY graphical concerns — components, layout, styling,
43
+ # token usage, motion, accessibility. It MUST NOT bundle business logic, API
44
+ # integration, data fetching, state management, form validation, or backend
45
+ # changes. If the step involves both UI and logic, split into two cards
46
+ # (ui-expert + coder) and wire them via `depends_on:` / `blocks:`.
32
47
  summary: |
33
48
  {{What this card delivers in 2-3 lines.}}
34
49
  # Drawn from identity.audience_segments[] in baldart.config.yml.
@@ -0,0 +1,116 @@
1
+ # Claude Design Handoff Prompt — Template
2
+
3
+ > Template populated at runtime by **Step 3.0 (Mockup Source Decision)** in
4
+ > [../references/ui-design-phase.md](../references/ui-design-phase.md) when the
5
+ > user picks the **handoff** branch. All `{{placeholders}}` are resolved from the
6
+ > PRD state file (`${paths.prd_dir}/sessions/YYYY-MM-DD-<slug>-state.md`),
7
+ > `baldart.config.yml`, and optional overlays.
8
+ >
9
+ > Render rules:
10
+ > - Conditional sections (marked `{{#if …}} … {{/if}}`) are emitted only when the
11
+ > condition is true. Skip the entire section (including its heading) when false.
12
+ > - Lists (marked `{{#each …}}`) render one bullet per item; emit "—" if empty.
13
+ > - The rendered output is presented to the user inside a fenced markdown
14
+ > code-block so they can copy-paste verbatim into Claude Design.
15
+
16
+ ---
17
+
18
+ # Feature: {{feature_title}}
19
+
20
+ ## 1. Obiettivo
21
+
22
+ {{feature_objective_one_sentence}}
23
+
24
+ ## 2. User flow
25
+
26
+ {{user_flow_summary}}
27
+
28
+ {{#if primary_personas}}
29
+ **Personas target**:
30
+ {{#each primary_personas}}
31
+ - {{this.name}} — {{this.context}}
32
+ {{/each}}
33
+ {{/if}}
34
+
35
+ ## 3. Schermate in scope
36
+
37
+ {{#each screens_in_scope}}
38
+ ### {{this.name}}
39
+
40
+ - **Scopo**: {{this.purpose}}
41
+ - **Stati richiesti**: {{this.states_required}} <!-- empty, loading, populated, error, success, ecc. -->
42
+ - **Azioni primarie**: {{this.primary_actions}}
43
+ - **Dati visualizzati**: {{this.data_shown}}
44
+ {{#if this.notes}}
45
+ - **Note**: {{this.notes}}
46
+ {{/if}}
47
+
48
+ {{/each}}
49
+
50
+ {{#if brand_voice}}
51
+ ## 4. Brand & voice
52
+
53
+ - **Tono**: {{brand_voice.tone}}
54
+ - **Personalità**: {{brand_voice.personality}}
55
+ - **Do**: {{brand_voice.do}}
56
+ - **Don't**: {{brand_voice.dont}}
57
+ {{#if brand_voice.references}}
58
+ - **Riferimenti visivi**: {{brand_voice.references}}
59
+ {{/if}}
60
+ {{/if}}
61
+
62
+ {{#if has_design_system}}
63
+ ## 5. Design system constraints
64
+
65
+ > Riusa SOLO i token e le primitive elencate. Se devi proporre qualcosa di nuovo,
66
+ > segnalalo esplicitamente nella consegna così posso aggiornare il registro.
67
+
68
+ ### Token chiave
69
+
70
+ ```
71
+ {{design_tokens_excerpt}}
72
+ ```
73
+
74
+ ### Primitive da riusare
75
+
76
+ {{#each registered_primitives}}
77
+ - **{{this.name}}** — {{this.purpose}} ({{this.path}})
78
+ {{/each}}
79
+
80
+ ### Vincoli numerici (da `design-system-protocol.md`)
81
+
82
+ - Type scale: {{tokens.type_scale}}
83
+ - Spacing scale: {{tokens.spacing_scale}}
84
+ - Radius: {{tokens.radius_scale}}
85
+ - Contrast minimo: {{tokens.contrast_target}} (WCAG AA + APCA Lc ≥ {{tokens.apca_target}})
86
+ - Motion durations: {{tokens.motion_durations}}
87
+ {{/if}}
88
+
89
+ ## 6. Stack target
90
+
91
+ - **Framework**: {{stack.framework}}
92
+ - **Output preferito**: {{output_format_preference}} <!-- "HTML/CSS standalone" | "React component (Tailwind)" | "Figma frame" -->
93
+ {{#if stack.charting}}
94
+ - **Charting library**: {{stack.charting}}
95
+ {{/if}}
96
+ {{#if stack.animation}}
97
+ - **Animation library**: {{stack.animation}}
98
+ {{/if}}
99
+
100
+ ## 7. Cosa restituirmi
101
+
102
+ Per ogni schermata elencata in § 3:
103
+
104
+ 1. **PNG export** ad alta risoluzione (≥ 2x) di OGNI stato richiesto (es. `lista-ordini__empty.png`, `lista-ordini__populated.png`).
105
+ 2. {{output_format_preference_block}} <!-- "Codice HTML/CSS in un file unico" | "Codice React (.tsx) con import Tailwind" | "Link Figma alla frame" -->
106
+ 3. **Note inline** su:
107
+ - Componenti nuovi (non presenti nel registry sopra) che hai introdotto e perché.
108
+ - Token deviation: qualunque colore/spacing/radius fuori dalla palette sopra, con motivazione.
109
+ - Decisioni di layout non ovvie (es. priority sort, hierarchy visiva, density).
110
+
111
+ Quando hai pronto, dimmi i **path locali** dei file (PNG/HTML/TSX) — li importerò in questa sessione PRD per analisi e validazione contro il design system.
112
+
113
+ ---
114
+
115
+ <!-- baldart-handoff: do-not-edit-manually -->
116
+ <!-- Generated from claude-design-handoff-prompt.template.md by /prd Step 3.0 -->
@@ -26,7 +26,14 @@ id: {{FEAT-XXXX-00}}
26
26
  title: "Epic: {{Feature Name}} — {{short tagline}}"
27
27
  status: TODO
28
28
  priority: {{HIGH|MEDIUM|LOW}}
29
- owner_agent: claude
29
+
30
+ # Epics are tracker-only — no implementation work, no dispatcher routing.
31
+ # The /new orchestrator skips epics (it only operates on child cards) and the
32
+ # PRD validation-phase enum-check skips them too. Keep this as an empty
33
+ # string to signal "no specialist assigned"; do NOT use one of the child
34
+ # enum values (coder | ui-expert | plan | visual-designer | motion-expert)
35
+ # on an epic — that would falsely imply the epic carries implementation work.
36
+ owner_agent: ""
30
37
  execution_mode: cloud
31
38
 
32
39
  # Epic's group.parent is the PRD slug (string), NOT a FEAT-ID.
@@ -4,6 +4,87 @@
4
4
 
5
5
  Mark task 4 as `in_progress`.
6
6
 
7
+ ## MANDATORY Card Rules (zero tolerance — read first)
8
+
9
+ These two rules apply to EVERY child card (epics use `owner_agent: ""`). The
10
+ `prd-card-writer` agent enforces them; the skill MUST verify post-generation
11
+ and HALT if violated.
12
+
13
+ ### Rule A — `owner_agent` is mandatory and enum-validated
14
+
15
+ Every child card MUST declare `owner_agent` with one of the five values:
16
+
17
+ ```
18
+ coder | ui-expert | plan | visual-designer | motion-expert
19
+ ```
20
+
21
+ There is no implicit default and `claude` is NOT a valid value. Cards with
22
+ missing, empty, placeholder, or non-enum values fail Step 6 (validation-phase)
23
+ and BLOCK the commit. The `/new` orchestrator dispatches implementation
24
+ agent by this field (see `framework/.claude/skills/new/SKILL.md` § Agent
25
+ Routing), so a wrong value silently routes the card to the wrong specialist.
26
+
27
+ ### Rule B — UI cards have UI-only scope (no mixed scope)
28
+
29
+ A card with `owner_agent: ui-expert` MUST be scoped EXCLUSIVELY to graphical
30
+ concerns: components, layout, styling, token usage, motion, accessibility.
31
+ It MUST NOT bundle:
32
+
33
+ - business logic / domain rules
34
+ - API integration or data fetching
35
+ - state management beyond local UI state
36
+ - form validation logic (rendering validation states is UI; the rules are not)
37
+ - backend changes (routes, handlers, DB schema)
38
+
39
+ If a feature step involves BOTH UI and logic, the writer MUST split it into:
40
+
41
+ - one `owner_agent: ui-expert` card — visual implementation, consumes mocked
42
+ or contract-stable data
43
+ - one `owner_agent: coder` card — logic, API call, state, persistence
44
+
45
+ The two cards are wired via `depends_on:` / `blocks:`. A common ordering is
46
+ `coder → ui-expert` (contract ready before UI), but the reverse is acceptable
47
+ when the UI card consumes a hand-written mock.
48
+
49
+ #### Split example — Login feature
50
+
51
+ **Bad** (single mixed card):
52
+
53
+ ```yaml
54
+ id: FEAT-XXXX-01
55
+ owner_agent: coder
56
+ scope:
57
+ summary: |
58
+ Implement the login page: form layout, validation states, call to
59
+ POST /api/auth/login, token storage, redirect to dashboard.
60
+ ```
61
+
62
+ **Good** (split into UI + logic):
63
+
64
+ ```yaml
65
+ # UI card — visual only, consumes a mocked auth contract
66
+ id: FEAT-XXXX-02
67
+ owner_agent: ui-expert
68
+ depends_on: [FEAT-XXXX-01]
69
+ scope:
70
+ summary: |
71
+ Login form layout (email/password fields, primary CTA, link to recovery),
72
+ visual states (idle / loading / error / success), a11y (focus order,
73
+ aria-live for inline errors), responsive breakpoints. Consumes the
74
+ `useAuth()` mock provided by FEAT-XXXX-01.
75
+ ```
76
+
77
+ ```yaml
78
+ # Logic card — API call + state + redirect
79
+ id: FEAT-XXXX-01
80
+ owner_agent: coder
81
+ blocks: [FEAT-XXXX-02]
82
+ scope:
83
+ summary: |
84
+ POST /api/auth/login handler, token storage in httpOnly cookie, redirect
85
+ on success, `useAuth()` hook exposing { status, error, signIn }.
86
+ ```
87
+
7
88
  ## MANDATORY Card Structure (zero tolerance — read first)
8
89
 
9
90
  Every PRD generates **1 epic card + N children**, regardless of N. The
@@ -1,15 +1,97 @@
1
1
  # UI Design Phase (Step 3)
2
2
 
3
+ ## Step 3.0 — Mockup Source Decision (only when `mockups.status: none`)
4
+
5
+ When the state file shows `mockups.status: none` AND UI impact ≠ N/A, the user
6
+ has not provided any mockup at intake. Before falling into the **Full** pipeline,
7
+ offer them an explicit choice — generate internally or hand off to **Claude
8
+ Design** (Anthropic's design product, design-system-sync'd) — so they don't have
9
+ to abandon the PRD flow halfway.
10
+
11
+ Skip this step entirely when `mockups.status` ∈ {`provided`, `partial`,
12
+ `pending_external`} (already decided) or when UI impact = N/A (no design work).
13
+
14
+ ### The question (single STOP)
15
+
16
+ Ask the user, verbatim:
17
+
18
+ > Non hai fornito mockup all'intake. Come preferisci produrli per questa feature?
19
+ > **(A) Internamente** — genero io 3 opzioni HTML (workflow `ui-design`), iteriamo qui.
20
+ > **(B) Handoff a Claude Design** — ti preparo un prompt context-rich da incollare in Claude Design; quando hai i mockup tornami con i path locali.
21
+
22
+ **STOP.** Wait for an explicit `A` / `B` answer. Silence or ambiguity ⇒ ask
23
+ again (do NOT default silently).
24
+
25
+ ### Branch A — Internal generation
26
+
27
+ Set `mockups.source: internal` in the state file, then fall through to the
28
+ **Precondition decision tree** below — the `none` row routes to Full mode
29
+ unchanged. No other side-effect of Step 3.0.
30
+
31
+ ### Branch B — Claude Design handoff
32
+
33
+ 1. **Collect context from the state file + config + overlays:**
34
+ - `feature_title`, `feature_objective_one_sentence` from `## Feature Description`.
35
+ - `user_flow_summary`, `primary_personas` from `## Discovery Log` (dimensions 1 + 2).
36
+ - `screens_in_scope[]` from `## UI Design` (derive from User Stories + ISA touchpoints if not yet populated — same logic as Hybrid mode § "Build the per-screen routing table").
37
+ - `brand_voice` from `.baldart/overlays/prd.md` if present (skip section otherwise).
38
+ - When `features.has_design_system: true`: read `${paths.design_system}/INDEX.md` (primitive list) + `${paths.design_system}/tokens-reference.md` (tokens excerpt). When `false`: omit § 5 of the prompt entirely.
39
+ - `stack.framework`, `stack.charting`, `stack.animation` from `baldart.config.yml`.
40
+ - `output_format_preference` derived from `stack.framework` (Next/Remix → React+Tailwind; vanilla → HTML/CSS; otherwise ask the user).
41
+ - Numeric token tables (type scale, spacing, radius, contrast, motion durations) from `framework/agents/design-system-protocol.md` — cite verbatim.
42
+
43
+ 2. **Render the prompt** by populating
44
+ [../assets/claude-design-handoff-prompt.template.md](../assets/claude-design-handoff-prompt.template.md)
45
+ with the collected context. Strip empty conditional sections.
46
+
47
+ 3. **Present the rendered prompt** to the user inside a fenced markdown
48
+ code-block, prefixed with this instruction (verbatim):
49
+
50
+ > Incolla il prompt qui sotto in Claude Design. Quando hai i mockup pronti,
51
+ > tornami con i **path locali** dei file (PNG, HTML, TSX, o link Figma) e
52
+ > riprendo da qui — copio i file nella cartella del PRD, li analizzo come
53
+ > al solito (Step 1.6 Mockup Intake), e Step 3 entra in Hybrid mode.
54
+
55
+ 4. **Update state file** before stopping:
56
+ - `mockups.status: pending_external`
57
+ - `mockups.source: claude-design`
58
+ - `mockups.handoff_prompt_path: ${paths.prd_dir}/<slug>/handoff/claude-design-prompt.md` (save the rendered prompt to disk so it survives session restarts).
59
+ - `step_3_mode: pending_external_handoff` (transitional — overwritten when user returns).
60
+
61
+ 5. **STOP.** Wait for the user to return with local paths.
62
+
63
+ ### Re-entry from handoff (user returns with paths)
64
+
65
+ When the user comes back with one or more local paths after the handoff:
66
+
67
+ 1. Invoke **Step 1.6 — Mockup Intake** verbatim
68
+ ([SKILL.md](../SKILL.md) § Hard Rule 16,
69
+ [discovery-phase.md](discovery-phase.md) § "Mockup analysis schema"):
70
+ - Copy local files into `${paths.prd_dir}/<slug>/mockups/` with collision-safe
71
+ rename.
72
+ - Run the full Mockup analysis schema (screens, user_flow, components,
73
+ states_visible, copy_excerpts, gaps, design_system_alignment).
74
+ - Populate `## UI Design` in the state file.
75
+ 2. Flip `mockups.status` from `pending_external` to `provided` or `partial`
76
+ based on coverage of `screens_in_scope[]`. Keep `mockups.source: claude-design`
77
+ as audit trail.
78
+ 3. Fall through to the **Precondition decision tree** below — the `provided` /
79
+ `partial` row routes to **Hybrid mode** unchanged.
80
+
81
+ ---
82
+
3
83
  ## Precondition decision tree
4
84
 
5
85
  Read `mockups.status` and `screens_in_scope[]` from the state file `## UI Design`
6
- section (populated by Step 1.6) plus the UI impact dimension from the discovery
7
- checklist. Pick exactly one branch:
86
+ section (populated by Step 1.6 and/or Step 3.0 re-entry) plus the UI impact
87
+ dimension from the discovery checklist. Pick exactly one branch:
8
88
 
9
89
  | Condition | Branch | Action |
10
90
  |-----------|--------|--------|
11
91
  | UI impact = N/A | **Skip totale** | Mark task 2 `completed` ("Skipped — no UI"). `step_3_mode: skipped`. Proceed to PRD Writing Phase. |
12
- | `mockups.status: none` AND UI impact ≠ N/A | **Full** | Run the standard pipeline 3a 3b 3c 3d as before. `step_3_mode: full`. |
92
+ | `mockups.status: none` AND UI impact ≠ N/A | **3.0 Decision** | Run Step 3.0 above first. Branch A fall through to **Full**; Branch B STOP, then re-enter. |
93
+ | `mockups.status: pending_external` | **STOP** | User is in handoff with Claude Design. Do not advance until paths arrive (see § "Re-entry from handoff"). |
94
+ | `mockups.status: none` AND user picked Branch A in Step 3.0 | **Full** | Run the standard pipeline 3a → 3b → 3c → 3d as before. `step_3_mode: full`. |
13
95
  | `mockups.status` ∈ {`provided`, `partial`} AND UI impact ≠ N/A | **Hybrid** | Per-screen routing (see § Hybrid mode below). `step_3_mode: hybrid` (or `skipped` if every screen is covered AND no `mockup_analysis.design_system_alignment.violations`). |
14
96
 
15
97
  Mark task 2 as `in_progress` for the Full and Hybrid branches.
@@ -6,6 +6,26 @@
6
6
 
7
7
  Mark task 5 as `in_progress`.
8
8
 
9
+ 0. **Agent Specialization Audit (runs FIRST — blocks if any failure)** — for each generated child card (epics are skipped):
10
+
11
+ a. **`owner_agent` enum check (BLOCKING)** — read the `owner_agent` field. It MUST equal one of:
12
+ ```
13
+ coder | ui-expert | plan | visual-designer | motion-expert
14
+ ```
15
+ Empty string, missing field, `claude`, or any other value = **BLOCKER**.
16
+ Message to the user: `"Card <ID> has owner_agent: '<value>' — must be one of {coder, ui-expert, plan, visual-designer, motion-expert}. Fix the card YAML before commit."`
17
+ Halt the audit. No subsequent checks run on a card that fails this gate.
18
+
19
+ b. **UI-only scope heuristic (WARN — soft gate, not blocking)** — for each card with `owner_agent: ui-expert`:
20
+ - Concatenate `scope.summary`, `requirements[]`, and `acceptance_criteria[]` into one lowercase string.
21
+ - Grep for logic-marker substrings: `api call`, `endpoint`, `route handler`, `state machine`, `validation logic`, `business rule`, `database`, `migration`, `prisma`, `firestore.collection`, `auth flow`, `token storage`, `webhook`, `cron`.
22
+ - For each marker hit, log a WARN line in the audit output:
23
+ `"[UI-SCOPE-WARN] Card <ID> (ui-expert) mentions '<marker>' — review whether logic belongs in a sibling coder card. See backlog-phase.md § Rule B."`
24
+ - The check is intentionally a soft gate: substrings like "API contract per il mock" or "consumes the auth state from `useAuth()`" are legitimate UI references. The WARN exists to prompt human review, not to block.
25
+ - Exception (no WARN): the marker appears INSIDE a quoted string that explicitly says "consume", "mock", "contract reference", or "exposed by sibling card" — those are UI cards reading an upstream contract, which is expected.
26
+
27
+ **Gate**: every card has `owner_agent` in the enum. WARN entries from check (b) are noted in the audit log; user may accept them after review.
28
+
9
29
  1. **Field Name Audit (runs BEFORE audit agents)** — for each generated card:
10
30
 
11
31
  a. Verify every `data_fields` entry has `ts_verified: true` OR `status: new` with `schema_ref`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baldart",
3
- "version": "3.15.0",
3
+ "version": "3.17.0",
4
4
  "description": "Claude Agent Framework - Reusable framework for coordinating AI agents and humans in software projects",
5
5
  "bin": {
6
6
  "baldart": "./bin/baldart.js"