background: false is the default. Use foreground dispatch whenever the result determines the current answer or next action.
- Use
background: true only for independent work. If this turn must consume a background result, call observe exactly once with action: "wait" and a bounded timeout before continuing; never continue independently while the result is pending.
- Otherwise end the turn and wait for the automatic
teammate-complete notification. Do not rely on SendMessage, team_msg, or hook callbacks as completion signals.
- Never silently ignore an unfinished dispatch.
Input
$ARGUMENTS first word determines mode:
| First Word |
Mode |
--codify / codify |
Codify — extract design system from existing code (see <codify_mode>) |
| Known command (see routing table) |
Direct |
Disambiguation for overlapping names (harden, live): bare keyword without target → Chain; keyword + explicit target/path → Direct. Override: --chain forces Chain, --direct forces Direct.
| Chain name: build, redesign, improve, enhance, launch, harden, foundation, live | Chain |
| continue / next / -c | Resume |
| search | Search: maestro impeccable search "$REST" |
| Free text (any) | Free Text Routing (3-layer system below) |
| (empty) | Menu: show commands by category |
Command Routing
All workflows at ~/.maestro/workflows/impeccable/{command}.md:
| Command |
Category |
Description |
| craft |
Build |
Shape then build end-to-end — full page/component implementation |
| shape |
Build |
Plan UX/UI before code — information architecture, wireframe, visual direction |
| teach |
Build |
Set up PRODUCT.md — users, brand, tone, anti-references, principles |
| document |
Build |
Generate DESIGN.md from existing code — extract tokens, typography, colors |
| extract |
Build |
Pull tokens/components into reusable design system |
| explore |
Build |
Multi-style comparison — generate variants, render prototypes, visual compare, select/mix |
| critique |
Evaluate |
UX heuristic review with Nielsen scoring (/40) + P0/P1 findings |
| audit |
Evaluate |
Technical quality checks — a11y, performance, responsive, code quality (/20) |
| polish |
Refine |
Final quality pass — micro-adjustments, pixel perfection |
| bolder |
Refine |
Amplify bland/safe designs — stronger personality, more contrast |
| quieter |
Refine |
Tone down aggressive/overwhelming designs — reduce visual noise |
| distill |
Refine |
Strip to essence — remove clutter, reduce cognitive load |
| harden |
Refine |
Production-ready — error states, i18n, edge cases, overflow, empty states |
| onboard |
Refine |
First-run flows, empty states, activation paths, progressive disclosure |
| animate |
Enhance |
Add purposeful motion — transitions, micro-interactions, scroll effects |
| colorize |
Enhance |
Add strategic color — OKLCH palette, contrast, color strategy |
| typeset |
Enhance |
Improve typography — scale, hierarchy, font pairing, line length |
| layout |
Enhance |
Fix spacing, rhythm, visual hierarchy, alignment, grid |
| delight |
Enhance |
Add personality — memorable details, joy, surprise moments |
| overdrive |
Enhance |
Push past conventional limits — ambitious visual effects |
| clarify |
Fix |
Improve UX copy — labels, error messages, microcopy, CTAs |
| adapt |
Fix |
Adapt for devices/screens — responsive, touch targets, breakpoints |
| optimize |
Fix |
Fix UI performance — loading, rendering, bundle, paint/layout jank |
| live |
Iterate |
Browser-based variant iteration — real-time design in DevTools |
Reference files (loaded by workflow as needed, not standalone commands):
brand.md, product.md, design.md, codex.md, heuristics-scoring.md, cognitive-load.md,
color-and-contrast.md, interaction-design.md, motion-design.md, personas.md,
responsive-design.md, spatial-design.md, typography.md, ux-writing.md
Chains
Chain step names below reuse Command Routing names but resolve through the chain runner. To avoid ambiguity with Direct command invocation, internal display, todo items, and session status records always tag chain steps with the impeccable: prefix (e.g. impeccable:craft, impeccable:critique). The bare names in this table refer to the workflow file at ~/.maestro/workflows/impeccable/{name}.md that the chain step reads.
| Chain |
Steps |
Scenario |
| build |
teach? → explore? → shape → craft → critique → [refine] → audit → polish |
New from scratch |
| redesign |
document → explore → shape → craft → critique → [refine] → audit → polish |
Redesign existing code |
| improve |
critique → [refine] → polish → audit |
Iterative improvement |
| enhance |
{cmd...} → critique → [refine] → polish |
Targeted enhancement (multi-command) |
| launch |
harden → adapt → optimize → audit → polish |
Full production readiness |
| harden |
harden → audit → polish |
Edge case hardening |
| foundation |
teach? → explore → document → extract |
Design system setup |
| live |
live |
Real-time iteration |
? = conditional: teach if PRODUCT.md missing; explore if DESIGN.md missing and --skip-design not set
[refine] = quality gate loop: gate fails → auto-select fix commands from findings → re-gate
{cmd...} = enhance supports multiple commands, comma-separated: enhance colorize,typeset landing-page
Chain flags: --threshold (default 26/40), --max-loops (default 3), --skip-design, --styles , -y (skip Layer 2 ambiguity user prompt — select first matching chain; skip chain session confirmation; skip quality gate refine confirmations. Does NOT skip prerequisite checks.)
Free Text Routing
Three-layer priority matching. Stop on first match — do not continue to lower layers.
Layer 1: Single command intent → Direct
Semantically match user description against the Command Routing table's Description column. Match the closest single command.
Skip condition: If the prompt matches a Layer 2 chain keyword AND matches MORE THAN ONE row in the Layer 1 intent signal table, skip this layer.
Example: enhance colors and typography — "enhance" is a chain keyword + multiple design dimensions → skip to Layer 2.
| Intent signal |
Command |
| review, check UX, score, heuristic, evaluate usability |
critique |
| audit, a11y, accessibility, technical check, performance audit, code quality |
audit |
| add animation, motion, transitions, micro-interactions |
animate |
| color, palette, OKLCH, contrast, color scheme |
colorize |
| font, typography, type scale, line height, font pairing |
typeset |
| layout, spacing, grid, alignment, visual hierarchy |
layout |
| too loud, tone down, visual noise, make it simpler, too busy |
quieter |
| too bland, bolder, more personality, stronger, more contrast |
bolder |
| too complex, simplify, strip, remove clutter, cognitive load |
distill |
| polish, fine-tune, pixel perfect, final pass, refine details |
polish |
| copy, labels, error messages, UX writing, microcopy, CTAs |
clarify |
| responsive, mobile, adapt, breakpoints, touch targets |
adapt |
| performance, loading, bundle, jank, speed, rendering |
optimize |
| edge cases, error states, i18n, overflow, empty state hardening |
harden |
| onboarding, first-run, empty state, activation, progressive disclosure |
onboard |
| fun, surprise, personality, memorable, joy, delight |
delight |
| extraordinary, push limits, ambitious effects, cutting-edge |
overdrive |
| plan UX, wireframe, information architecture, visual direction |
shape |
| multi-style, variants, compare styles, style comparison |
explore |
| brand definition, PRODUCT.md, product context |
teach |
| extract design, DESIGN.md, document design system |
document |
| pull tokens, extract components, design system extraction |
extract |
| real-time, browser iteration, live editing |
live |
Layer 2: Project intent → Chain
Override: if the user explicitly uses a chain name as the primary verb (improve, enhance, redesign, build, launch), prefer Layer 2 chain even if Layer 1 matched a single command.
Layer 1 did not match. Check for chain-level keywords — even if the prompt also contains a specific target/path, chain matching takes priority.
| Pattern |
Chain |
| new, create, build, from scratch, start fresh |
build |
| redo, redesign, rethink, restyle, overhaul, revamp |
redesign |
| improve, iterate, better, refine overall |
improve |
| enhance, visual upgrade, level up |
enhance |
| launch, deploy, ship, production-ready, go live |
launch |
| harden, production-harden, edge cases |
harden |
| design system, tokens, design foundation, design infrastructure |
foundation |
| real-time, live, browser |
live |
Ambiguous + no -y:
[@ask] AskUserQuestion (single-select, header: "意图确认"):
- Options: top 2-3 matched chains from Layer 2 table, each with label = chain name, description = matched keywords
- Last option: "直接构建" — skip chain, route to Layer 3 craft
Layer 3: Concrete build task → Direct craft
Layer 1+2 both did not match, but intent is to build/create a specific thing:
- Contains a specific file path or target (
d:\path, src/pages/, index.html)
- Contains ≥2 specific visual attributes (e.g., exact color values, font names, spacing numbers, layout structure description)
- Contains reference material (
based on..., like..., similar to...)
→ Route to craft (Direct)
If all three layers produce no match → E001 (No command or intent resolved). Before raising E001, attempt [@ask] user prompt with top 2-3 closest matches from Layer 1+2 tables.
Prerequisites
Before reading any command workflow:
- Context:
maestro load --type spec --category ui → if empty → maestro impeccable load-context
- PRODUCT.md: missing/placeholder (<200 chars /
[TODO]) → execute teach first, then resume original task
- Register: identify brand/product → Read
~/.maestro/workflows/impeccable/{brand|product}.md
Direct Execution
- Prerequisites ✓
- Display execution info:
── Command: {command} ────────────────────
Category: {category} | Target: {target}
─────────────────────────────────────────
- Read
~/.maestro/workflows/impeccable/{command}.md
- TodoWrite tracking: create todo items for each major phase in the workflow file
- Format:
[{command}] {phase description}
- Mark each phase completed immediately upon finishing
- Follow workflow file instructions
- Post: suggest logical next command (teach→shape, shape→craft, craft→critique, etc.)
Chain Execution
- Prerequisites ✓
- Display chain preview: parse chain definition, output full step preview (chain steps prefixed
impeccable: to disambiguate from Direct commands):── Chain: build ──────────────────────────
1. impeccable:teach (conditional: PRODUCT.md missing)
2. impeccable:explore (conditional: DESIGN.md missing)
3. impeccable:shape
4. impeccable:craft
5. impeccable:critique ◆ quality gate (threshold: 26/40)
6. impeccable:[refine] ↺ auto-fix loop (max: 3)
7. impeccable:audit ◆ quality gate (threshold: 14/20)
8. impeccable:polish
─────────────────────────────────────────
Target: {target}
◆ marks quality gate steps with threshold
↺ marks refine loop with max iteration count
- Conditional steps show trigger condition
- Skipped conditional steps marked
(skipped)
- Confirm chain session: [@ask] user prompt "Create chain session for '{chain_type}' targeting '{target}'?" — proceed only if user confirms. On decline, abort chain.
Create session:
.workflow/.maestro/ui-craft-{YYYYMMDD-HHmmss}/status.json{ "chain_type": "...", "target": "...", "steps": [...], "current_step": 0,
"gate_history": [], "loop_count": 0, "status": "running" }
- TodoWrite init: create todo items for all chain steps
- One item per step, format:
[chain] step N: impeccable:{command} — {description} (use impeccable: prefix to disambiguate from Direct command items)
- If conditional step is skipped, immediately mark completed
- Quality gate steps include threshold:
[chain] step 5: impeccable:critique ◆ gate ≥26/40
- For each step:
- Read
~/.maestro/workflows/impeccable/{command}.md → execute
- Step start: TodoWrite marks current step in_progress
- Step done: TodoWrite marks completed + update status.json (
current_step, step status)
- Step failed: TodoWrite marks completed (with note) + record reason
- Failure classification:
- Blocking (chain stops): craft, shape, teach (if PRODUCT.md required)
- Non-blocking (chain continues with W003): polish, delight, animate, colorize, typeset, layout, clarify, adapt, optimize, bolder, quieter, distill, harden, onboard
- Gate steps (critique/audit): gate failure triggers refine loop, not step failure
- Quality gate (critique/audit steps):
- Parse score: critique
**Total** | | **N/40**, audit **Total** | | **N/20**
- Count
[P0] / [P1] tags
- Pass: score ≥ threshold AND P0 == 0 → advance
- Fail: collect suggested commands from findings → execute → re-gate
- Max loops exceeded → force advance with warning
- TodoWrite: record gate result in current step notes (score, P0/P1 count, pass/fail)
- Final report: scores + trend + commands executed
Codify Execution
Trigger: first word is --codify or codify. Also reachable when the foundation chain reaches its document/extract steps and the user wants full reverse-extraction with knowhow persistence.
Arguments: --codify <source-path> [--package-name <name>] [--output-dir <path>] [--overwrite]
<source-path> (required): Directory containing CSS/SCSS/JS/TS/HTML source files
--package-name <name>: Package name for reference output (default: auto-generated from source directory)
--output-dir <path>: Output directory for reference package (default: .workflow/reference_style)
--overwrite: Allow overwriting existing package directory
Output boundary: ALL file writes MUST target the --output-dir path (default: .workflow/reference_style/) for reference packages, and .workflow/knowhow/ for knowledge assets (manifest-driven direct writes per ui-codify-knowhow). NEVER modify the source directory being analyzed.
Codify Invariants
- Source read-only — the source path being analyzed MUST NOT be modified; extraction is purely read-only
- Phase-sequential loading — workflow files (ui-codify-extract, ui-codify-package, ui-codify-knowhow) MUST be read only when their phase starts; NEVER load all phases eagerly
- User confirmation before knowhow — Phase 3→4 gate MUST present [@ask] user prompt before generating knowledge assets; NEVER auto-proceed to knowhow generation
- Overwrite protection — existing package directory MUST NOT be overwritten without
--overwrite flag (E102)
- Artifact completeness — all 5 required artifacts MUST exist before reporting completion; NEVER skip artifact verification
- Token-first extraction — design-tokens.json MUST be generated before layout-templates.json; layout extraction depends on token foundation
Step 1: Load UI Specs
maestro load --type spec --category ui
Step 2: Execute Workflow
Route to ~/.maestro/workflows/ui-codify.md and follow completely. The workflow orchestrates 4 phases with deferred loading of phase-specific workflow files (see <deferred_reading>). Each phase reads its workflow file only when execution reaches that phase.
Codify Phase Gates (MANDATORY, BLOCKING)
GATE Phase 1 → Phase 2: Validation → Extraction
- REQUIRED: Source path validated and file discovery completed.
- REQUIRED: design-tokens.json generated with color, typography, spacing tokens.
- BLOCKED if missing: source path invalid (E101) or design-tokens.json not generated — extraction cannot proceed without token foundation.
GATE Phase 2 → Phase 3: Extraction → Package
- REQUIRED: layout-templates.json generated with component patterns.
- BLOCKED if missing: layout-templates.json absent — package generation requires component patterns as input.
GATE Phase 3 → Phase 4: Package → Knowhow
GATE Phase 4 → Completion: Knowhow → Done
- REQUIRED: knowhow-manifest.json created with AST/DCS assets and spec entries.
- REQUIRED: knowledge assets persisted — knowhow files + spec entries written to
.workflow/knowhow/ and .workflow/specs/ per ui-codify-knowhow Step 4.4 (after user confirmation at Phase 3→4 gate).
- BLOCKED if missing: knowhow-manifest.json absent or knowledge assets not persisted.
Artifact Verification (before completion)
REQUIRED_ARTIFACTS = [
"design-tokens.json", // Phase 1
"layout-templates.json", // Phase 2
"preview.html", // Phase 3
"preview.css", // Phase 3
"knowhow-manifest.json" // Phase 4
]
If any artifact is missing: DO NOT report completion.
Resume
Scan .workflow/.maestro/ui-craft-*/status.json for status == "running" || status == "paused" → most recent → resume from current_step.
Quality Gate — Finding → Command Fallback
When findings lack explicit suggested command:
| Finding Category |
Command |
| Layout, spacing, hierarchy, alignment |
layout |
| Color, contrast, palette |
colorize |
| Typography, font, readability |
typeset |
| Animation, motion, transitions |
animate |
| Copy, labels, UX writing |
clarify |
| Responsive, mobile, breakpoints |
adapt |
| Performance, loading, speed |
optimize |
| Complexity, overload, clutter |
distill |
| Bland, safe, generic |
bolder |
| Aggressive, overwhelming |
quieter |
| Onboarding, empty state |
onboard |
| Edge cases, i18n, error handling |
harden |
| Personality, memorability |
delight |
Never auto-select: teach, shape, craft, live, document, extract, overdrive, critique, audit.
Chain Phase Gates (MANDATORY for chain mode)
GATE: Quality Gate Step → Next Step
- REQUIRED: Score parsed from critique/audit output (not assumed or estimated).
- REQUIRED: P0 count extracted from findings — P0 == 0 required for pass.
- REQUIRED: If gate fails, refine commands executed and re-gate attempted.
- BLOCKED if: score not parsed from actual output, or P0 > 0 and max refine loops not exhausted — do not advance past gate.
- Do NOT skip quality gate steps or mark as "passed" without parsing actual score.
- If score unparseable from output: retry the gate step once. If still unparseable → treat as gate fail (enter refine loop). Emit W005.
GATE: Chain → Completion
- REQUIRED: All non-skipped steps executed (TodoWrite all completed).
- REQUIRED: status.json updated with
status: "completed" and final scores.
- REQUIRED: If any step failed: documented in status.json with reason.
- BLOCKED if missing: steps not all completed or status.json not updated — chain is incomplete.
Chain mode:
Codify mode:
| Condition |
Suggestion |
| Direct teach complete |
maestro impeccable shape |
| Direct shape complete |
maestro impeccable craft |
| Direct craft complete |
maestro impeccable critique |
| Direct critique findings |
maestro impeccable polish or targeted fix command |
| Chain complete |
Review final scores, consider maestro impeccable improve for iteration |
| Chain paused/interrupted |
maestro impeccable continue to resume |
| Codify complete |
Use extracted tokens in maestro impeccable craft for new builds |
| Codify design system needs refinement |
maestro impeccable document to regenerate DESIGN.md |
| Codify knowledge assets persisted |
maestro search --type knowhow "design system" to verify |
|
|
1---2name: maestro-impeccable-23description: Use when designing, auditing, polishing, improving, or codifying frontend UI — websites, dashboards, landing pages, components, design systems Arguments: build|redesign|improve|enhance|launch|harden|foundation|live [target] [--codify <path>]4---56<teammate_contract>78- `background: false` is the default. Use foreground dispatch whenever the result determines the current answer or next action.9- Use `background: true` only for independent work. If this turn must consume a background result, call `observe` exactly once with `action: "wait"` and a bounded timeout before continuing; never continue independently while the result is pending.10- Otherwise end the turn and wait for the automatic `teammate-complete` notification. Do not rely on `SendMessage`, `team_msg`, or hook callbacks as completion signals.11- Never silently ignore an unfinished dispatch.1213</teammate_contract>1415<required_reading>16~/.maestro/workflows/run-mode.md17</required_reading>1819<deferred_reading>20Codify mode only (read when `--codify` and the corresponding phase starts):21- [ui-codify.md](~/.maestro/workflows/ui-codify.md) — read always in codify mode (main workflow orchestrator)22- [ui-codify-extract.md](~/.maestro/workflows/ui-codify-extract.md) — read when Codify Phase 2 starts (style extraction with 3 agents)23- [ui-codify-package.md](~/.maestro/workflows/ui-codify-package.md) — read when Codify Phase 3 starts (reference package generation)24- [ui-codify-knowhow.md](~/.maestro/workflows/ui-codify-knowhow.md) — read when Codify Phase 4 starts (knowledge asset generation)25</deferred_reading>2627<purpose>28UI design command: direct single-command, chain multi-step with quality gates, codify a design system from existing code, or search design knowledge.29Parse input → prerequisites → read workflow file → execute → track.30</purpose>3132## Input3334$ARGUMENTS first word determines mode:3536| First Word | Mode |37|------------|------|38| `--codify` / `codify` | Codify — extract design system from existing code (see `<codify_mode>`) |39| Known command (see routing table) | Direct |4041> Disambiguation for overlapping names (`harden`, `live`): bare keyword without target → Chain; keyword + explicit target/path → Direct. Override: `--chain` forces Chain, `--direct` forces Direct.4243| Chain name: build, redesign, improve, enhance, launch, harden, foundation, live | Chain |44| continue / next / -c | Resume |45| search | Search: `maestro impeccable search "$REST"` |46| Free text (any) | Free Text Routing (3-layer system below) |47| (empty) | Menu: show commands by category |4849## Command Routing5051All workflows at `~/.maestro/workflows/impeccable/{command}.md`:5253| Command | Category | Description |54|---------|----------|-------------|55| craft | Build | Shape then build end-to-end — full page/component implementation |56| shape | Build | Plan UX/UI before code — information architecture, wireframe, visual direction |57| teach | Build | Set up PRODUCT.md — users, brand, tone, anti-references, principles |58| document | Build | Generate DESIGN.md from existing code — extract tokens, typography, colors |59| extract | Build | Pull tokens/components into reusable design system |60| explore | Build | Multi-style comparison — generate variants, render prototypes, visual compare, select/mix |61| critique | Evaluate | UX heuristic review with Nielsen scoring (/40) + P0/P1 findings |62| audit | Evaluate | Technical quality checks — a11y, performance, responsive, code quality (/20) |63| polish | Refine | Final quality pass — micro-adjustments, pixel perfection |64| bolder | Refine | Amplify bland/safe designs — stronger personality, more contrast |65| quieter | Refine | Tone down aggressive/overwhelming designs — reduce visual noise |66| distill | Refine | Strip to essence — remove clutter, reduce cognitive load |67| harden | Refine | Production-ready — error states, i18n, edge cases, overflow, empty states |68| onboard | Refine | First-run flows, empty states, activation paths, progressive disclosure |69| animate | Enhance | Add purposeful motion — transitions, micro-interactions, scroll effects |70| colorize | Enhance | Add strategic color — OKLCH palette, contrast, color strategy |71| typeset | Enhance | Improve typography — scale, hierarchy, font pairing, line length |72| layout | Enhance | Fix spacing, rhythm, visual hierarchy, alignment, grid |73| delight | Enhance | Add personality — memorable details, joy, surprise moments |74| overdrive | Enhance | Push past conventional limits — ambitious visual effects |75| clarify | Fix | Improve UX copy — labels, error messages, microcopy, CTAs |76| adapt | Fix | Adapt for devices/screens — responsive, touch targets, breakpoints |77| optimize | Fix | Fix UI performance — loading, rendering, bundle, paint/layout jank |78| live | Iterate | Browser-based variant iteration — real-time design in DevTools |7980Reference files (loaded by workflow as needed, not standalone commands):81brand.md, product.md, design.md, codex.md, heuristics-scoring.md, cognitive-load.md,82color-and-contrast.md, interaction-design.md, motion-design.md, personas.md,83responsive-design.md, spatial-design.md, typography.md, ux-writing.md8485## Chains8687Chain step names below reuse Command Routing names but resolve through the chain runner. To avoid ambiguity with Direct command invocation, internal display, todo items, and session status records always tag chain steps with the `impeccable:` prefix (e.g. `impeccable:craft`, `impeccable:critique`). The bare names in this table refer to the workflow file at `~/.maestro/workflows/impeccable/{name}.md` that the chain step reads.8889| Chain | Steps | Scenario |90|-------|-------|----------|91| build | teach? → explore? → shape → craft → critique → [refine] → audit → polish | New from scratch |92| redesign | document → explore → shape → craft → critique → [refine] → audit → polish | Redesign existing code |93| improve | critique → [refine] → polish → audit | Iterative improvement |94| enhance | {cmd...} → critique → [refine] → polish | Targeted enhancement (multi-command) |95| launch | harden → adapt → optimize → audit → polish | Full production readiness |96| harden | harden → audit → polish | Edge case hardening |97| foundation | teach? → explore → document → extract | Design system setup |98| live | live | Real-time iteration |99100- `?` = conditional: teach if PRODUCT.md missing; explore if DESIGN.md missing and --skip-design not set101- `[refine]` = quality gate loop: gate fails → auto-select fix commands from findings → re-gate102- `{cmd...}` = enhance supports multiple commands, comma-separated: `enhance colorize,typeset landing-page`103104Chain flags: --threshold <N> (default 26/40), --max-loops <N> (default 3), --skip-design, --styles <N>, -y (skip Layer 2 ambiguity user prompt — select first matching chain; skip chain session confirmation; skip quality gate refine confirmations. Does NOT skip prerequisite checks.)105106## Free Text Routing107108Three-layer priority matching. Stop on first match — do not continue to lower layers.109110### Layer 1: Single command intent → Direct111112Semantically match user description against the Command Routing table's Description column. Match the closest **single** command.113114**Skip condition**: If the prompt matches a Layer 2 chain keyword AND matches MORE THAN ONE row in the Layer 1 intent signal table, skip this layer.115Example: `enhance colors and typography` — "enhance" is a chain keyword + multiple design dimensions → skip to Layer 2.116117| Intent signal | Command |118|---------------|---------|119| review, check UX, score, heuristic, evaluate usability | critique |120| audit, a11y, accessibility, technical check, performance audit, code quality | audit |121| add animation, motion, transitions, micro-interactions | animate |122| color, palette, OKLCH, contrast, color scheme | colorize |123| font, typography, type scale, line height, font pairing | typeset |124| layout, spacing, grid, alignment, visual hierarchy | layout |125| too loud, tone down, visual noise, make it simpler, too busy | quieter |126| too bland, bolder, more personality, stronger, more contrast | bolder |127| too complex, simplify, strip, remove clutter, cognitive load | distill |128| polish, fine-tune, pixel perfect, final pass, refine details | polish |129| copy, labels, error messages, UX writing, microcopy, CTAs | clarify |130| responsive, mobile, adapt, breakpoints, touch targets | adapt |131| performance, loading, bundle, jank, speed, rendering | optimize |132| edge cases, error states, i18n, overflow, empty state hardening | harden |133| onboarding, first-run, empty state, activation, progressive disclosure | onboard |134| fun, surprise, personality, memorable, joy, delight | delight |135| extraordinary, push limits, ambitious effects, cutting-edge | overdrive |136| plan UX, wireframe, information architecture, visual direction | shape |137| multi-style, variants, compare styles, style comparison | explore |138| brand definition, PRODUCT.md, product context | teach |139| extract design, DESIGN.md, document design system | document |140| pull tokens, extract components, design system extraction | extract |141| real-time, browser iteration, live editing | live |142143### Layer 2: Project intent → Chain144145Override: if the user explicitly uses a chain name as the primary verb (improve, enhance, redesign, build, launch), prefer Layer 2 chain even if Layer 1 matched a single command.146147Layer 1 did not match. Check for chain-level keywords — even if the prompt also contains a specific target/path, chain matching takes priority.148149| Pattern | Chain |150|---------|-------|151| new, create, build, from scratch, start fresh | build |152| redo, redesign, rethink, restyle, overhaul, revamp | redesign |153| improve, iterate, better, refine overall | improve |154| enhance, visual upgrade, level up | enhance |155| launch, deploy, ship, production-ready, go live | launch |156| harden, production-harden, edge cases | harden |157| design system, tokens, design foundation, design infrastructure | foundation |158| real-time, live, browser | live |159160Ambiguous + no `-y`:161162[@ask] AskUserQuestion (single-select, header: "意图确认"):163- Options: top 2-3 matched chains from Layer 2 table, each with label = chain name, description = matched keywords164- Last option: **"直接构建"** — skip chain, route to Layer 3 craft165166### Layer 3: Concrete build task → Direct craft167168Layer 1+2 both did not match, but intent is to build/create a specific thing:169- Contains a specific file path or target (`d:\path`, `src/pages/`, `index.html`)170- Contains ≥2 specific visual attributes (e.g., exact color values, font names, spacing numbers, layout structure description)171- Contains reference material (`based on...`, `like...`, `similar to...`)172173→ Route to **craft** (Direct)174175If all three layers produce no match → E001 (No command or intent resolved). Before raising E001, attempt [@ask] user prompt with top 2-3 closest matches from Layer 1+2 tables.176177## Prerequisites178179Before reading any command workflow:1801811. **Context**: `maestro load --type spec --category ui` → if empty → `maestro impeccable load-context`1822. **PRODUCT.md**: missing/placeholder (<200 chars / `[TODO]`) → execute teach first, then resume original task1833. **Register**: identify brand/product → Read `~/.maestro/workflows/impeccable/{brand|product}.md`184185## Direct Execution1861871. Prerequisites ✓1882. **Display execution info**:189 ```190 ── Command: {command} ────────────────────191 Category: {category} | Target: {target}192 ─────────────────────────────────────────193 ```1943. Read `~/.maestro/workflows/impeccable/{command}.md`1954. **TodoWrite tracking**: create todo items for each major phase in the workflow file196 - Format: `[{command}] {phase description}`197 - Mark each phase completed immediately upon finishing1985. Follow workflow file instructions1996. Post: suggest logical next command (teach→shape, shape→craft, craft→critique, etc.)200201## Chain Execution2022031. Prerequisites ✓2042. **Display chain preview**: parse chain definition, output full step preview (chain steps prefixed `impeccable:` to disambiguate from Direct commands):205 ```206 ── Chain: build ──────────────────────────207 1. impeccable:teach (conditional: PRODUCT.md missing)208 2. impeccable:explore (conditional: DESIGN.md missing)209 3. impeccable:shape210 4. impeccable:craft211 5. impeccable:critique ◆ quality gate (threshold: 26/40)212 6. impeccable:[refine] ↺ auto-fix loop (max: 3)213 7. impeccable:audit ◆ quality gate (threshold: 14/20)214 8. impeccable:polish215 ─────────────────────────────────────────216 Target: {target}217 ```218 - `◆` marks quality gate steps with threshold219 - `↺` marks refine loop with max iteration count220 - Conditional steps show trigger condition221 - Skipped conditional steps marked `(skipped)`2223. **Confirm chain session**: [@ask] user prompt "Create chain session for '{chain_type}' targeting '{target}'?" — proceed only if user confirms. On decline, abort chain.223 Create session: `.workflow/.maestro/ui-craft-{YYYYMMDD-HHmmss}/status.json`224 ```json225 { "chain_type": "...", "target": "...", "steps": [...], "current_step": 0,226 "gate_history": [], "loop_count": 0, "status": "running" }227 ```2284. **TodoWrite init**: create todo items for all chain steps229 - One item per step, format: `[chain] step N: impeccable:{command} — {description}` (use `impeccable:` prefix to disambiguate from Direct command items)230 - If conditional step is skipped, immediately mark completed231 - Quality gate steps include threshold: `[chain] step 5: impeccable:critique ◆ gate ≥26/40`2325. For each step:233 - Read `~/.maestro/workflows/impeccable/{command}.md` → execute234 - **Step start**: TodoWrite marks current step in_progress235 - **Step done**: TodoWrite marks completed + update status.json (`current_step`, step `status`)236 - **Step failed**: TodoWrite marks completed (with note) + record reason237 - **Failure classification**:238 - **Blocking** (chain stops): craft, shape, teach (if PRODUCT.md required)239 - **Non-blocking** (chain continues with W003): polish, delight, animate, colorize, typeset, layout, clarify, adapt, optimize, bolder, quieter, distill, harden, onboard240 - **Gate steps** (critique/audit): gate failure triggers refine loop, not step failure2416. **Quality gate** (critique/audit steps):242 - Parse score: critique `**Total** | | **N/40**`, audit `**Total** | | **N/20**`243 - Count `[P0]` / `[P1]` tags244 - Pass: score ≥ threshold AND P0 == 0 → advance245 - Fail: collect suggested commands from findings → execute → re-gate246 - Max loops exceeded → force advance with warning247 - TodoWrite: record gate result in current step notes (score, P0/P1 count, pass/fail)2487. Final report: scores + trend + commands executed249250## Codify Execution251252<codify_mode>253Extract a design system from existing source code into tokens, a reference package, and knowledge assets. 4-phase pipeline: validate → extract → package → knowhow.254255**Trigger**: first word is `--codify` or `codify`. Also reachable when the `foundation` chain reaches its `document`/`extract` steps and the user wants full reverse-extraction with knowhow persistence.256257**Arguments**: `--codify <source-path> [--package-name <name>] [--output-dir <path>] [--overwrite]`258- `<source-path>` (required): Directory containing CSS/SCSS/JS/TS/HTML source files259- `--package-name <name>`: Package name for reference output (default: auto-generated from source directory)260- `--output-dir <path>`: Output directory for reference package (default: `.workflow/reference_style`)261- `--overwrite`: Allow overwriting existing package directory262263**Output boundary**: ALL file writes MUST target the `--output-dir` path (default: `.workflow/reference_style/`) for reference packages, and `.workflow/knowhow/` for knowledge assets (manifest-driven direct writes per ui-codify-knowhow). NEVER modify the source directory being analyzed.264265### Codify Invariants2661. **Source read-only** — the source path being analyzed MUST NOT be modified; extraction is purely read-only2672. **Phase-sequential loading** — workflow files (ui-codify-extract, ui-codify-package, ui-codify-knowhow) MUST be read only when their phase starts; NEVER load all phases eagerly2683. **User confirmation before knowhow** — Phase 3→4 gate MUST present [@ask] user prompt before generating knowledge assets; NEVER auto-proceed to knowhow generation2694. **Overwrite protection** — existing package directory MUST NOT be overwritten without `--overwrite` flag (E102)2705. **Artifact completeness** — all 5 required artifacts MUST exist before reporting completion; NEVER skip artifact verification2716. **Token-first extraction** — design-tokens.json MUST be generated before layout-templates.json; layout extraction depends on token foundation272273### Step 1: Load UI Specs274```bash275maestro load --type spec --category ui276```277278### Step 2: Execute Workflow279Route to `~/.maestro/workflows/ui-codify.md` and follow completely. The workflow orchestrates 4 phases with deferred loading of phase-specific workflow files (see `<deferred_reading>`). Each phase reads its workflow file only when execution reaches that phase.280281### Codify Phase Gates (MANDATORY, BLOCKING)282283**GATE Phase 1 → Phase 2: Validation → Extraction**284- REQUIRED: Source path validated and file discovery completed.285- REQUIRED: design-tokens.json generated with color, typography, spacing tokens.286- BLOCKED if missing: source path invalid (E101) or design-tokens.json not generated — extraction cannot proceed without token foundation.287288**GATE Phase 2 → Phase 3: Extraction → Package**289- REQUIRED: layout-templates.json generated with component patterns.290- BLOCKED if missing: layout-templates.json absent — package generation requires component patterns as input.291292**GATE Phase 3 → Phase 4: Package → Knowhow**293- REQUIRED: preview.html + preview.css generated as interactive showcase.294- BLOCKED if missing: preview artifacts not generated — knowhow phase needs rendered reference for validation.295- REQUIRED: [@ask] user prompt confirmation before proceeding to knowhow generation:296 ```297 question: "Preview 生成完成。是否继续将设计系统持久化为 knowhow 知识资产?"298 options:299 - label: "继续生成 knowhow"300 description: "按 knowhow-manifest.json 写入 AST/DCS assets 和 spec entries"301 - label: "仅保留 preview,跳过 knowhow"302 description: "保留 preview.html + preview.css,不写入知识库"303 ```304305**GATE Phase 4 → Completion: Knowhow → Done**306- REQUIRED: knowhow-manifest.json created with AST/DCS assets and spec entries.307- REQUIRED: knowledge assets persisted — knowhow files + spec entries written to `.workflow/knowhow/` and `.workflow/specs/` per ui-codify-knowhow Step 4.4 (after user confirmation at Phase 3→4 gate).308- BLOCKED if missing: knowhow-manifest.json absent or knowledge assets not persisted.309310### Artifact Verification (before completion)311```312REQUIRED_ARTIFACTS = [313 "design-tokens.json", // Phase 1314 "layout-templates.json", // Phase 2315 "preview.html", // Phase 3316 "preview.css", // Phase 3317 "knowhow-manifest.json" // Phase 4318]319```320If any artifact is missing: DO NOT report completion.321</codify_mode>322323## Resume324325Scan `.workflow/.maestro/ui-craft-*/status.json` for `status == "running" || status == "paused"` → most recent → resume from `current_step`.326327## Quality Gate — Finding → Command Fallback328329When findings lack explicit suggested command:330331| Finding Category | Command |332|-----------------|---------|333| Layout, spacing, hierarchy, alignment | layout |334| Color, contrast, palette | colorize |335| Typography, font, readability | typeset |336| Animation, motion, transitions | animate |337| Copy, labels, UX writing | clarify |338| Responsive, mobile, breakpoints | adapt |339| Performance, loading, speed | optimize |340| Complexity, overload, clutter | distill |341| Bland, safe, generic | bolder |342| Aggressive, overwhelming | quieter |343| Onboarding, empty state | onboard |344| Edge cases, i18n, error handling | harden |345| Personality, memorability | delight |346347Never auto-select: teach, shape, craft, live, document, extract, overdrive, critique, audit.348349## Chain Phase Gates (MANDATORY for chain mode)350351**GATE: Quality Gate Step → Next Step**352- REQUIRED: Score parsed from critique/audit output (not assumed or estimated).353- REQUIRED: P0 count extracted from findings — P0 == 0 required for pass.354- REQUIRED: If gate fails, refine commands executed and re-gate attempted.355- BLOCKED if: score not parsed from actual output, or P0 > 0 and max refine loops not exhausted — do not advance past gate.356- Do NOT skip quality gate steps or mark as "passed" without parsing actual score.357- If score unparseable from output: retry the gate step once. If still unparseable → treat as gate fail (enter refine loop). Emit W005.358359**GATE: Chain → Completion**360- REQUIRED: All non-skipped steps executed (TodoWrite all completed).361- REQUIRED: status.json updated with `status: "completed"` and final scores.362- REQUIRED: If any step failed: documented in status.json with reason.363- BLOCKED if missing: steps not all completed or status.json not updated — chain is incomplete.364365<error_codes>366| Code | Severity | Condition | Recovery |367|------|----------|-----------|----------|368| E001 | error | No command or intent resolved from input | Provide a known command, chain name, or descriptive intent |369| E002 | error | Source/target path not found | Verify path exists |370| E003 | error | PRODUCT.md missing and teach step failed | Run `maestro impeccable teach` manually first |371| E004 | error | Chain quality gate failed after max loops | Review findings manually, fix critical issues, then resume |372| W001 | warning | UI specs not found via `maestro load --type spec --category ui` | Continuing without specs — output may miss project conventions |373| W002 | warning | Quality gate score below threshold but P0 == 0 | Auto-refine loop triggered |374| W003 | warning | Chain step failed but non-blocking | Step failure documented, chain continues |375| E101 | error | Codify: source path not found or not a directory | Verify `--codify <source-path>` exists |376| E102 | error | Codify: package directory exists without `--overwrite` | Re-run with `--overwrite` or a new `--output-dir` |377| W004 | warning | Codify: animation-tokens.json not found (optional) | Extraction continues without animation tokens |378| W005 | warning | Quality gate score unparseable from output | Retry gate step; if still fails, treat as gate fail |379</error_codes>380381<success_criteria>382Direct mode:383- [ ] Command resolved from input (routing table or free text matching)384- [ ] Prerequisites satisfied (UI specs loaded, PRODUCT.md present)385- [ ] Workflow file read and executed completely386- [ ] TodoWrite tracking created and all phases marked completed387- [ ] Next-step suggestion provided388389Chain mode:390- [ ] Chain steps resolved and preview displayed391- [ ] Session status.json created in `.workflow/.maestro/ui-craft-*/`392- [ ] TodoWrite items created for all chain steps393- [ ] Each step executed with workflow file read394- [ ] Quality gates parsed with actual scores (not estimated)395- [ ] Refine loops executed when gate fails (up to max-loops)396- [ ] status.json updated with `status: "completed"` and final scores397- [ ] Final report with scores, trend, and commands executed398399Codify mode:400- [ ] UI specs loaded via `maestro load --type spec --category ui` (if available)401- [ ] Source path validated and file discovery completed402- [ ] design-tokens.json generated with color, typography, spacing tokens403- [ ] layout-templates.json generated with component patterns (universal/specialized)404- [ ] animation-tokens.json generated (optional, W004 if missing)405- [ ] preview.html + preview.css generated as interactive showcase406- [ ] knowhow-manifest.json created with AST/DCS assets and spec entries407- [ ] knowledge assets persisted (knowhow + spec entries written per ui-codify-knowhow Step 4.4, after Phase 3→4 confirmation)408- [ ] Temporary workspace cleaned up409</success_criteria>410411<completion>412### Next-step routing413414| Condition | Suggestion |415|-----------|-----------|416| Direct teach complete | `maestro impeccable shape` |417| Direct shape complete | `maestro impeccable craft` |418| Direct craft complete | `maestro impeccable critique` |419| Direct critique findings | `maestro impeccable polish` or targeted fix command |420| Chain complete | Review final scores, consider `maestro impeccable improve` for iteration |421| Chain paused/interrupted | `maestro impeccable continue` to resume |422| Codify complete | Use extracted tokens in `maestro impeccable craft` for new builds |423| Codify design system needs refinement | `maestro impeccable document` to regenerate DESIGN.md |424| Codify knowledge assets persisted | `maestro search --type knowhow "design system"` to verify |425</completion>