skills/design/SKILL.md
Generate design system and UI mockups for a feature using Pencil MCP. Runs after SPEC phase, before BEADS. Produces MASTER.md (design tokens), screen-map.md (screen breakdown), and a .pen file with reusable components and screen frames. Use when the workflow reaches DESIGN state or user asks to design screens/UI. Integrates impeccable best practices OKLCH colors, tinted neutrals, modular typography, spatial rhythm, motion tokens, 8-state component design, and UX writing.
npx skillsauth add tunneleven/C4Flow c4flow:designInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Phase: 2: Design & Beads Agent type: Main agent (interactive) + sub-agents (parallel screen composition) Status: Implemented
Step 0: Teach → Auto-parse context → Recommend → User approves
Phase 1: → Screen map + Design system tokens + Components + Hero screen
Phase 2: → Remaining screens (sub-agents, parallel)
Phase 3: → Final review + Gate check → update .state.json → BEADS
Before Pencil MCP or any design work, gather persistent project context.
Read: references/teach.md for the full protocol.
[ -f "docs/specs/<feature>/context.md" ] && echo "CONTEXT_EXISTS"
[ -f ".impeccable.md" ] && echo "IMMACULATE_EXISTS"
Scan these files without asking the user. Extract what you can:
README.md # Product type, value prop, users
docs/specs/<feature>/spec.md # Requirements, constraints
docs/specs/<feature>/proposal.md # Goals, scope, brand tone
package.json / pyproject.toml # Tech stack, framework
src/**/*.{css,scss,styles,css.ts} # Existing tokens, design variables
components/**/*.{tsx,jsx,vue} # Component names, structure
docs/**/*.md # Any existing design docs
CLAUDE.md / .cursorrules # Existing design guidance
Synthesize into a Design Context Recommendation:
Design Context — Recommended
Product type: [parsed — e.g., SaaS dashboard, e-commerce, developer tool]
Target users: [parsed — role, tech level, context]
Brand personality: [3 words — e.g., Professional, minimal, trustworthy]
Aesthetic direction:
Recommended: [bold direction based on product type + brand]
Anti-references: [what to avoid — AI slop patterns to reject]
Design tokens: [existing CSS variables/tokens found]
Accessibility: WCAG AA (default) / WCAG AAA / custom target
Tech stack: [parsed from package.json — framework, styling approach]
Design system: [detected (Tailwind, MUI, Chakra) or "none"]
⚠️ Couldn't infer: [list anything missing — user can fill in or accept recommendation]
User can edit any field, add missing context, or approve as-is.
After approval, save:
# Inside c4flow workflow: alongside spec
cp /tmp/context.md "docs/specs/<feature>/context.md"
# Standalone project: project root
cp /tmp/context.md ".impeccable.md"
Then proceed to Phase 1.
Before Phase 1, verify:
get_editor_state(). If it fails: "Design skill requires Pencil MCP. Install from https://docs.pencil.dev/getting-started/ai-integration"docs/specs/<feature>/spec.md exists — if not, run SPEC phase firstdocs/specs/<feature>/design.md exists — if not, run SPEC phase firstRead workflow state from docs/c4flow/.state.json to get feature.slug and feature.name.
Check docs/c4flow/designs/<slug>/ before starting:
| Existing State | Resume From |
|---|---|
| Directory doesn't exist | Step 1.1 (analyze & screen map) |
| screen-map.md exists, no MASTER.md | Step 1.2 (design tokens) |
| MASTER.md exists, no components in .pen | Step 1.3 (reusable components) |
| Components exist, no screen frames | Step 1.4 (hero screen) |
| Hero screen exists, remaining screens missing | Phase 2 (sub-agents) |
| All screens exist | Phase 3 (final review) |
If resuming, tell user: "Found existing design artifacts. Resuming from [step]. Say 'regenerate' to start over."
Goal: Understand what screens to build and get user approval.
skills/design/references/design-principles.md — Impeccable context gathering + AI slop testdocs/specs/<feature>/spec.md — extract all MUST requirements + scenariosdocs/specs/<feature>/design.md — extract components, data model, API endpointsdocs/specs/<feature>/proposal.md if exists — extract target audience, brand toneskills/design/references/ux-writing.md — for UX writing guidelinesI've analyzed the spec and propose these screens:
[Auth Flow] (3 screens): Login, Register, Forgot Password
[Dashboard] (2 screens): Overview, Analytics
[Feature X] (3 screens): List, Create, Detail
Shared components needed: Nav, Sidebar, Button, Input, Card, Badge, Table, Modal
Does this look right? Want to add, remove, or merge any screens?
docs/c4flow/designs/<slug>/docs/c4flow/designs/<slug>/screen-map.md:# Screen Map: <feature-name>
## <Flow Name> (N screens)
### <Screen Name> — <frame-name>
- **Components:** Nav, Input×2, Button(primary)
- **Spec refs:** spec.md#<section>
- **Notes:** <layout or interaction notes>
Goal: Create project-specific design tokens, save to .pen file and MASTER.md.
skills/design/references/color-and-contrast.md — OKLCH, tinted neutrals, 60-30-10skills/design/references/typography.md — modular scale, font pairingskills/design/references/spatial-design.md — 4pt scale, rhythmskills/design/references/quality-checklist.md — AI slop detectionget_style_guide_tags() → get available tagsget_style_guide(name: <chosen-guide>) → get style inspirationget_guidelines(topic: "design-system") → get Pencil schema rulesopen_document("new") → creates new .pen fileset_variables() with all tokensbatch_design() → create "Design System" frame with color swatches + type scale samplesget_screenshot() on the DS framereferences/quality-checklist.md)docs/c4flow/designs/<slug>/MASTER.md:# MASTER: <feature-name> Design System
## Design Tokens
| Token | Value | Purpose |
|-------|-------|---------|
| `--primary` | `oklch(...)` | CTAs, links |
| `--bg` | `oklch(...)` | Page background |
| `--fg` | `oklch(...)` | Body text |
| `--muted` | `oklch(...)` | Secondary text |
| `--border` | `oklch(...)` | Borders |
| `--card` | `oklch(...)` | Card surfaces |
| `--destructive` | `oklch(...)` | Errors |
| `--success` | `oklch(...)` | Confirmations |
| `--warning` | `oklch(...)` | Warnings |
| `font-heading` | `'...'` | Heading font |
| `font-body` | `'...'` | Body font |
| `space-xs` | `4` | Tight spacing |
| `space-sm` | `8` | Small spacing |
| `space-md` | `16` | Medium spacing |
| `space-lg` | `32` | Large spacing |
| `space-xl` | `64` | XL spacing |
## Motion Tokens
| Token | Value | Purpose |
|-------|-------|---------|
| `--duration-fast` | `150ms` | Button press, toggle |
| `--duration-normal` | `250ms` | Menu open, tooltip |
| `--duration-slow` | `400ms` | Accordion, drawer |
| `--ease-out` | `cubic-bezier(0.16,1,0.3,1)` | Elements entering |
| `--ease-in` | `cubic-bezier(0.7,0,1,1)` | Elements leaving |
## Reusable Components
| Component | Variants | Frame ID |
|-----------|----------|----------|
| Button | Primary, Secondary, Ghost, Destructive | `<id>` |
| Input | Default, Error, Disabled | `<id>` |
| ... | ... | ... |
## File
- Pencil file: `docs/c4flow/designs/<slug>/<slug>.pen`
- Design System Frame ID: `<id>`
.pen file: call get_editor_state() to get the current document path. If not saved to target path, call open_document("save", path: "docs/c4flow/designs/<slug>/<slug>.pen").Goal: Create all shared components in the .pen file as reusable frames.
skills/design/references/component-patterns.md — 8 interaction states, focus rings, formsskills/design/references/spatial-design.md — 4pt scale, rhythmtech-stack.mdscreen-map.md, extract the full component listbatch_design() — insert frame with reusable: true inside the Design System framebatch_design call — split if neededget_screenshot() on the Design System frameBinding names must be unique across calls. Never reuse a binding name.
Goal: Compose the most complex screen using reusable components, validate style direction.
references/*.md files — this is the most design-intensive steptech-stack.md or use defaults from references/spatial-design.mdfind_empty_space_on_canvas({direction: "right", width: <w>, height: <h>}) → get positionbatch_design() → create screen frame at that positionbatch_get({patterns: [{reusable: true}], searchDepth: 2}) → get all component ref IDsbatch_design() → compose screen using {type: "ref", ref: "<id>"} for components
get_screenshot() on the screen framesnapshot_layout({nodeIds: [<screenId>], problemsOnly: true}).state.json:
jq '.heroScreen = "<hero-frame-id>" | .designSystem = "docs/c4flow/designs/<slug>/<slug>.pen" | .screenCount = <N>' \
docs/c4flow/.state.json > docs/c4flow/.state.json.tmp \
&& mv docs/c4flow/.state.json.tmp docs/c4flow/.state.json
Goal: Compose remaining screens concurrently — each screen gets its own sub-agent running in parallel. All agents write to the same .pen file safely (Pencil MCP handles concurrent writes).
screen-map.md — list all screens except the herobatch_get({patterns: [{reusable: true}], searchDepth: 2}) — extract ALL component ref IDs once before dispatching.pen path, DS frame ID, hero frame ID, screen spec, all component ref IDs, design tokenshaiku, dashboard/complex → sonnetget_screenshot() for all screen frames, present batch review# Design Screen: {screen_name}
## Context
Feature: {feature_name}
Pencil MCP file: {pen_file_path}
Design System Frame ID: {ds_frame_id}
Hero Screen Frame ID: {hero_frame_id} — match spacing rhythm, visual weight, layout patterns
Screen Dimensions: {width}×{height}
## Screen Spec (from screen-map.md)
{full screen entry from screen-map.md}
## Reusable Components Available
{list each: name: ref="<id>"}
## Design Tokens (from MASTER.md)
Primary: {value}
Background: {value}
Foreground: {value}
Font heading: {value}
Font body: {value}
Spacing scale: 4 · 8 · 12 · 16 · 24 · 32 · 48 · 64
## Impeccable Design Rules (non-negotiable)
- No pure black/gray — tinted neutrals only (chroma ≥ 0.005)
- No card nesting — use spacing for hierarchy within sections
- Squint test: primary element identifiable in 2 seconds
- Every interactive element needs clear affordance
- Tight grouping (8-12px) for related items, generous (48-96px) between sections
- 60-30-10 color weight rule (neutrals 60%, secondary 30%, accent 10%)
- No identical repeated card grids (icon + heading + text repeated)
- Match hero screen's layout rhythm and visual weight
- Motion: ease-out for entering, ease-in for leaving — no bounce/elastic
- Animate only transform + opacity
## AI Slop Checklist (run before reporting DONE)
- [ ] No gradient text or backgrounds
- [ ] No glassmorphism
- [ ] No pure gray neutrals
- [ ] No hero metric layout (big number, small label, stats, gradient)
- [ ] No Inter/Roboto/Arial fonts
- [ ] No rounded rectangles with generic drop shadows everywhere
## Report
Return: DONE | DONE_WITH_CONCERNS | BLOCKED
Include:
- Screen frame ID
- Screenshot verified: yes/no
- Issues found: <list or "none">
| Screen Type | Model |
|---|---|
| Simple form (login, register, settings) | haiku |
| Dashboard / data-heavy / multi-section | sonnet |
| Complex flow (multi-step wizard) | sonnet |
get_screenshot() of entire canvas (all frames)export_nodes() for all screen frame IDs → PNG exportsdocs/c4flow/designs/<slug>/MASTER.md existsdocs/c4flow/designs/<slug>/screen-map.md exists.pen file exists with Design System frame + ≥1 screen framescreen-map.md have corresponding frames.state.json:
# Read current state first
CURRENT=$(cat docs/c4flow/.state.json)
COMPLETED=$(echo "$CURRENT" | jq -r '.completedStates // []')
PHASE_NAME="DESIGN"
# Add DESIGN to completedStates if not already there
if echo "$COMPLETED" | grep -q "\"$PHASE_NAME\""; then
NEW_COMPLETED="$COMPLETED"
else
NEW_COMPLETED=$(echo "$COMPLETED" | jq --arg p "$PHASE_NAME" '. + [$p]')
fi
# Update state: mark DESIGN done, screenCount, design path, move to next state
echo "$CURRENT" | jq \
--argjson completed "$NEW_COMPLETED" \
--arg count "<N>" \
--arg designPath "docs/c4flow/designs/<slug>/<slug>.pen" \
--arg nextState "BEADS" \
'
.completedStates = $completed
| .currentState = $nextState
| .screenCount = ($count | tonumber)
| .designPath = $designPath
' > docs/c4flow/.state.json.tmp \
&& mv docs/c4flow/.state.json.tmp docs/c4flow/.state.json
Critical: This is the ONLY place
.state.jsonis updated during design. The orchestrator reads this file to determine the next state (BEADS).
| Situation | Action |
|---|---|
| Pencil MCP not available | Abort: "Design skill requires Pencil MCP." |
| spec.md or design.md missing | Abort: "Run SPEC phase first (/c4flow:run)" |
| get_style_guide returns no results | Proceed with Impeccable defaults from reference files |
| Sub-agent can't find component ref | Re-call batch_get(), provide correct ref IDs, re-dispatch |
| snapshot_layout reports issues | Fix via batch_design, re-screenshot (1 auto-retry), then DONE_WITH_CONCERNS |
| Canvas space insufficient | Call find_empty_space_on_canvas with larger dimensions |
| User rejects design 3+ times | Ask: "Want to try a different style direction?" |
| batch_design fails (rollback) | Check error message, fix operation list, retry |
| .pen file corrupted or empty | Delete file, restart from Step 1.2 |
| >15 screens | Batch into groups of 5, user review between groups |
batch_design max 25 operations per call — split by logical sectionI(), C(), R() operation must have a binding namedocument is reserved — only use when creating top-level canvas framesbatch_design callU() descendants of a freshly C()'d node"image" node type — images are fills on frame/rectangle nodesfind_empty_space_on_canvas before every new screen frameRead as needed:
references/teach.md — Context gathering (auto-parse, recommend, approve)references/design-principles.md — Impeccable design direction + AI slop testreferences/color-and-contrast.md — OKLCH, tinted neutrals, 60-30-10, dark modereferences/typography.md — Modular scale, font pairing, vertical rhythmreferences/spatial-design.md — 4pt scale, visual rhythm, card usage rulesreferences/component-patterns.md — 8 states, focus rings, forms, loading statesreferences/quality-checklist.md — AI slop detection, contrast, hierarchy, spacingreferences/motion.md — Easing curves, timing, prefers-reduced-motionreferences/interaction.md — Keyboard nav, gestures, destructive actionsreferences/responsive.md — Mobile-first, container queries, input detectionreferences/ux-writing.md — Button labels, errors, empty states, terminologydevelopment
Quality gate aggregation — runs bd preflight, combines with Codex review results, declares Ready for PR status. Use when the user wants to check if code is ready for PR, verify quality gates, or run preflight checks. Also triggers when mentioning "verify", "preflight", "quality gate", or "ready for PR".
development
Run unit and integration tests with coverage checking. Auto-detect framework, classify failures, enforce coverage threshold before advancing to review. Use when the user wants to run tests, check coverage, or validate implementation quality. Triggers on "run tests", "check coverage", "test suite", or when the code phase completes.
development
Test-driven development — RED-GREEN-REFACTOR cycles for all C4Flow implementation work. Merged into c4flow:code as a sub-agent phase with a mandatory RED gate pause. Use c4flow:code to run the full task loop.
testing
Sync local project with remote sources — pulls DoltHub beads and GitHub repo to local. Handles the "no common ancestor" Dolt error that occurs when bd init creates a fresh local DB that conflicts with an existing DoltHub history. Use when local beads are out of sync, after a fresh init on a project that already has DoltHub data, or to pull the latest GitHub changes.