designagent-cli 0.1.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.
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: a11y-check
3
+ description: Audit color pairs and touch targets against WCAG AA. Use when reviewing a design system, a screen, or before shipping UI for accessibility.
4
+ reads: [DESIGN.md, CLAUDE.md]
5
+ ---
6
+
7
+ # a11y-check
8
+
9
+ Audit the project's tokens and UI against WCAG AA and platform accessibility minimums. Output specific, actionable fixes.
10
+
11
+ ## When to use
12
+ Reviewing `DESIGN.md` color pairs, auditing a screen/component, or as a gate before shipping.
13
+
14
+ ## Checks
15
+
16
+ ### Contrast (WCAG AA)
17
+ - For every `on-*` / surface or foreground/background pair in `DESIGN.md`, compute the contrast ratio.
18
+ - **Pass:** ≥4.5:1 for normal text, ≥3:1 for large text (≥24px, or ≥18.66px bold) and meaningful UI/graphics.
19
+ - Report each failing pair with its ratio and a suggested adjusted hex that passes while staying close to the intended hue.
20
+
21
+ ### Touch / click targets
22
+ - iOS: ≥44×44pt. Android: ≥48×48dp. Web: ≥24×24px with adequate spacing.
23
+ - Flag interactive elements below the minimum.
24
+
25
+ ### Non-color signals
26
+ - Flag any state conveyed by color alone (error, success, selection) — require an icon, text, or shape pairing.
27
+
28
+ ### Focus & keyboard
29
+ - Every interactive element must have a visible, non-color-only focus indicator and full keyboard operability.
30
+
31
+ ### Semantics
32
+ - Inputs have labels; icon-only controls have accessible names; meaningful images have alt text; motion respects reduced-motion.
33
+
34
+ ## Process
35
+ 1. Parse `DESIGN.md` tokens; enumerate all foreground/background pairings (including component `backgroundColor`/`textColor`).
36
+ 2. Compute contrast for each; collect failures.
37
+ 3. If auditing code, scan for target sizes, focus styles, labels, and color-only signals.
38
+ 4. Output a prioritized fix list: each item = location, the problem, the measured value, and the concrete fix.
39
+
40
+ ## Output contract
41
+ - A table of color pairs with ratios and pass/fail.
42
+ - A prioritized list of fixes (highest impact first).
43
+ - No vague advice — every item names a token/element and a specific change.
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: component-audit
3
+ description: Scan the codebase for hardcoded values and token drift, cross-reference against DESIGN.md, and produce a prioritized fix list. Use when checking design-system adherence or before a cleanup pass.
4
+ reads: [DESIGN.md, CLAUDE.md, .designagent/config.json]
5
+ ---
6
+
7
+ # component-audit
8
+
9
+ Find where the code has drifted from the design system and rank the fixes. This is James's killer feature: turn invisible drift into a concrete, prioritized list.
10
+
11
+ ## When to use
12
+ Auditing a codebase for design-system adherence, before a refactor, or to quantify drift for the team.
13
+
14
+ ## Inputs
15
+ 1. `DESIGN.md` — the source-of-truth tokens to measure against.
16
+ 2. `.designagent/config.json` — frameworks in play (so the scan targets the right files).
17
+ 3. The codebase itself.
18
+
19
+ ## What to flag
20
+ - **Hardcoded colors** — hex/rgb/hsl/named CSS colors that match (or nearly match) a `DESIGN.md` color token. Suggest the token.
21
+ - **Magic spacing** — px/rem values off the spacing scale. Suggest the nearest on-scale token.
22
+ - **One-off type** — font sizes/weights not in the typography tokens.
23
+ - **Missing token references** — components that re-declare a value a token already covers.
24
+ - **Orphan values** — colors/sizes that appear once or twice with no token and no pattern (candidates either to tokenize or remove).
25
+
26
+ ## Process
27
+ 1. Read `DESIGN.md` tokens into a lookup (color hexes, spacing values, radii, type).
28
+ 2. Scan source for literal values (prefer the `@designagent/scanner` drift report if available — it already maps file:line → nearest token).
29
+ 3. For each finding, attach: file, line, the literal, the nearest token, and a confidence (exact match vs. approximate).
30
+ 4. **Prioritize:** exact-match drift first (mechanical fixes), then near-matches, then orphans. Within each, sort by frequency (most-repeated value = biggest win).
31
+
32
+ ## Output contract
33
+ - A prioritized table: file:line · value · suggested token · confidence.
34
+ - A short summary: total drift, % that are exact-match (auto-fixable), top 3 highest-impact values.
35
+ - Never auto-edit unless asked — this skill reports; fixing is a separate, confirmed step.
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: copywriting
3
+ description: Write UI copy in the product's brand voice, following platform conventions and any voice guidelines in CLAUDE.md. Use when writing or revising microcopy — labels, buttons, empty states, errors, onboarding.
4
+ reads: [CLAUDE.md, DECISIONS.md]
5
+ ---
6
+
7
+ # copywriting
8
+
9
+ Write interface copy that sounds like the product and respects the platform.
10
+
11
+ ## When to use
12
+ Drafting or revising microcopy: button labels, form labels and helper text, empty states, error and success messages, tooltips, onboarding, confirmations.
13
+
14
+ ## Inputs
15
+ 1. `CLAUDE.md` — product identity and any voice/tone guidance.
16
+ 2. `DECISIONS.md` — naming and terminology decisions to stay consistent with.
17
+ 3. The surface being written (what the user is doing and what just happened).
18
+
19
+ ## Principles
20
+ - **Clarity over cleverness.** The user is mid-task; say what's true and what to do next.
21
+ - **Voice from the product, not a default.** Match the tone established in `CLAUDE.md`; don't impose generic friendly-startup voice.
22
+ - **Action labels are verbs.** Buttons say what happens ("Save changes", not "OK"). One primary action per surface.
23
+ - **Errors are helpful, not blaming.** What went wrong + how to fix it. No "Oops!" for serious failures.
24
+ - **Consistent terminology.** Reuse the product's nouns (check `DECISIONS.md`); don't call the same thing three names.
25
+ - **Platform conventions.** Respect iOS HIG / Android / web norms for casing, punctuation, and standard terms.
26
+
27
+ ## Process
28
+ 1. Read the voice guidance and existing terminology first.
29
+ 2. For each string: state the user's goal and context, then write the shortest copy that's clear and on-voice.
30
+ 3. Provide 1–2 alternatives for key strings (e.g. the primary CTA) when tone could reasonably vary.
31
+ 4. Check length against the UI — labels must fit their controls.
32
+
33
+ ## Output contract
34
+ - The copy, mapped to each UI element/state.
35
+ - Terminology consistent with `DECISIONS.md`; flag any new term introduced so it can be recorded.
36
+ - Note platform-specific variants when the copy differs across iOS/Android/web.
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: design-review
3
+ description: Review a screen or component against DESIGN.md tokens and CLAUDE.md craft principles, and return a structured critique with specific fixes. Use when reviewing UI work before it ships.
4
+ reads: [DESIGN.md, CLAUDE.md, DECISIONS.md]
5
+ ---
6
+
7
+ # design-review
8
+
9
+ Review UI against the project's own standards — not generic taste. Output a structured, fixable critique.
10
+
11
+ ## When to use
12
+ Reviewing a component, screen, or PR for design quality before it merges.
13
+
14
+ ## Inputs
15
+ 1. `CLAUDE.md` — the craft principles and "Do not" list to review against.
16
+ 2. `DESIGN.md` — exact token values.
17
+ 3. `DECISIONS.md` — prior rationale that may justify an apparent "violation".
18
+ 4. The component/screen (code, and a screenshot if available).
19
+
20
+ ## Review dimensions (score each, with specific fixes)
21
+ - **Hierarchy** — is the primary action clear? One focal point per view? Size/weight/color used intentionally?
22
+ - **Spacing** — on the scale? Consistent rhythm? Related things grouped, unrelated things separated?
23
+ - **Color** — role tokens used correctly (`primary` for primary action, `on-*` on surfaces)? No raw values?
24
+ - **Typography** — named type tokens only? Sensible scale steps? Readable measure/line-height?
25
+ - **Accessibility** — AA contrast, focus states, target sizes, semantics (defer detail to `a11y-check`).
26
+ - **Consistency** — matches existing components and `DECISIONS.md`? No reinvented primitives?
27
+
28
+ ## Process
29
+ 1. Read the standards first (`CLAUDE.md`, `DESIGN.md`), then the work.
30
+ 2. Check each dimension; cite the exact token or principle a finding relates to.
31
+ 3. Before flagging an inconsistency, check `DECISIONS.md` — it may be deliberate.
32
+ 4. Separate **must-fix** (violates a token/principle/AA) from **consider** (subjective polish).
33
+
34
+ ## Output contract
35
+ - Per-dimension findings, each with: what, where, why it matters, and the specific fix (name the token/value).
36
+ - A short verdict: ship / ship-with-fixes / needs-work.
37
+ - No vague advice ("improve spacing") — always name the token or value to change.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: design-to-code
3
+ description: Turn a design intent, screenshot, or canvas node into production code for this project's framework(s), using DESIGN.md tokens. Use when implementing UI from a design, mockup, or description.
4
+ reads: [DESIGN.md, CLAUDE.md, DECISIONS.md, .designagent/config.json]
5
+ frameworks: [react, vue, svelte, react-native, swiftui, compose]
6
+ ---
7
+
8
+ # design-to-code
9
+
10
+ Translate design intent into production code that respects the project's token system and conventions.
11
+
12
+ ## When to use
13
+ Implementing a screen/component from a screenshot, a canvas node, a description, or a redline — for any framework configured in this project.
14
+
15
+ ## Inputs to read first
16
+ 1. `.designagent/config.json` — the configured framework(s), design system, and canvas.
17
+ 2. `DESIGN.md` — exact token values (colors, typography, spacing, rounded, components).
18
+ 3. `CLAUDE.md` — framework conventions and the "Do not" list.
19
+ 4. `DECISIONS.md` — prior rationale that constrains the implementation.
20
+
21
+ ## Process
22
+ 1. **Identify the target framework** from config. If multiple, ask which target (or generate the shared token layer plus the requested platform).
23
+ 2. **Decompose** the design into the smallest reusable primitives. Reuse existing components before creating new ones.
24
+ 3. **Map every visual value to a token.** Color → color token, spacing → spacing scale, radius → rounded, text → typography token. If a value has no token, add it to `DESIGN.md`, lint, then use it. Never emit a raw hex/size/spacing literal that a token covers.
25
+ 4. **Emit framework-idiomatic output:**
26
+ - **React / Vue / Svelte** → components using Tailwind utilities or CSS variables exported via `npx @google/design.md export --format css-tailwind DESIGN.md`.
27
+ - **React Native** → `StyleSheet.create` referencing token constants; handle `Platform.OS` differences.
28
+ - **SwiftUI** → a `DesignTokens.swift` (Color/Font extensions) bridge + `View` code using semantic colors, SF Symbols, Dynamic Type. Modifier order: content → layout → background → overlay → accessibility.
29
+ - **Jetpack Compose** → a `Theme.kt`/`Tokens.kt` (Material 3 `ColorScheme` + token objects) + composables reading `MaterialTheme.*`, with `modifier` params and slot APIs.
30
+ 5. **Accessibility pass:** labels, focus/keyboard, contrast (AA), touch targets (44pt iOS / 48dp Android / 24px web). Run `a11y-check` if available.
31
+ 6. **Self-review** against `CLAUDE.md` principles and the "Do not" list. Record any non-obvious decision in `DECISIONS.md`.
32
+
33
+ ## Output contract
34
+ - Tokenized, idiomatic, accessible code for the requested framework.
35
+ - A short note of which tokens were used and any new tokens added to `DESIGN.md`.
36
+ - No hardcoded values that duplicate a token.
37
+
38
+ ## Note on mobile
39
+ There is no automated Swift/Kotlin token exporter in `@google/design.md` yet, so this skill generates the bridge file (`DesignTokens.swift` / `Theme.kt`) directly from `DESIGN.md`. Keep that file as the single source the views read from, and regenerate it when tokens change.
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: redlines
3
+ description: Generate a precise implementation spec (redlines) from a component — dimensions, spacing, colors, type, and states — expressed in token names, framework-aware. Use when handing a component to engineering or documenting it.
4
+ reads: [DESIGN.md, CLAUDE.md, .designagent/config.json]
5
+ ---
6
+
7
+ # redlines
8
+
9
+ Produce an exact, build-ready spec for a component, expressed in tokens rather than raw values.
10
+
11
+ ## When to use
12
+ Documenting a component for handoff or its own spec sheet — the inverse of `design-to-code`.
13
+
14
+ ## Inputs
15
+ 1. The component (code and/or a canvas node).
16
+ 2. `DESIGN.md` — to express every measurement as a token, not a literal.
17
+ 3. `.designagent/config.json` — framework, so the spec's code references match the target.
18
+
19
+ ## What to specify
20
+ - **Layout** — width/height behavior (fill vs. hug), alignment, internal direction.
21
+ - **Spacing** — padding and gaps as spacing tokens (`spacing.md`), not px.
22
+ - **Color** — background/text/border as color tokens (`colors.surface`, `colors.on-surface`).
23
+ - **Shape** — corner radius as a `rounded.*` token; border width.
24
+ - **Typography** — the named type token per text element.
25
+ - **States** — default / hover / focus / active / disabled / loading, each as token deltas from default.
26
+ - **Accessibility** — target size, focus ring, contrast notes, required labels.
27
+
28
+ ## Process
29
+ 1. Inspect the component; resolve every concrete value back to its nearest `DESIGN.md` token (flag any that don't map — that's drift to fix first).
30
+ 2. Lay out the spec per element, then per state.
31
+ 3. Express measurements in token names; include the resolved value in parentheses for reference.
32
+ 4. Match output format to the framework (e.g. SwiftUI modifier names, Tailwind utilities, Compose params).
33
+
34
+ ## Output contract
35
+ - A structured spec: element → property → token (resolved value), then a states table.
36
+ - Accessibility notes inline.
37
+ - Anything that can't be expressed as a token is called out as drift, not silently hardcoded.
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: token-namer
3
+ description: Rename heuristic/auto-generated color tokens (e.g. accent-4, color-1) to semantic, role-based names in DESIGN.md — done by Claude Code itself, no API key needed. Use right after `designagent init` or whenever DESIGN.md has non-semantic color names.
4
+ reads: [DESIGN.md, DECISIONS.md, .designagent/config.json]
5
+ ---
6
+
7
+ # token-namer
8
+
9
+ Give a reverse-engineered design system **good names** — the "taste" step. The scanner extracts real colors but can only guess names heuristically (`primary`, `secondary`, or fallbacks like `accent-4`). You — the Claude Code already running in this project — assign semantic, role-based names. This needs **no external API and no API key**: it's your judgment, applied to the user's own session.
10
+
11
+ ## When to use
12
+ - Immediately after `designagent init` generated `DESIGN.md`.
13
+ - Whenever `DESIGN.md` contains non-semantic color names (`accent-N`, `color-N`, `neutral-N`) or names that don't match how the color is actually used.
14
+
15
+ ## What "good" looks like
16
+ Role-based, lowercase, kebab-case, matching `/^[a-z][a-z0-9-]*$/` (never start with a digit — required for Tailwind v4 export). Prefer these roles where they fit:
17
+ `primary`, `secondary`, `tertiary`, `neutral`, `surface`, `on-surface`, `on-primary`, `outline`, `muted`, `accent`, `error`, `success`, `warning`, `info`.
18
+
19
+ ## Process
20
+ 1. Read `DESIGN.md` colors. For each, note its hex, usage count (if present), and how it's actually used in the codebase (grep the source: backgrounds → `surface`, body text → `on-surface`, the most-used saturated brand color → `primary`, destructive/error states → `error`, borders → `outline`).
21
+ 2. Propose a semantic name per token. Resolve collisions (two colors both "primary" → `primary` + `secondary`/`accent`). Keep already-good names.
22
+ 3. **Rewrite `DESIGN.md`**: rename the color keys AND update every `{colors.<old>}` reference (components, etc.) to the new name. Don't orphan a reference.
23
+ 4. **Lint:** `npx @google/design.md lint DESIGN.md` — must be 0 errors. Fix any digit-leading or duplicate names.
24
+ 5. **Export-check:** `npx @google/design.md export --format css-tailwind DESIGN.md` must succeed (catches invalid token names).
25
+ 6. Record the rename map (old → new) in `DECISIONS.md` with today's date, so the rationale is preserved.
26
+
27
+ ## Output contract
28
+ - `DESIGN.md` with semantic color names, all references updated, lints + exports clean.
29
+ - A `DECISIONS.md` entry listing the renames and the reasoning.
30
+ - Never invent colors or change hex values — this is naming only.
31
+
32
+ ## Note
33
+ For non-interactive/CI use where there's no Claude Code session, `designagent <cmd> --ai` does the same naming via a direct Anthropic API call (needs `ANTHROPIC_API_KEY`). In normal interactive use this skill is preferred — it's free and uses the session you already have open.
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: token-sync
3
+ description: Pull design tokens from the canvas (Figma / Pencil / OpenPencil) into DESIGN.md and record the diff. Use when the canvas changed and DESIGN.md needs to catch up.
4
+ reads: [DESIGN.md, .designagent/config.json]
5
+ requires: [figma-mcp OR pencil-mcp OR .pen file]
6
+ ---
7
+
8
+ # token-sync
9
+
10
+ Keep `DESIGN.md` in sync with the design canvas, then lint and record what changed.
11
+
12
+ ## When to use
13
+ The canvas (Figma variables, a Pencil/OpenPencil file) changed and `DESIGN.md` should reflect it — or you want to seed `DESIGN.md` from an existing canvas.
14
+
15
+ ## Source by canvas (read from `.designagent/config.json`)
16
+ - **Figma** → read variables/styles via the Figma Dev Mode MCP. Map collections to `colors`, `typography`, `spacing`, `rounded`.
17
+ - **Pencil / OpenPencil** → parse the `.pen` JSON; extract token definitions.
18
+
19
+ ## Process
20
+ 1. Read the configured canvas from `.designagent/config.json`.
21
+ 2. Pull tokens from the canvas source.
22
+ 3. **Map to DESIGN.md schema** — preserve existing token names where they match; map canvas naming to role tokens (`primary`, `on-surface`, …). Don't rename tokens that already exist unless the canvas clearly supersedes them.
23
+ 4. **Write the merge** into `DESIGN.md`, keeping markdown prose sections intact.
24
+ 5. **Lint:** `npx @google/design.md lint DESIGN.md` — fix any errors before finishing.
25
+ 6. **Diff:** `npx @google/design.md diff <old> DESIGN.md` to capture token-level changes and regressions.
26
+ 7. **Record:** append a dated entry to `DECISIONS.md` summarizing what changed (added/removed/changed tokens) and why, if known.
27
+
28
+ ## Output contract
29
+ - Updated `DESIGN.md` that lints clean.
30
+ - A diff summary of token changes.
31
+ - A timestamped `DECISIONS.md` entry.
32
+ - Never overwrite prose sections or silently drop tokens — report removals.
@@ -0,0 +1,95 @@
1
+ # {{PROJECT_NAME}} — Design Agent Briefing
2
+
3
+ > Generated by [designagent](https://designagent.dev). This file is Claude Code's design brain for this project.
4
+ > Edit it freely — it is yours now. Re-run `designagent update` to pull in template improvements.
5
+
6
+ ## Project
7
+
8
+ - **Name:** {{PROJECT_NAME}}
9
+ - **Canvas:** {{CANVAS}}
10
+ - **Design system:** {{DESIGN_SYSTEM}}
11
+ - **Framework(s):** {{FRAMEWORKS}}
12
+ - **Tokens:** `DESIGN.md` (machine-readable, linted via `@google/design.md`)
13
+ - **Decisions:** `DECISIONS.md` (the why behind the what)
14
+
15
+ When you start work, read `DESIGN.md` for exact token values and `DECISIONS.md` for prior rationale. Treat both as the source of truth over anything you infer from existing code.
16
+
17
+ ## How to use the three files
18
+
19
+ | File | Question it answers | Authority |
20
+ |---|---|---|
21
+ | `DESIGN.md` | *What* are the exact values? | Tokens — colors, type, spacing, components |
22
+ | `CLAUDE.md` (this file) | *How* do we build? | Craft, conventions, agent behavior |
23
+ | `DECISIONS.md` | *Why* is it this way? | History and rationale |
24
+
25
+ If `DESIGN.md` and code disagree, `DESIGN.md` wins — flag the drift. If a request conflicts with `DECISIONS.md`, surface the prior decision before overriding it.
26
+
27
+ ## Design principles
28
+
29
+ - **Tokens over literals.** Never hardcode a hex value, font size, or spacing number that exists in `DESIGN.md`. Reference the token. If a needed value is missing, add it to `DESIGN.md` first, then use it.
30
+ - **Hierarchy is deliberate.** Size, weight, and color carry meaning. One primary action per view. Secondary actions recede. Don't make everything bold.
31
+ - **Spacing is a system, not a guess.** Use the spacing scale (`xs`…`xxl`). Multiples of the base unit only — no `13px`, no `7px`.
32
+ - **Type scale is closed.** Use the named typography tokens (`headline-*`, `body-*`, `label-*`). Don't invent one-off sizes.
33
+ - **Color carries semantics.** `primary` for primary action, `error` for destructive/error, `on-*` for content that sits on a surface. Never pick a raw color when a role token fits.
34
+ - **Restraint reads as quality.** Fewer borders, fewer shadows, fewer competing accents. Whitespace is a feature.
35
+
36
+ ## Token reference
37
+
38
+ Exact values live in `DESIGN.md`. Resolve token references (e.g. `{colors.primary}`) against that file. To see resolved output for this stack, run:
39
+
40
+ ```
41
+ npx @google/design.md export --format css-tailwind DESIGN.md # Tailwind v4 @theme
42
+ npx @google/design.md export --format dtcg DESIGN.md # W3C Design Tokens
43
+ ```
44
+
45
+ Before relying on `DESIGN.md`, confirm it lints clean:
46
+
47
+ ```
48
+ npx @google/design.md lint DESIGN.md
49
+ ```
50
+
51
+ ## Canvas
52
+
53
+ {{CANVAS_BLOCK}}
54
+
55
+ ## Accessibility
56
+
57
+ - **Contrast:** WCAG AA minimum — 4.5:1 for body text, 3:1 for large text (≥24px or ≥18.66px bold) and meaningful UI/graphics. Verify every `on-*` token against its surface.
58
+ - **Focus:** Every interactive element has a visible, non-color-only focus state.
59
+ - **Targets:** Touch targets ≥44×44pt (iOS) / 48×48dp (Android); ≥24×24px clickable on web with adequate spacing.
60
+ - **Semantics:** Real semantic elements/roles, labels for inputs, alt text for meaningful images, respects reduced-motion.
61
+ - **Don't rely on color alone** to convey state — pair with icon, text, or shape.
62
+
63
+ ## Agent instructions
64
+
65
+ When given a design task:
66
+
67
+ 1. **Read first.** `DESIGN.md` (values) → `DECISIONS.md` (rationale) → the relevant existing component.
68
+ 2. **Reuse before creating.** Search for an existing component/token that fits. Extend it before adding a new one.
69
+ 3. **Work in tokens.** Express every color/space/type choice as a token reference. If you must introduce a value, add the token to `DESIGN.md`, lint, then use it.
70
+ 4. **State your design reasoning briefly** when making a non-obvious choice — then record meaningful decisions in `DECISIONS.md`.
71
+ 5. **Self-review against this file** before declaring done: hierarchy, spacing system, token usage, accessibility, and the "Do not" list below.
72
+ 6. **Lint after touching tokens.** Run `npx @google/design.md lint DESIGN.md` and fix any errors.
73
+
74
+ ## Skills
75
+
76
+ Installed under `~/.designagent/skills/`. Invoke when relevant:
77
+
78
+ - **token-namer** — rename heuristic color tokens (e.g. `accent-4`) to semantic, role-based names. No API key — you do this with your own judgment.
79
+ - **design-to-code** — turn a design intent, screenshot, or canvas node into production code for this project's framework(s), using `DESIGN.md` tokens.
80
+ - **a11y-check** — audit color pairs and touch targets against WCAG AA.
81
+ - **token-sync** — pull tokens from the canvas into `DESIGN.md` and record the diff.
82
+
83
+ ## First run
84
+
85
+ If `DESIGN.md` was reverse-engineered by `designagent init`, its color names may be heuristic (`accent-4`, `neutral-2`). On your first session in this project, run the **token-namer** skill to give them semantic, role-based names — then everything downstream (components, drift suggestions, docs) reads cleanly. This is free: it's your judgment on the session already open, no API key required.
86
+
87
+ ## Do not
88
+
89
+ - Do not hardcode hex colors, rgb/hsl literals, or named CSS colors — use color tokens.
90
+ - Do not use magic spacing numbers — use the spacing scale.
91
+ - Do not invent font sizes — use the typography tokens.
92
+ - Do not add a new component when an existing one can be composed or extended.
93
+ - Do not ship contrast below WCAG AA.
94
+ - Do not edit `DESIGN.md` to a state that fails lint.
95
+ - Do not silently override a recorded decision — reference and update `DECISIONS.md`.
@@ -0,0 +1,21 @@
1
+ ## Jetpack Compose conventions
2
+
3
+ Target: **Jetpack Compose (Android)**. There is no automated Kotlin exporter yet — the `design-to-code` skill reads `DESIGN.md` and generates a `Theme.kt` / `Tokens.kt` (a Material 3 `MaterialTheme` wiring + token objects) plus composables. Keep that as the single bridge between tokens and UI.
4
+
5
+ ### Tokens in Kotlin
6
+ - Map `DESIGN.md` colors into a Material 3 `ColorScheme` (`primary`, `onPrimary`, `surface`, `onSurface`, `error`, …) and read them via `MaterialTheme.colorScheme.*` in composables — never inline `Color(0xFF...)`.
7
+ - Typography → `MaterialTheme.typography.*` built from the `DESIGN.md` type tokens. Spacing → a `Dimens`/`Spacing` object of `Dp` constants. No magic `.dp` literals.
8
+ - Provide light and dark `ColorScheme`s; support dynamic color (Android 12+) only if it doesn't break brand tokens.
9
+
10
+ ### Composables
11
+ - `@Composable` functions are `PascalCase`, UI-only, side-effect-free in the composition path. Hoist state — pass values down, events up.
12
+ - Every composable takes a `modifier: Modifier = Modifier` as its first optional param and applies it to the root. **Modifier order matters** (it's applied outside-in): size/padding → background → clip → clickable → semantics.
13
+ - Prefer **slot APIs** (`content: @Composable () -> Unit`) over many boolean flags for layout flexibility.
14
+
15
+ ### Material 3
16
+ - Use M3 components (`Button`, `Card`, `Scaffold`, `TopAppBar`) and tokens rather than rebuilding them. Follow M3 elevation/state-layer conventions.
17
+ - Touch targets ≥48×48dp. Respect `LocalAccessibilityManager` and reduced-motion preferences.
18
+ - Content descriptions on every meaningful `Icon`/`Image`; decorative ones get `contentDescription = null`.
19
+
20
+ ### Previews
21
+ - `@Preview` for light + dark (`uiMode`) and a font-scale variant for the key composables.
@@ -0,0 +1,9 @@
1
+ ## Cross-platform strategy
2
+
3
+ This project targets multiple frameworks ({{FRAMEWORKS}}). `DESIGN.md` is the **single source of truth** for all of them — one token set, many outputs.
4
+
5
+ - **One token layer.** All targets derive from the same `DESIGN.md`. Web reads exported CSS variables; React Native reads `StyleSheet` constants; SwiftUI/Compose read generated token files. Never let a platform fork its own values.
6
+ - **Shared semantics, platform-idiomatic output.** A token named `primary` stays `primary` everywhere; only its rendered form differs (CSS var vs. `Color.primary` vs. `MaterialTheme.colorScheme.primary`).
7
+ - **Naming parity.** Keep token names identical across platforms so a change in `DESIGN.md` maps 1:1 to every target.
8
+ - **When a value must diverge per platform** (e.g. elevation, motion), record why in `DECISIONS.md` and keep both under the same token name with platform notes.
9
+ - **Regenerate, don't hand-edit** exported/generated token files — change `DESIGN.md` and re-export so platforms never drift.
@@ -0,0 +1,25 @@
1
+ ## React conventions
2
+
3
+ Target: **React** ({{DESIGN_SYSTEM}}). Design tokens reach components as Tailwind v4 CSS variables — generate them with `npx @google/design.md export --format css-tailwind DESIGN.md` into your global stylesheet's `@theme`.
4
+
5
+ ### Components
6
+ - Function components only. Named exports, one component per file, `PascalCase.tsx`.
7
+ - Props are a typed `interface` named `<Component>Props`. No `any`. Prefer discriminated unions over boolean prop soup.
8
+ - Compose, don't configure: small primitives (`Button`, `Card`, `Stack`) combined over one mega-component with 15 props.
9
+ - Co-locate: component, its variants, and its types in one file unless shared.
10
+
11
+ ### Styling
12
+ - Use Tailwind utilities mapped to tokens — `bg-primary`, `text-on-surface`, `rounded-md`, `p-md`. Never arbitrary values (`p-[13px]`, `bg-[#1A1C1E]`) when a token utility exists.
13
+ - Class order: layout → box model → typography → visual → state/variants. Keep it consistent; let Prettier/tailwind plugin sort if present.
14
+ - Conditional classes via `clsx`/`cn` — no string concatenation.
15
+ - No inline `style={{}}` for anything that maps to a token.
16
+
17
+ ### State & data
18
+ - Local state with `useState`/`useReducer`. Lift only when shared. Reach for context/store only when prop-drilling genuinely hurts.
19
+ - Side effects belong in `useEffect`/event handlers, not render. Keep render pure.
20
+ - Derive, don't duplicate: compute from props/state instead of mirroring into more state.
21
+
22
+ ### Accessibility in JSX
23
+ - Semantic elements first (`button`, `a`, `nav`, `label`). Reach for ARIA only to fill gaps.
24
+ - Every input has an associated `label`. Icon-only buttons get `aria-label`.
25
+ - Keyboard: interactive custom elements handle Enter/Space and show a focus ring.
@@ -0,0 +1,22 @@
1
+ ## SwiftUI conventions
2
+
3
+ Target: **SwiftUI (iOS)**. There is no automated Swift exporter yet — the `design-to-code` skill reads `DESIGN.md` and generates a `DesignTokens.swift` (Color/Font extensions) plus view code. Keep that generated file as the single bridge between tokens and views.
4
+
5
+ ### Tokens in Swift
6
+ - Map `DESIGN.md` colors to `Color` extension statics (`Color.primary`, `Color.onSurface`) and typography to `Font` helpers or a `Text` modifier set. Views reference those — never inline `Color(hex:)` or `.font(.system(size: 17))`.
7
+ - Spacing → a `Spacing` enum/struct of `CGFloat` constants from the scale. No magic padding numbers.
8
+ - Asset catalog colors should mirror the token names so Dynamic Color (light/dark) works.
9
+
10
+ ### Views
11
+ - Small composable views; extract subviews once a `body` grows past a screen. Computed `var`s or `@ViewBuilder` funcs for repeated chunks.
12
+ - **Modifier order matters** and is conventional: content → layout (`frame`, `padding`) → background/clip → overlay → accessibility → gesture. Apply `.padding` before `.background` so the background includes the padding.
13
+ - Prefer SF Symbols (`Image(systemName:)`) over bundled icons; size with `.imageScale`/`.font`, never hardcoded frames where a symbol scale fits.
14
+
15
+ ### iOS HIG
16
+ - Respect Dynamic Type: use semantic text styles or scalable fonts; don't pin to fixed point sizes. Test the largest accessibility size.
17
+ - Support light and dark via asset-catalog/semantic colors — no hardcoded light-only hex.
18
+ - Honor safe areas, standard navigation patterns, and `@Environment(\.accessibilityReduceMotion)` for animations.
19
+ - Touch targets ≥44×44pt.
20
+
21
+ ### Previews
22
+ - Every view ships a `#Preview` covering light + dark and at least one large Dynamic Type size.
@@ -0,0 +1,138 @@
1
+ ---
2
+ name: {{PROJECT_NAME}}
3
+ version: alpha
4
+ description: Design tokens for {{PROJECT_NAME}}. Opinionated neutral scaffold — replace every value with your own.
5
+ colors:
6
+ primary: "#111827"
7
+ on-primary: "#FFFFFF"
8
+ secondary: "#374151"
9
+ on-secondary: "#FFFFFF"
10
+ tertiary: "#4B5563"
11
+ on-tertiary: "#FFFFFF"
12
+ neutral: "#6B7280"
13
+ surface: "#FFFFFF"
14
+ on-surface: "#111827"
15
+ error: "#B91C1C"
16
+ on-error: "#FFFFFF"
17
+ outline: "#D1D5DB"
18
+ typography:
19
+ headline-display:
20
+ fontFamily: system-ui
21
+ fontSize: 3rem
22
+ fontWeight: 700
23
+ lineHeight: 1.1
24
+ headline-lg:
25
+ fontFamily: system-ui
26
+ fontSize: 2.25rem
27
+ fontWeight: 700
28
+ lineHeight: 1.15
29
+ headline-md:
30
+ fontFamily: system-ui
31
+ fontSize: 1.5rem
32
+ fontWeight: 600
33
+ lineHeight: 1.25
34
+ body-lg:
35
+ fontFamily: system-ui
36
+ fontSize: 1.125rem
37
+ fontWeight: 400
38
+ lineHeight: 1.6
39
+ body-md:
40
+ fontFamily: system-ui
41
+ fontSize: 1rem
42
+ fontWeight: 400
43
+ lineHeight: 1.6
44
+ body-sm:
45
+ fontFamily: system-ui
46
+ fontSize: 0.875rem
47
+ fontWeight: 400
48
+ lineHeight: 1.5
49
+ label-lg:
50
+ fontFamily: system-ui
51
+ fontSize: 0.875rem
52
+ fontWeight: 500
53
+ lineHeight: 1.4
54
+ label-md:
55
+ fontFamily: system-ui
56
+ fontSize: 0.75rem
57
+ fontWeight: 500
58
+ lineHeight: 1.4
59
+ label-sm:
60
+ fontFamily: system-ui
61
+ fontSize: 0.6875rem
62
+ fontWeight: 500
63
+ lineHeight: 1.3
64
+ spacing:
65
+ xs: 4px
66
+ sm: 8px
67
+ md: 16px
68
+ lg: 24px
69
+ xl: 32px
70
+ xxl: 48px
71
+ rounded:
72
+ none: 0px
73
+ sm: 4px
74
+ md: 8px
75
+ lg: 12px
76
+ xl: 16px
77
+ full: 9999px
78
+ components:
79
+ button-primary:
80
+ backgroundColor: "{colors.primary}"
81
+ textColor: "{colors.on-primary}"
82
+ rounded: "{rounded.md}"
83
+ padding: 12px
84
+ button-secondary:
85
+ backgroundColor: "{colors.secondary}"
86
+ textColor: "{colors.on-secondary}"
87
+ rounded: "{rounded.md}"
88
+ padding: 12px
89
+ card:
90
+ backgroundColor: "{colors.surface}"
91
+ textColor: "{colors.on-surface}"
92
+ rounded: "{rounded.lg}"
93
+ padding: 16px
94
+ input:
95
+ backgroundColor: "{colors.surface}"
96
+ textColor: "{colors.on-surface}"
97
+ rounded: "{rounded.sm}"
98
+ padding: 8px
99
+ ---
100
+
101
+ ## Overview
102
+
103
+ A neutral, opinionated starting point for **{{PROJECT_NAME}}**. Every value here is a placeholder with a sensible default — replace the palette, type, and component tokens with your own, then run:
104
+
105
+ ```
106
+ npx @google/design.md lint DESIGN.md
107
+ ```
108
+
109
+ ## Colors
110
+
111
+ Role-based tokens with `on-*` foregrounds. Start by setting `primary` to your brand color and checking `on-primary` contrast.
112
+
113
+ ## Typography
114
+
115
+ `system-ui` so it renders everywhere with no font loading. Swap in your typeface across the scale when ready.
116
+
117
+ ## Layout
118
+
119
+ 4px-based spacing scale. Keep all spacing on-scale.
120
+
121
+ ## Elevation & Depth
122
+
123
+ Define your shadow language here. Start flat; add elevation only where it communicates layering.
124
+
125
+ ## Shapes
126
+
127
+ Corner radii from `none` to `full`. Pick a default radius for your brand and apply it consistently.
128
+
129
+ ## Components
130
+
131
+ Token-composed primitives to extend. Add components as your system grows — always referencing tokens, never raw values.
132
+
133
+ ## Do's and Don'ts
134
+
135
+ - **Do** replace these defaults with real brand values.
136
+ - **Do** keep contrast at WCAG AA.
137
+ - **Don't** leave placeholder values in production.
138
+ - **Don't** hardcode values that belong in a token.