stitch2 0.0.0-stage → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +208 -2
  3. package/config.schema.json +109 -0
  4. package/dist/assets.d.ts +1 -0
  5. package/dist/assets.js +59 -0
  6. package/dist/audit.d.ts +10 -0
  7. package/dist/audit.js +259 -0
  8. package/dist/build-design.d.ts +39 -0
  9. package/dist/build-design.js +337 -0
  10. package/dist/build-elements.d.ts +1 -0
  11. package/dist/build-elements.js +33 -0
  12. package/dist/canvas.html +689 -0
  13. package/dist/check.d.ts +1 -0
  14. package/dist/check.js +86 -0
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +73 -0
  17. package/dist/colours.d.ts +2 -0
  18. package/dist/colours.js +57 -0
  19. package/dist/compare.d.ts +1 -0
  20. package/dist/compare.js +185 -0
  21. package/dist/config.d.ts +53 -0
  22. package/dist/config.js +38 -0
  23. package/dist/consistency.d.ts +40 -0
  24. package/dist/consistency.js +336 -0
  25. package/dist/design-md.d.ts +27 -0
  26. package/dist/design-md.js +49 -0
  27. package/dist/design-page.d.ts +1 -0
  28. package/dist/design-page.js +127 -0
  29. package/dist/elements.d.ts +32 -0
  30. package/dist/elements.js +69 -0
  31. package/dist/exports.d.ts +25 -0
  32. package/dist/exports.js +86 -0
  33. package/dist/extract.d.ts +1 -0
  34. package/dist/extract.js +197 -0
  35. package/dist/init.d.ts +5 -0
  36. package/dist/init.js +83 -0
  37. package/dist/list.d.ts +1 -0
  38. package/dist/list.js +17 -0
  39. package/dist/pick.d.ts +10 -0
  40. package/dist/pick.js +38 -0
  41. package/dist/report.d.ts +1 -0
  42. package/dist/report.js +110 -0
  43. package/dist/sandbox.d.ts +1 -0
  44. package/dist/sandbox.js +183 -0
  45. package/dist/screens.d.ts +34 -0
  46. package/dist/screens.js +85 -0
  47. package/dist/serve.d.ts +4 -0
  48. package/dist/serve.js +181 -0
  49. package/dist/setup.d.ts +1 -0
  50. package/dist/setup.js +214 -0
  51. package/dist/tokens.d.ts +1 -0
  52. package/dist/tokens.js +128 -0
  53. package/dist/type.d.ts +1 -0
  54. package/dist/type.js +60 -0
  55. package/dist/typecheck.d.ts +35 -0
  56. package/dist/typecheck.js +112 -0
  57. package/package.json +53 -4
  58. package/skills/stitch2/SKILL.md +80 -0
  59. package/skills/stitch2/references/components.md +59 -0
  60. package/skills/stitch2/references/guides.md +20 -0
  61. package/skills/stitch2/references/principles.md +80 -0
  62. package/skills/stitch2/references/screens.md +70 -0
  63. package/skills/stitch2/references/typography.md +106 -0
  64. package/skills/stitch2-app-sync/SKILL.md +65 -0
  65. package/skills/stitch2-consistency/SKILL.md +59 -0
  66. package/skills/stitch2-design-md/SKILL.md +64 -0
  67. package/skills/stitch2-import-from-google-stitch/SKILL.md +47 -0
  68. package/skills/stitch2-import-from-google-stitch/references/how-stitch-works.md +36 -0
  69. package/skills/stitch2-variants/SKILL.md +45 -0
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: stitch2
3
+ description: Design app screens as HTML with the stitch2 design lab — a canvas, layout and type checks, shared components, screen versions and the user's approval — on a project's DESIGN.md. Use when drafting or redesigning a screen or flow, fixing what the checks flag, comparing variants, or running a blind design trial.
4
+ ---
5
+
6
+ # Designing screens with stitch2
7
+
8
+ stitch2 is a design lab for agents. A screen is one HTML file (Tailwind from a CDN, the project's generated
9
+ tokens, an icon set) at phone or desktop width. stitch2 renders it in Chromium, checks it, and shows every screen
10
+ version on a canvas where the user approves, archives or comments on each one. The design system is the
11
+ project's `DESIGN.md` in Google's DESIGN.md format: tokens in the YAML front matter, rules in the prose.
12
+
13
+ The project tunes all of this in `stitch2.config.json` (folders, the prefix of its meta tags, components and
14
+ CSS variables, screen order) and in a **project skill** with its specifics: brand, components, screen names,
15
+ data. Read the project skill first when there is one; it wins over this one where they differ.
16
+
17
+ A project without stitch2 yet: ask the user for the product name, brand colour and modes, then run
18
+ `stitch2 setup --name "…" --primary "#…" --modes …` (config, DESIGN.md and tokens, template, catalog, starter
19
+ components, and these skills linked). No DESIGN.md yet, or a new look: build it first with the
20
+ **stitch2-design-md** skill (`stitch2 init` or `stitch2 extract`).
21
+
22
+ References, read before the first screen:
23
+
24
+ - [principles.md](references/principles.md): what makes a screen read well, and the review rubric.
25
+ - [typography.md](references/typography.md): type levels and how to combine them; most polish is here.
26
+ - [components.md](references/components.md): build from the shared components; the reuse ladder.
27
+ - [screens.md](references/screens.md): screen names, versions, statuses, the user's approval and notes, desktop.
28
+ - [guides.md](references/guides.md): the public sources behind the rules.
29
+
30
+ ## Workflow
31
+
32
+ 1. **Read** the brief, DESIGN.md, the references, the project skill and the component catalog (on the canvas,
33
+ or its render under `<design>/renders/`). Run `stitch2 screens`: approved versions are the reference, notes
34
+ are the user's feedback. A systemic change (a colour, a type level, a component) goes into DESIGN.md first,
35
+ then `stitch2 lint` and `stitch2 tokens`.
36
+ 2. **Inventory.** List every element the brief names, in order, with its real data. That list is the screen:
37
+ add nothing (status bars, step labels, tips, helper text, extra buttons), drop nothing. Next to each element
38
+ write the catalog component that shows it; adapt or extend components rather than inventing markup.
39
+ 3. **Hierarchy before markup.** Name the one thing the user came for, the single primary action (the only
40
+ accent-filled element in its region), and what is secondary. Give every text element a type level and a
41
+ colour before writing markup.
42
+ 4. **Build** the next version, `<screens>/<screen>/<device>-v<N>.html`, from the project's template (status
43
+ `draft`; never edit an approved version). Assemble it from the components; plain markup only where none
44
+ applies, with token classes, `.type-<level>` classes for text, the spacing scale, and the states DESIGN.md
45
+ defines. Never add classes to a component to change how it looks, and never write a colour value (hex,
46
+ `rgb()`, `hsl()`): only DESIGN.md's colours, as token classes or `var(--<prefix>-<name>)`.
47
+ 5. **Check** `stitch2 check <path> --shots --strict`. Fix every error (overflow, wrapped labels, content under
48
+ fixed bars, fixed bars overlapping each other, tap targets, contrast, cramped text) and every warning about type (`type-*`), hand-built
49
+ components (`reuse`), components that differ from the catalog (`consistency`) and colour values (`color`).
50
+ 6. **Look and critique.** View the render in `<design>/renders/` (crop the first screenful). Score it with the
51
+ rubric in principles.md, fix what fails, repeat 5–6 at most three times.
52
+ 7. **Hand over.** Set the version's status to `review`, point the user to it on the canvas, and report what
53
+ changed, how you answered their notes, and any rubric item you could not satisfy. The user approves.
54
+
55
+ ## Commands
56
+
57
+ `stitch2 <command>` from the project (through its package manager when stitch2 is a dev dependency):
58
+
59
+ | Command | What it does |
60
+ |---|---|
61
+ | `setup [--name N --primary #hex] [options]` | Sets a project up in one step; keeps every file that exists |
62
+ | `canvas` | The canvas at http://localhost:4400: screens and versions, DESIGN.md, the consistency report, approval and notes |
63
+ | `check [filter] [--shots] [--strict]` | Layout, type, reuse and consistency checks; `--shots` saves renders |
64
+ | `consistency [kind…]` | Every shared component cropped from every screen, next to the catalog's version |
65
+ | `type [filter] [--json]` | Every text style a screen uses and the type level it matches |
66
+ | `screens [name] [--status s] [--json]` | Every version with its status and the user's note |
67
+ | `compare [screen…]` | The live app against the approved versions: missing or extra components, order, looks; a side-by-side report |
68
+ | `elements <entry>` | Bundles the app's components, turned into elements with `stitch2/elements`, for the screens |
69
+ | `tokens` | `tokens.css` (colours, `.type-*` classes) and `tailwind.tokens.js` from DESIGN.md |
70
+ | `lint` | Google's DESIGN.md linter |
71
+ | `localize [filter]` | Copies remote images a screen uses into its `assets/` folder |
72
+ | `init`, `extract` | Build DESIGN.md from choices, or measure it from an existing site (stitch2-design-md) |
73
+ | `sandbox create <dir> <brief.md>…`, `sandbox import <dir>` | Fresh-eyes versions from agents that see no other versions (stitch2-variants) |
74
+
75
+ ## Alternatives and fresh eyes
76
+
77
+ When the user wants options or a new direction, or a design is stuck, do not iterate on the existing versions:
78
+ use the **stitch2-variants** skill. Fresh agents in sandboxes design from the brief without seeing the other
79
+ versions, and their screens come back as new versions to compare on the canvas. The same skill tests changes to
80
+ the skills or DESIGN.md.
@@ -0,0 +1,59 @@
1
+ # Components: reuse before you create
2
+
3
+ Screens are assembled from the project's shared components: light-DOM custom elements named
4
+ `<prefix>-<name>` (the prefix from `stitch2.config.json`), each rendering the same markup with the type levels
5
+ and every state, and marking itself `data-<prefix>="<name>"`. The **component catalog** (a screen in the
6
+ config's `catalogDir`, first on the canvas) shows every component with its variants, and it is the reference
7
+ `check` and `stitch2 consistency` compare every screen with. The project skill lists its components.
8
+
9
+ Two screens that both show a tab bar, a header, a list or a button must show the same one: same size, type,
10
+ colour, icons and states. Users learn an element once; every variant costs attention and looks like a mistake.
11
+
12
+ ## The ladder
13
+
14
+ Go down only when the step above cannot work:
15
+
16
+ 1. **Use** a component as it is.
17
+ 2. **Use a variant** it already has (variant, size, selected, state…).
18
+ 3. **Adapt the content** to the component: a shorter label, an icon it supports, two rows instead of a custom
19
+ grid. A brief describes what to show, not which markup to invent.
20
+ 4. **Extend the component**: add the attribute or variant to the component, show it in the catalog, describe it
21
+ in DESIGN.md if it is a new look. Every screen gets it, and the change is reviewed once.
22
+ 5. **Create a component** only when nothing fits and the element appears on more than one screen; give it a
23
+ name, add it to the catalog and the project skill. A one-screen element may stay plain markup.
24
+
25
+ Never restyle a component on one screen, copy its markup by hand, or build a near-twin ("a chip, but 30 px").
26
+
27
+ ## Components from the app
28
+
29
+ When the project builds its elements from the app's own components (`stitch2/elements›, bundled with
30
+ `stitch2 elements <entry>›), the catalog and every screen show exactly what the app renders. Then a change to
31
+ a component is a change to the app's component: edit it there, rebuild the bundle, and look at the catalog;
32
+ never patch the bundle or restyle the element on a screen. Props are the element's attributes (kebab-case,
33
+ an empty attribute is true) and its content is children. A component the screens need but the app lacks is
34
+ added to the app first, with the same name.
35
+
36
+ ## Colours come from DESIGN.md
37
+
38
+ Every colour on a screen and in a component is one of DESIGN.md's: a token class (`bg-surface`,
39
+ `text-muted`, …) or `var(--<prefix>-<name>)`, and for a shade a mix of those
40
+ (`color-mix(in srgb, var(--<prefix>-accent) 30%, transparent)`). Then a colour changed in DESIGN.md and
41
+ `stitch2 tokens` changes every screen at once. A colour DESIGN.md lacks (an illustration's backdrop, a chart
42
+ series) is added to DESIGN.md first, with a line in the prose saying where it is used.
43
+
44
+ ## What the checks report
45
+
46
+ - **reuse**: on a lab screen, an element that looks like a catalog component but was built by hand (a bottom
47
+ bar with three or more buttons, an h1, a primary-filled button, a pill chip, a header icon button, a caps
48
+ label).
49
+ - **consistency**: a component whose size, radius, font, icon set or icons differ from the catalog's version
50
+ (or, without a catalog, from the majority of screens in its family), or that appears in two versions on one
51
+ screen. `stitch2 consistency` shows the same as cropped images; see the stitch2-consistency skill.
52
+ - **color**: a hex, `rgb()` or `hsl()` value in a lab screen's markup, or (reported on the catalog) in the
53
+ component scripts it loads, with the file and line.
54
+
55
+ ## Generated drafts
56
+
57
+ Generators such as Google Stitch produce each screen on its own and cannot share components, so their chrome
58
+ drifts from screen to screen. Treat generated screens as drafts of layout and content; the catalog decides how
59
+ shared components look. When a draft has a better element, adopt it by changing the component (step 4).
@@ -0,0 +1,20 @@
1
+ # Guides worth reading
2
+
3
+ The skill works from principles.md and DESIGN.md; these are the sources behind them. Fetch the free ones when
4
+ a question goes deeper than the principles (a component's anatomy, a platform convention, an accessibility
5
+ rule). Paid books are listed for the humans on the team; an agent cannot read them, which is why their ideas
6
+ are restated in principles.md.
7
+
8
+ | Source | Free | Use it for |
9
+ |---|---|---|
10
+ | Material 3 (m3.material.io) | yes | Component anatomy and states, colour roles (stitch2 generates them as `md-*` tokens), type scale, motion durations |
11
+ | Apple Human Interface Guidelines (developer.apple.com/design/human-interface-guidelines) | yes | iOS conventions, sheets, tab bars, watchOS |
12
+ | WCAG 2.2 (w3.org/TR/WCAG22) | yes | Contrast (1.4.3), target size (2.5.8), focus, motion |
13
+ | Laws of UX (lawsofux.com) | yes | Fitts, Hick, Jakob, proximity and similarity, with short explanations |
14
+ | Refactoring UI, Adam Wathan & Steve Schoger (refactoringui.com) | no | The most practical book on hierarchy, spacing, colour and depth; principles.md restates its main ideas |
15
+ | Google's material-color-utilities (github.com/material-foundation/material-color-utilities) | yes | Generating tonal palettes and roles from a seed (`tokens` uses it) |
16
+ | DESIGN.md format (github.com/google-labs-code/design.md, npm `@google/design.md`) | yes | The file format of DESIGN.md (the one Stitch reads and writes); `stitch2 lint` runs its linter, and `design.md export css-tailwind` emits Tailwind v4 `@theme` for the app |
17
+ | Stitch skills (github.com/google-labs-code/stitch-skills) | yes | How Google prompts Stitch: content and structure in prompts, all style in the design system |
18
+ | Vercel Geist typography (vercel.com/geist/typography) | yes | The type scale made for Geist by its authors: sizes, line heights and the tracking that suits it (and fonts like it) |
19
+ | Apple HIG, Typography (developer.apple.com/design/human-interface-guidelines/typography) | yes | iOS Dynamic Type sizes, the SF Pro tracking table, minimum sizes (11pt), watchOS sizes |
20
+ | Material 3 type scale (m3.material.io/styles/typography/type-scale-tokens) | yes | Role names (display, headline, title, body, label) and how labels open up at small sizes |
@@ -0,0 +1,80 @@
1
+ # Principles for screens that read well
2
+
3
+ In our own words; the ideas are common practice in interface design, drawn from Refactoring UI (Wathan &
4
+ Schoger), Material 3, Apple's Human Interface Guidelines, WCAG 2.2 and the Laws of UX (see
5
+ [guides.md](guides.md)); no text is copied from them. Items marked **(check)** are measured by `stitch2 check`;
6
+ the rest are judged from the render. Colour names below are roles: the project's DESIGN.md names the actual
7
+ colours (its accent, its primary and secondary text, its surface steps).
8
+
9
+ ## Hierarchy
10
+
11
+ - Decide what matters before styling. Each screen has one focal point and one primary action; everything else
12
+ steps back.
13
+ - Emphasise by de-emphasising: make secondary text the secondary colour and a lighter weight rather than making
14
+ the important thing bigger and louder. At most three text styles per region.
15
+ - Weight and colour carry hierarchy better than size. A semibold primary-colour label over a smaller
16
+ secondary-colour line reads as a pair; two sizes of the same colour do not.
17
+ - Labels are the last resort. A value needs no "Weight:" in front when its card is titled "Body weight"; when a
18
+ label is needed it is the quiet part and the value is the loud part.
19
+ - Buttons follow the action's importance, not its existence: one filled primary, secondary on a surface step,
20
+ rare or destructive actions as text or icon buttons.
21
+
22
+ ## Layout and spacing
23
+
24
+ - Start with too much space and remove it. Crowded is the common failure.
25
+ - Use the spacing scale from DESIGN.md; never a value between two steps.
26
+ - Spacing shows grouping: the gap inside a group is smaller than the gap between groups. Ambiguous spacing is
27
+ a bug.
28
+ - Align to a few vertical lines: the page edge, the card's inner edge, one column for numbers. Numbers in lists
29
+ are right-aligned so their digits line up.
30
+ - Fewer borders. Separate with spacing or a surface step first, a hairline second, never a card inside a card.
31
+ - Do not fill the width because it is there; prose reads best at about 60 characters a line.
32
+
33
+ ## Type
34
+
35
+ The full guide is [typography.md](typography.md). In short: every text element is one of DESIGN.md's type
36
+ levels **(check)**; hierarchy by weight and colour first; tabular figures on numbers, and large numbers in a
37
+ proportional font **(check)**; tracking follows size **(check: capitals)**; wrapped text has room **(check)**;
38
+ short labels never wrap **(check)**.
39
+
40
+ ## Colour and depth
41
+
42
+ - One accent with one meaning ("act here"). Two accent-filled elements in one region: one of them is wrong.
43
+ - Greys carry the structure: a few surface steps and two text colours do almost all the work.
44
+ - Status colours appear as small text, icons or thin bars, never as large fills.
45
+ - Text contrast at least 4.5:1, 3:1 for large text **(check)**. Secondary text on raised surfaces is where this
46
+ fails.
47
+ - Depth from surface steps, not shadows; an overlay (sheet, docked bar) may use one soft shadow.
48
+
49
+ ## Data and content
50
+
51
+ - Real-looking data with irregular numbers. No round placeholders, no "Lorem", no John Doe.
52
+ - Show only what the brief describes. Every invented chip, tip, badge, statistic or helper line is a defect.
53
+ - Labels that make the described data readable belong in the screen even when the brief does not list them:
54
+ axis or month labels, a legend for a colour scale, captions under figures. They add no new facts.
55
+ - Icons that stand for different things look different; one generic glyph repeated down a list says nothing.
56
+ - Charts: one series in the accent, thin lines, few gridlines; label a single line directly instead of a legend.
57
+ - Empty and loading states are designed too: one sentence and one action; skeletons the size of the content.
58
+
59
+ ## Touch and mobile
60
+
61
+ - Tap targets at least 44 px for buttons; smaller ones only with spacing **(check)**.
62
+ - The primary action sits in the thumb zone (lower half or a docked bar); destructive actions far from it.
63
+ - Fixed bars never cover content: the scroll ends with enough bottom padding **(check)**.
64
+ - Nothing wider than the frame; only chip rows and tab strips scroll sideways **(check)**.
65
+
66
+ ## Review rubric (step 6)
67
+
68
+ Score each pass or fail from the render; done when all pass or the failures are explained.
69
+
70
+ 1. **Focal point:** squinting, the eye lands on the thing the user came for.
71
+ 2. **One primary:** exactly one accent-filled element per region.
72
+ 3. **Inventory:** everything the brief names is there, nothing it does not name was added, every chart or scale
73
+ carries the labels needed to read it.
74
+ 4. **Grouping:** spacing alone shows what belongs together.
75
+ 5. **Alignment:** text starts on a few shared vertical lines; numbers line up.
76
+ 6. **Type discipline:** every style is a type level (no `type-*` warnings); at most three per region.
77
+ 7. **Calm structure:** no card in a card, no redundant borders, no decoration without information.
78
+ 8. **Data realism:** names, numbers and dates look like a real person's data.
79
+ 9. **Consistency:** built from the catalog components; no `reuse` or `consistency` warnings.
80
+ 10. **Checks:** `stitch2 check --strict` reports no errors.
@@ -0,0 +1,70 @@
1
+ # Screens, versions and approval
2
+
3
+ The canvas and the agents share one model: an app **screen** (home, settings, …) has **versions**, each for a
4
+ **device** (mobile or desktop), and each version has a **status**. The user decides; agents read the decision
5
+ and build on it. Meta tag names below use the project's prefix (`<p>`, from `stitch2.config.json`).
6
+
7
+ ## Names and files
8
+
9
+ - Screen names are lowercase with hyphens and name what the user sees; one per step of a flow
10
+ (`checkout-1`, `checkout-2`). Reuse existing names (`stitch2 screens` lists them).
11
+ - A version is one file, `<screens dir>/<screen>/<device>-v<N>.html`, N the next free number for that device.
12
+ Its head carries `<p>-screen`, `<p>-device` (mobile | desktop), `<p>-status`, `<p>-source` (stitch | lab),
13
+ `<p>-frame-width` (390 mobile, 1280 desktop) and, written by the user, `<p>-note`. Older files elsewhere
14
+ carry the same tags.
15
+
16
+ ## New version or edit?
17
+
18
+ - **New version** for every new attempt: a new direction, a regeneration, an export from a generator, a
19
+ redesign after feedback on an approved screen. It starts as `draft` and ends as `review`.
20
+ - **Edit in place** only to finish your own draft, or to answer a note on a version still in `review` or
21
+ `draft`.
22
+ - **Never edit** an `approved` or `archived` version: copy it to the next number and change the copy.
23
+
24
+ ## Statuses
25
+
26
+ | Status | Meaning | Who sets it |
27
+ |---|---|---|
28
+ | `draft` | Work in progress | The agent, while working |
29
+ | `review` | Finished, waiting for the user ("Needs review") | The agent, when done |
30
+ | `approved` | The reference: build on it, match it, implement it | The user only |
31
+ | `archived` | History: superseded or rejected; hidden on the canvas | The user; approving a version archives the previously approved one |
32
+
33
+ ## How to use them
34
+
35
+ 1. Before designing, run `stitch2 screens` (a name or `--status approved` narrows it) and open the approved
36
+ versions of the screens next to yours.
37
+ 2. A note is the user's feedback: address every point in your next version or edit, and say how.
38
+ 3. Never set `approved` yourself; never build on an archived version unless asked.
39
+ 4. Only approved versions get implemented in the product.
40
+ 5. When the user pastes a reference copied from the canvas, such as `home mobile v2
41
+ (design/screens/home/mobile-v2.html)`, open that file: it names exactly the version they mean.
42
+ 6. A reference to an element adds its source line, its tag and its text: `home mobile v1
43
+ (design/screens/home/mobile-v1.html:36) <gg-button> “Start Push”`. The element is the one with that tag
44
+ starting on that line (the text tells apart two on one line); a component's tag stands for everything it
45
+ renders. Change that element, or the component itself when the change belongs on every screen. Several
46
+ references in one message are numbered in the order the user picked them.
47
+
48
+ ## Implementing an approved version
49
+
50
+ Build the screen in the app from the same components the screens use, in the version's order, with the app's
51
+ own data, strings and behaviour; keep the app's tests passing. Then run `stitch2 compare <screen>` with the app
52
+ running: fix every `missing` component and look at the side-by-side report. `extra` and `order` warnings are
53
+ fine when the app needs them (a desktop-only control, a frame drawn by layout); say so when you hand over. When
54
+ the page needs a state first (an open sheet, a running workout), add a `prepare` module for its route.
55
+
56
+ ## Desktop
57
+
58
+ Desktop is a device of the same screen, designed after the mobile version is approved: `desktop-v<N>.html`,
59
+ frame width 1280, the same components and type levels, the layout from DESIGN.md (typically a sidebar instead
60
+ of a tab bar, a content max width, two columns where it helps). Shared components get their desktop form in the
61
+ component, before the first desktop screen.
62
+
63
+ ## The canvas
64
+
65
+ `stitch2 canvas` → http://localhost:4400. The sidebar lists DESIGN.md (drawn as tokens and rules), the
66
+ consistency report, the component catalog and every screen with its versions; filters for active, approved,
67
+ needs review or all, and mobile or desktop. Selecting a version opens the inspector: status, note, checks, and
68
+ Copy for its reference. Pick mode (`p`) highlights the element under the pointer; a click copies its reference,
69
+ Shift-click collects several (Copy all, Add to note). Keys: `/` search, `j`/`k` next and previous, `a` approve,
70
+ `p` pick, `f` fit, `0` actual size, double-click to use a frame, `Esc` to leave.
@@ -0,0 +1,106 @@
1
+ # Typography for app screens
2
+
3
+ Most of what makes a dense app screen look finished is type: a small set of text styles used the same way
4
+ everywhere, hierarchy carried by weight and colour, tracking that follows size, quiet secondary text. The
5
+ project's DESIGN.md defines the levels (front matter `typography`); `stitch2 tokens` turns each into a
6
+ `.type-<level>` class, `stitch2 check` warns about text that is not one of them, and `stitch2 type` lists every
7
+ style a screen uses.
8
+
9
+ ## 1. A type scale is a short list of levels
10
+
11
+ Google's DESIGN.md format suggests 9–15 levels, each fixing family, size, line height, weight and tracking
12
+ together. A typical app set (sizes for a 390 px phone):
13
+
14
+ | Role | Typical size / line | Weight | Tracking |
15
+ |---|---|---|---|
16
+ | Display (a timer, a hero number) | 40–56 / 1.0–1.1 | 600 | −0.04em |
17
+ | Screen title | 28 / 34 | 600 | −0.03em |
18
+ | Sheet or dialog title | 22 / 28 | 600 | −0.02em |
19
+ | Card title | 18 / 24 | 600 | −0.02em |
20
+ | Body | 15–16 / 22–24 | 400 | 0 |
21
+ | Body strong (list names) | 15 / 20 | 500 | 0 |
22
+ | Button label | 15 / 20 | 600 | 0 |
23
+ | Meta (secondary lines) | 13 / 18 | 400 | 0 |
24
+ | Chip or tab label | 13 / 16 | 500 | 0 |
25
+ | Caps label (sections) | 12 / 16 | 600 | +0.06em, uppercase |
26
+ | Caption (units, axes) | 12 / 16 | 400 | +0.01em |
27
+ | Tab bar label | 11 / 14 | 500 | +0.02em |
28
+
29
+ - One `.type-<level>` class per text element plus a colour class. No size, weight, tracking or line-height
30
+ utilities on text: that is how screens drift into twenty slightly different styles.
31
+ - Add a level only when a real use appears on two screens and nothing fits. Never solve a one-off with an
32
+ in-between size.
33
+
34
+ ## 2. Hierarchy recipes
35
+
36
+ | Element | Recipe |
37
+ |---|---|
38
+ | Screen header | meta line in the secondary colour above the screen title |
39
+ | Section | caps label, 8 px above its block |
40
+ | Card header | data cards: a caps label; cards whose title is the content: a card title |
41
+ | List row | body-strong name over a meta line; a trailing value as meta, or body-strong when it matters |
42
+ | Stat | caps label, a large value with its unit at about half its size in the secondary colour, a meta note |
43
+ | Controls | button label on buttons, chip label on chips and segments, tab label in the tab bar |
44
+
45
+ At most three levels and two text colours per region. Most of a screen is 13–15 px; one or two things are big.
46
+ To make something stand out inside a row, change its weight or colour, not its size.
47
+
48
+ ## 3. Text colour
49
+
50
+ - Primary text for what the user reads first or acts on; secondary for everything else; a third, faint grey
51
+ only for disabled text and separators (it usually fails 4.5:1, so it never carries information).
52
+ - Accent-coloured text means "active" or "act here". Check its contrast on every surface it sits on: accent text
53
+ on a tinted accent background over a raised surface is a common failure.
54
+ - Status colours colour short values and words, never sentences.
55
+
56
+ ## 4. Numbers
57
+
58
+ - Tabular figures for every number, so columns line up and timers do not jitter.
59
+ - Large values in a proportional font with tabular figures: monospace fonts give the decimal point, comma and
60
+ colon a full-width cell ("80 . 7"); `check` warns about large monospace numbers. Monospace, if the brand uses
61
+ it, is for small standalone metadata, never mid-sentence.
62
+ - Units follow their value at about half its size in the secondary colour.
63
+ - Real typography: minus "−" for negatives, "×" for multiplication, en dash for ranges, "·" between facts.
64
+ - Locales write numbers differently ("82,5"): leave room and never hard-code the decimal point.
65
+
66
+ ## 5. Tracking and line height
67
+
68
+ - Tracking follows size: tight for titles (tighter the bigger), zero for reading sizes, open for small text and
69
+ capitals. For fonts without optical sizes (Geist, Inter and most web fonts) the font's own scale is the best
70
+ guide; Apple's SF Pro table follows the same curve below 24 pt.
71
+ - Line height comes with the level. Wrapped text needs at least 1.3× its size; `check` reports wrapped text under
72
+ 1.15× as an error. A line height equal to the size is only for single-line display numbers.
73
+ - Titles, labels and metadata stay on one line: truncate with an ellipsis rather than wrap.
74
+
75
+ ## 6. Capitals
76
+
77
+ Only the caps-label level: one to three words, never buttons, titles or sentences. Chinese, Korean, Thai, Hindi
78
+ and Arabic have no capitals; `tokens.css` removes the uppercase and tracking for those languages.
79
+
80
+ ## 7. Text in each state
81
+
82
+ | State | Text |
83
+ |---|---|
84
+ | Hover (pointer only) | secondary → primary colour |
85
+ | Pressed | unchanged; the surface darkens and moves 1 px |
86
+ | Focus | unchanged; a visible ring around the control |
87
+ | Selected | the accent (chips, tabs) or primary text on a raised surface (segments) |
88
+ | Disabled | the faint colour, with the reason nearby when it is not obvious |
89
+ | Error | one meta line in the danger colour under the field, saying how to fix it |
90
+ | Placeholder | secondary colour, an example of the input, not an instruction |
91
+ | Loading | skeleton bars the height of the level's line |
92
+
93
+ ## 8. Length and languages
94
+
95
+ Translations run up to 30% longer (German, Russian, Polish, Hungarian): every label has room or truncates.
96
+ Right-to-left scripts align to start and end, never left and right, and are never letter-spaced (it breaks
97
+ Arabic joining). Thai and Hindi need line height of at least 1.5. Latin web fonts lack Arabic, CJK, Thai and
98
+ Devanagari; `tokens.css` falls back to Noto and system fonts.
99
+
100
+ ## 9. Type review
101
+
102
+ 1. `check` shows no `type-*` warnings.
103
+ 2. Squint: the title and the screen's main number are the only big things.
104
+ 3. Secondary text differs by colour and weight, not just size.
105
+ 4. Numbers are tabular; large ones proportional; units smaller and secondary.
106
+ 5. At most three levels per region; capitals only in section labels; nothing wraps that should not.
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: stitch2-app-sync
3
+ description: Keep the live app and the approved designs in step when both are built from the same components. Use when changing a shared component the app uses, building or fixing an app screen from an approved design, adding a state or control the app needs (a paused timer, an error, an empty list), or when stitch2 compare reports missing components or layout errors in the app.
4
+ ---
5
+
6
+ # Keeping the app and the designs in step
7
+
8
+ The screens on the canvas and the app use **the same components** (one definition each, rendered by both). The
9
+ canvas is where a component's look is decided and checked; the app wires the component to real data. Drift starts
10
+ when the app draws something the canvas never showed: a control added only in the app, a state no screen has,
11
+ a component rebuilt by hand. The checks can only judge what the canvas draws, so those slip through.
12
+
13
+ ## The direction of change
14
+
15
+ **Design first, then the app.** A visible change to a shared component goes:
16
+
17
+ 1. **Component**: change it (or add the variant) in the component library, never in the app's copy of a screen.
18
+ 2. **Canvas**: rebuild the elements bundle, show the change on the screens that use it (a new version of each
19
+ approved screen if the change is visible there; a catalog entry for a new variant or state), and run
20
+ `stitch2 check <screens> --strict`. Look at the screens yourself: the check finds overlaps and overflow, not
21
+ ugliness.
22
+ 3. **Approval**: the user approves the new versions (or the catalog change) as for any design.
23
+ 4. **App**: the app picks the component up; wire it, then run `stitch2 compare <screen>`.
24
+
25
+ Fixing a bug found in the app follows the same path: reproduce it on the canvas (a screen or catalog state that
26
+ shows it), fix the component, check, then the app. If the canvas cannot show the bug, the canvas is missing a
27
+ state: add it.
28
+
29
+ ## What the app may and may not add
30
+
31
+ | The app needs | Do |
32
+ |---|---|
33
+ | Real data, handlers, routing, test ids | Props on the component (`onClick`, `onSelect`, `testId`); no change in look |
34
+ | Its own control where the screen shows a value (an input where the design shows a number) | A slot that keeps the component's look: same size, type and colour as the value it replaces |
35
+ | A new visible part (a pause button, a badge, a second line) | Add it to the component with its own props, and show it on a screen first. Never through a generic "extra" slot |
36
+ | A state the screens do not have (loading, empty, error, paused, ready) | A screen version or catalog entry for that state first |
37
+ | A whole new screen or sheet | Design it on the canvas first; until then it is unfinished, and the user should know |
38
+
39
+ Slots are for wiring. If what goes into a slot changes how the component looks, it belongs in the component.
40
+
41
+ ## Checks that keep them honest
42
+
43
+ - `stitch2 check` (screens): overflow, labels that wrap, content under fixed bars, fixed bars overlapping each
44
+ other, **controls overlapping each other**, small tap targets, contrast, type levels, reuse and consistency.
45
+ - `stitch2 compare` (the live app, against every approved version with a route): which components appear, in
46
+ what order, how the measured ones look, **and the same layout errors as check** (overflow, fixed-overlap,
47
+ control-overlap), so a control squeezed in the app shows up even when no screen drew it.
48
+ - Give every approved screen a route, and every state a `prepare` module that puts the app into it (a sheet
49
+ open, a timer running, a form half filled). An unrouted screen is not compared at all.
50
+
51
+ Read the findings as:
52
+
53
+ | Finding | Meaning | Fix |
54
+ |---|---|---|
55
+ | `missing` in compare | The app does not use a component the design shows | Build that part from the component; if the data is missing, fix the `prepare` |
56
+ | `extra` in compare | The app shows a component the design does not | Fine if it is a kept feature the design leaves out; otherwise design it first |
57
+ | `control-overlap` / `overflow` in compare only | The app draws a state or control the canvas never showed | Show it on the canvas, fix the component there, then re-run both |
58
+ | `look` differences | The component is styled differently in the app | The app is overriding the component: remove the override, or change the component |
59
+
60
+ ## Before you call it done
61
+
62
+ 1. `stitch2 check --strict` passes on the screens you touched (archived screens excepted).
63
+ 2. `stitch2 compare` has no errors for the screens you touched; warnings are explained (a kept feature) or fixed.
64
+ 3. The user has seen the canvas versions of anything that changed how a component looks.
65
+
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: stitch2-consistency
3
+ description: Verify that shared elements (tab bar, header, buttons, chips, icon buttons, section labels, rows…) look the same on every screen, and fix drift the right way. Use when screens look inconsistent, after generating or importing screens (Stitch exports, a new flow), before asking the user to approve, or when check reports reuse or consistency warnings.
4
+ ---
5
+
6
+ # Verifying design consistency with stitch2
7
+
8
+ A shared element must be the same everywhere: same size, radius, type, colour, icon set, icons and states.
9
+ stitch2 measures this; your job is to read the evidence, decide what is wrong, and fix it at the source. The
10
+ reference is the **component catalog** (the screen in the config's `catalogDir`); without a catalog, the
11
+ majority of screens in the same family.
12
+
13
+ ## 1. Measure
14
+
15
+ 1. `stitch2 check` over **all** screens (no filter), so every screen's components are known; later filtered runs
16
+ compare with them.
17
+ 2. `stitch2 consistency` (or `stitch2 consistency tab-bar header` for some kinds): crops every shared component
18
+ from every active screen into one page, next to the catalog's version, with what differs. Open it from the
19
+ canvas sidebar (Consistency report) or view the crops under `<design>/consistency/<kind>/`.
20
+ 3. Read the warnings, per screen (`<design>/checks.json`, or the canvas inspector):
21
+ - `consistency`: "Tab bar differs from the component catalog: label 13/500 (catalog 11/500); iconSet
22
+ material-symbols (catalog lucide); icons home,… (catalog house,…)". Every field is a fact:
23
+ `height`/`width`/`radius` in px, `font` and `label` as size/weight/family/tracking, `icon` size,
24
+ `iconSet` and `icons` (the glyph names), and for a tab bar its centre `circle` and `lift`.
25
+ Measured are the tab bar, header, section label, card, buttons, icon buttons and chips; every other
26
+ component takes its size from its content, so compare those by eye in the report.
27
+ - `… different versions … on this screen`: the same component styled two ways on one screen.
28
+ - `reuse`: a lab screen built a catalog component by hand instead of using it.
29
+ 4. Look at the crops yourself. Numbers say what differs; the images say whether it matters. A 1 px height
30
+ difference from a border is noise; another icon set, label size or button shape is not.
31
+
32
+ ## 2. Decide, per difference
33
+
34
+ | What you see | Fix |
35
+ |---|---|
36
+ | A lab screen rebuilt a component by hand (`reuse`) | Replace the markup with the component, in a new version if the screen is approved |
37
+ | A lab screen restyled a component (extra classes) | Remove the overrides; if the change was wanted, extend the component (step 4 of the ladder) |
38
+ | A generated draft (Stitch) has its own chrome | Rebuild the draft from components as a new lab version, keeping its layout and content; or leave it and record it, because drafts are not implemented |
39
+ | The draft's element is better than the catalog's | Change the component and the catalog (and DESIGN.md if it is a new look), then re-run the checks: every screen follows |
40
+ | Two versions of one component on a screen | Pick the catalog's; if both are needed, they are two variants: add the variant to the component |
41
+ | The catalog itself is missing the variant a screen needs | Add it to the component and the catalog first, then use it |
42
+
43
+ Never fix consistency by editing one screen to imitate another by hand, and never edit an approved version:
44
+ make the next version.
45
+
46
+ ## 3. Verify and report
47
+
48
+ 1. Re-run `stitch2 check` and `stitch2 consistency`: the fixed screens show "matches" in the report and no
49
+ `reuse`/`consistency` warnings.
50
+ 2. Tell the user, per component, which screens matched, which you fixed (and how: component used, component
51
+ extended, new version), and which differ on purpose (drafts you left, with the reason). Point to the report
52
+ on the canvas so they can see it.
53
+
54
+ ## Rules for every screen you build
55
+
56
+ - Build from the catalog; check the catalog before writing any shared element.
57
+ - One icon set (DESIGN.md names it); the same glyph for the same meaning on every screen.
58
+ - Same chrome in the same place: header, tab bar or sidebar, safe-area padding.
59
+ - Changes to shared elements happen in the component, never per screen.
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: stitch2-design-md
3
+ description: Create or update a project's DESIGN.md (Google's DESIGN.md format) with stitch2 — from a short interview (stitch2 init) or measured from an existing site or screens (stitch2 extract) — then refine it with the user. Use when a project has no design system yet, when the user wants a new look or a rebrand, or wants to capture an existing product's design.
4
+ ---
5
+
6
+ # Building a DESIGN.md
7
+
8
+ DESIGN.md is the design system every other stitch2 skill and check reads: tokens (colours, type levels, radii,
9
+ spacing, components with states) in the YAML front matter, rules in the prose. Google Stitch builds one from a
10
+ theme or a website; stitch2 does the same with two commands, and you refine the result with the user.
11
+
12
+ ## 1. Choose the starting point
13
+
14
+ - **From choices** (`stitch2 init`), when there is no product yet or the user wants a new look. Ask, in one
15
+ message, only what you cannot infer: the product in one sentence and its mood; the brand colour (a hex, or a
16
+ description you turn into one); dark, light or both; the font (default Inter; offer one or two that fit the
17
+ mood); a monospace font for numbers, if any; corner style (square, gently rounded, rounded, pill); density
18
+ (compact, balanced, spacious). Then run:
19
+ `stitch2 init --name "…" --mood "…" --primary "#…" --modes dark,light --sans "…" [--mono "…"]
20
+ --roundness 0|8|12|16|999 --base 14|15|16 --icons Lucide [--scheme tonal_spot|neutral|vibrant|…]`.
21
+ - **From an existing product** (`stitch2 extract <url or .html files…>`), when the user has a site, an app's web
22
+ build or exported screens. Use several representative pages (a list, a detail, a form). It measures colours,
23
+ fonts, text styles, radii and padding and generates what it cannot measure.
24
+
25
+ Both write `<design>/DESIGN.md` (`--out` elsewhere, `--force` to replace) and print the contrast of the pairs
26
+ that matter; when a brand colour had to move to reach 4.5:1, they say so. Tell the user about every adjustment.
27
+
28
+ ## 2. Refine
29
+
30
+ The generated prose is correct but generic. Make it the product's:
31
+
32
+ 1. **Overview**: the product, its users, the mood, in two or three sentences.
33
+ 2. **Colors**: keep the role names (other skills and the components use them); give each a short brand name in
34
+ the prose if the team has one. Extracted colours are guesses where the page was ambiguous: confirm text,
35
+ surfaces and the primary with the user.
36
+ 3. **Typography**: keep the levels; adjust sizes only together with the user and only on the scale.
37
+ 4. **Components**: name the product's real components (its tab bar items, its core list row) and their states.
38
+ 5. **Content & voice** and **Do's and Don'ts**: add the product's data style, naming and banned patterns.
39
+ 6. Keep every rule checkable: values, not adjectives.
40
+
41
+ ## 3. Validate and show
42
+
43
+ 1. `stitch2 lint`: 0 errors. Warnings about disabled text contrast (WCAG exempts it), semi-transparent washes
44
+ (the linter cannot measure them) and colours no component references are expected.
45
+ 2. `stitch2 tokens`, then open the canvas: **DESIGN.md** in the sidebar draws the swatches, live type levels,
46
+ radii and component tokens. Walk the user through it; change and repeat until they agree.
47
+ 3. Then build the component catalog and the first screens with the stitch2 skill, and run stitch2-consistency.
48
+
49
+ ## Updating an existing DESIGN.md
50
+
51
+ Edit the front matter and prose directly for small changes. For a rebrand, generate a new file with `--out`,
52
+ compare it with the current one (`npx @google/design.md diff old new`), and merge what the user approves;
53
+ run `stitch2 tokens`, and every screen re-renders from the new tokens: screens and components use only token
54
+ colours, and `stitch2 check` reports any colour value written into them (`color`).
55
+
56
+ ## The app uses the same tokens
57
+
58
+ DESIGN.md is the one source of the product's look, not only the screens'. `stitch2 tokens` also writes every
59
+ entry of `exports` in `stitch2.config.json` (format `css`, `tailwind4` or `dtcg`; `path` relative to the config).
60
+ When the app already has its own theme variables (shadcn's `--background`, `--primary`, …), map each one to a
61
+ DESIGN.md colour in `aliases` and import the generated file in place of the hand-written values, so nothing in
62
+ the app sets a colour, radius or font of its own. `themes` sets the selectors when the app switches themes
63
+ another way than `data-theme` (`{ "dark": ".dark", "light": ":root" }`). A colour the app needs and DESIGN.md
64
+ lacks goes into DESIGN.md first. Commit the generated files; never edit them.