@jonandev/longbeard 0.9.0 → 0.11.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,27 @@
1
+ #!/usr/bin/env node
2
+ // WCAG 2.x contrast for colour pairs.
3
+ // node contrast.mjs "#2c2824 on #f6f1e7" "#b0563a on #f6f1e7:mark"
4
+ // Suffix :large or :mark checks against 3:1 instead of 4.5:1.
5
+ const lum = (hex) => {
6
+ const [r, g, b] = [1, 3, 5]
7
+ .map((i) => parseInt(hex.slice(i, i + 2), 16) / 255)
8
+ .map((c) => (c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));
9
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
10
+ };
11
+ let failed = false;
12
+ for (const arg of process.argv.slice(2)) {
13
+ const m = arg.match(/^(#[0-9a-f]{6})\s+on\s+(#[0-9a-f]{6})(?::(large|mark))?$/i);
14
+ if (!m) {
15
+ console.error(`skip: ${arg}`);
16
+ continue;
17
+ }
18
+ const [a, b] = [lum(m[1]), lum(m[2])];
19
+ const ratio = (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
20
+ const need = m[3] ? 3 : 4.5;
21
+ const verdict = ratio >= 7 && !m[3] ? "AAA" : ratio >= need ? "AA" : "FAIL";
22
+ if (verdict === "FAIL") failed = true;
23
+ console.log(
24
+ `${m[1]} on ${m[2]} ${ratio.toFixed(2)}:1 ${verdict}${m[3] ? ` (${m[3]}, needs 3:1)` : ""}`,
25
+ );
26
+ }
27
+ process.exit(failed ? 1 : 0);
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: design-check
3
+ description: >
4
+ Check a screen against the design rules and DESIGN.md, and report findings
5
+ (rule, hard or soft, where, fix). Frame mode checks a Figma frame, called
6
+ by design after each screen. Build mode checks a built UI spec against its
7
+ Ready frames, run after implement-spec, with evidence for the PR. Hard
8
+ findings block; soft findings are reported. It reports and never redesigns.
9
+ ---
10
+
11
+ # design-check
12
+
13
+ Checks one thing: does this screen pass [design-rules.md](references/design-rules.md) and follow `DESIGN.md`? It returns findings. The caller fixes them. It does not suggest a new look, and it does not change `DESIGN.md`.
14
+
15
+ ## Findings
16
+
17
+ One line per finding, hard first:
18
+
19
+ ```
20
+ | Rule | Hard/soft | Where | Fix |
21
+ |---|---|---|---|
22
+ | 8 States | hard | Today, no empty frame | Add "Today — empty": what goes here, and the one action that fills it |
23
+ | 4 Spacing | soft | Today, list to heading gap 24 | Use space/lg (32) or say why in DESIGN.md |
24
+ ```
25
+
26
+ - **Rule** is the number and name from design-rules.md, plus the check if the section has several.
27
+ - **Where** names the screen and the element, so someone can find it without the screenshot.
28
+ - **Fix** is the smallest change that passes, in `DESIGN.md`'s tokens. Never a new colour, face or component the file does not have. If the only fix is one, write "needs a design decision" and say what.
29
+ - A soft rule that `DESIGN.md` overrides with a reason is not a finding. Without a reason, it is.
30
+ - No findings: say "passes" and list which rules were checked.
31
+
32
+ **Hard blocks; soft is reported.** The caller gets one fresh pass to fix the hard findings, then one re-check. Hard findings that remain are listed as open. They never pass silently.
33
+
34
+ ## Order
35
+
36
+ 1. **Idea** (rule 0): cover the logo. Is it still this product?
37
+ 2. **Hard** checks, every section, then the site or app list from the brief's surface.
38
+ 3. **Soft** checks, then the tells (rule 14).
39
+
40
+ Read `DESIGN.md` first: its tokens, components and decisions are what "follows the file" means.
41
+
42
+ ## Frame mode
43
+
44
+ Called by `design` after it composes or changes a Figma screen. Input: the file key, the node IDs of the screen and its state frames, and the approved prototype shot of that screen when there is one.
45
+
46
+ 1. Load `figma-use` for any `use_figma` call. Screenshot each frame (`get_screenshot`, `maxDimension` 1440 so text is readable). Read structure with `get_metadata` when spacing or alignment needs numbers.
47
+ 2. Find the states: the frames next to the default, whatever they are called. Decide from what each frame shows whether it is the screen's empty, loading or error state, not from its name. A reachable state with no frame is a rule 8 hard finding. So is a "not needed" under Decisions in `DESIGN.md` when a person can reach that state after all.
48
+ 3. Check tokens where the screenshot cannot tell: in one read-only `use_figma` call, list fills, gaps and text styles that are not bound to a variable or style. An unbound value is a rule 7 soft finding when a token exists for it. With more than one theme, an unbound colour is a rule 6 hard finding, because it will not change with the theme.
49
+ 4. Check the themes, when `DESIGN.md` lists more than one. Themes built as separate colour sets or as a frame per theme, instead of modes on one collection, are a rule 6 hard finding. For each mode, set it on a temporary copy of the frame, screenshot the copy, delete it, and run the rules on that shot. If the shot does not change with the mode, report that theme as "not checked", never as passed.
50
+ 5. Compare with the prototype shot, side by side. The frame must be faithful to what they approved. Anything lost or changed without their yes is a hard finding, under rule 0. Pixels do not count. No shot: say "not compared".
51
+ 6. Return the findings. `design` fixes the hard ones, runs this once more, then shows the screen. A frame with open hard findings is never marked Ready.
52
+
53
+ ## Build mode
54
+
55
+ After `implement-spec` builds a UI spec. Input: the running app's URL for each screen, and the Ready frames the tickets link. A screen with no Ready frame has nothing to compare with: report it as "not checked" and send it to `design`.
56
+
57
+ 1. **Render** each screen at phone and desktop:
58
+ ```
59
+ node <skill>/scripts/capture.mjs <url> --out <scratch>/<screen>-390.png --width 390 --strict
60
+ node <skill>/scripts/capture.mjs <url> --out <scratch>/<screen>-1440.png --strict
61
+ ```
62
+ Behind a login, pass `--cookie "name=value"` from a dev session the project already uses (a seed user, a test token). Never ask for real credentials. `--strict` exits 1 when the page lands elsewhere: a shot of the login page is not a check. Report it and stop for that screen.
63
+ 2. **Reach the states.** Render each state that has a frame the way the app allows: a fixture, a seed, a query flag, a test route. A state that cannot be reached is reported as "not checked", never as passed. With more than one theme, render each one too, the way the app sets it (a cookie, a query flag). The same applies to a theme that cannot be reached.
64
+ 3. **Compare with the Ready frame on meaning, not pixels:**
65
+ - structure: the same sections, in the same order, with the same hierarchy
66
+ - tokens: colours, type and spacing are `DESIGN.md`'s values (`scripts/contrast.mjs` for any pair that looks off)
67
+ - copy: the frame's words, not placeholders or new ones
68
+ - states: each frame state exists and says the same thing
69
+ A difference from the frame is a finding, hard when it breaks a hard rule or changes structure or copy. The rules' glue line holds: a mismatch with the frame is a bug.
70
+ 4. **Check the rules** on the build shots, in the order above.
71
+ 5. **Fix pass.** Hard findings get one fresh fix pass (a new agent or a clean context, with the findings as its brief), then one re-check.
72
+ 6. **PR evidence.** Matt's `pr` writes the body. Put the shots in its Before/After: the Ready frame beside the build at each width. Then the findings table, with what remains open after the re-check.
73
+
74
+ ## Do not
75
+
76
+ - Redesign, or suggest a colour, face or component `DESIGN.md` does not have.
77
+ - Pass a state you could not see, or a screen whose shot landed on another page.
78
+ - Edit `DESIGN.md` or the Figma file. Fixes are the caller's.
79
+ - Compare pixels. Two renders of the same design differ by antialiasing and fonts. Meaning is what is checked.
@@ -0,0 +1,189 @@
1
+ # Design rules
2
+
3
+ How a screen is checked. Read by `design` before it prototypes and by `design-check` on every frame and build.
4
+
5
+ These rules decide execution, never the look. The direction and `DESIGN.md` decide the look. A rule that seems to ask for a colour, a typeface or a style is misread. It asks only that whatever was chosen is used with intent.
6
+
7
+ ## How to use this
8
+
9
+ - Check from a screenshot. Every check below can be passed or failed by looking at a rendered screen at its real size. When a check needs a state you cannot see (focus, error, empty), it needs that state's frame, and a missing frame fails rule 8.
10
+ - Go in order: **Idea** first, then every **hard** check, then **soft**.
11
+ - **Hard** is the floor: structure, contrast, targets, focus and states. A hard failure blocks the screen. `DESIGN.md` cannot waive it.
12
+ - **Soft** is a default. `DESIGN.md` may override a soft check on purpose, with a written reason. A soft finding with no reason in `DESIGN.md` is reported, not blocked.
13
+ - A finding is four things: the rule (number and check), hard or soft, where on the screen, and the fix.
14
+ - The shared core applies to everything. Then add the site list or the app list, whichever the brief's surface says.
15
+
16
+ ## 0. Idea
17
+
18
+ **Principle:** the screen says one thing about this product that a screen from another product would not.
19
+
20
+ - [soft] Cover the logo and the name. Is it still recognisably this product, from its content, imagery, voice or structure? A screen that could belong to any product in the category fails.
21
+ - [soft] You can say what the screen is for in one sentence, and the most visible element serves that sentence.
22
+ - [soft] The ownable idea in `DESIGN.md` (or the direction, before `DESIGN.md` exists) shows up somewhere you can point to.
23
+
24
+ ## 1. Hierarchy
25
+
26
+ **Principle:** the eye lands first on what matters most, then moves in the order the task needs.
27
+
28
+ - [hard] Exactly one element is the most prominent on the screen. Squint or blur the shot: one thing still stands out.
29
+ - [hard] The primary action is easier to find than any secondary action. If two actions look equally important, only one of them should be.
30
+ - [soft] Prominence comes from at most two of size, weight, colour and position at once. Using all four on one element is shouting.
31
+ - [soft] Secondary text (meta, captions, help) is visibly quieter than body text, by lighter colour or smaller size, not both pushed to the limit.
32
+
33
+ ## 2. Grouping
34
+
35
+ **Principle:** things that belong together look together, and things that do not are kept apart.
36
+
37
+ - [hard] The space between related items is clearly smaller than the space between groups. A label sits closer to its field than to the field above.
38
+ - [soft] Each group is separated by one device: space, a tone step, a box, or a line. Two at once (a boxed card with a divider inside a tinted panel) is noise.
39
+ - [soft] A reader can count the groups on the screen at a glance, and the count matches the sections the brief describes.
40
+
41
+ ## 3. Alignment and grid
42
+
43
+ **Principle:** every element sits on a line shared with something else.
44
+
45
+ - [hard] Left edges of text blocks in one column line up. No block is nudged a few pixels off its neighbours.
46
+ - [soft] The screen has a small number of alignment lines (often a column grid). Draw them on the shot: an element that touches none of them needs a reason.
47
+ - [soft] Centred alignment is used for a single moment (an empty state, a hero line), not as the default for whole sections of left-reading content.
48
+ - [soft] Numbers in a column align on the right or on the decimal, so they compare.
49
+
50
+ ## 4. Spacing rhythm
51
+
52
+ **Principle:** space comes from a short scale, and bigger gaps mean bigger separations.
53
+
54
+ - [soft] Every gap on the screen comes from the spacing scale in `DESIGN.md`. Measure five gaps at random: all are on the scale.
55
+ - [soft] There are at most three or four distinct gap sizes in one view, and each has a job (inside a component, between items, between groups, between sections).
56
+ - [soft] Nothing touches the edge of its container. Text inside a box has padding at least as large as the gap between its lines.
57
+ - [soft] Dense views stay dense on purpose: a table or list keeps tight rows rather than inheriting marketing-page spacing.
58
+
59
+ ## 5. Typography
60
+
61
+ **Principle:** a few sizes, far apart, set for reading.
62
+
63
+ - [soft] The view uses at most five font sizes, and adjacent sizes are clearly different (roughly a 1.2× step or more), not 15, 16 and 17.
64
+ - [soft] Body text runs about 45 to 80 characters per line on desktop. Count one line.
65
+ - [soft] Body line height is visibly looser than heading line height. Headings of two lines do not drift apart.
66
+ - [soft] Weight does the work before size. A label is not set larger to be noticed when bold would do.
67
+ - [hard] No text is clipped, overlapped, or cut mid-word by its container, in any language the product ships.
68
+
69
+ ## 6. Colour
70
+
71
+ **Principle:** colour carries meaning, and the meaning stays the same everywhere.
72
+
73
+ - [hard] Body text has a contrast ratio of at least 4.5:1 against its background. Large text (24px, or 18.66px bold, and up) and the visible parts of controls and icons have at least 3:1.
74
+ - [hard] Colour is never the only signal. An error, a selected item or a required field also changes shape, weight, an icon or text.
75
+ - [soft] Every colour on the screen is a token in `DESIGN.md`. Pick three at random: each maps to a named token.
76
+ - [hard] A product with more than one theme has one set of colour tokens, with a value for each theme, and passes every check here in each theme. A colour that stays the same when the theme changes, and should not, fails.
77
+ - [soft] The accent colour marks action or state, and is not also used for decoration on the same screen.
78
+ - [soft] Status colours (error, warning, success) are used for status only.
79
+
80
+ ## 7. Consistency
81
+
82
+ **Principle:** the same thing looks and behaves the same everywhere.
83
+
84
+ - [hard] One action has one look. Two primary buttons on different screens are the same component, same size and same label case.
85
+ - [soft] Components come from the Figma library or the codebase's components. A one-off that looks like a library component, but is slightly different, fails.
86
+ - [soft] Icons share a style: one stroke weight or one fill style, one corner treatment, one optical size.
87
+ - [soft] The same word means the same thing. "Delete" and "Remove" are not both used for one action.
88
+
89
+ ## 8. States
90
+
91
+ **Principle:** every screen is shown in every state a person will meet.
92
+
93
+ - [hard] The screen has a frame for each of empty, loading and error that a person can reach, next to the default. A state nobody can reach is recorded as not needed, with the reason. A reachable state with no frame is a failure, not a later task.
94
+ - [hard] Empty says what goes here and gives the one action that fills it. Error says what went wrong in plain words and how to recover.
95
+ - [hard] Interactive components show hover (pointer surfaces), focus, pressed, disabled, and selected where they apply. Each state is visibly different from default.
96
+ - [soft] Loading keeps the layout's shape (skeleton or reserved space), so content does not jump when it arrives.
97
+ - [soft] Long content is shown: the longest real name, a big number, a two-line title. Short sample text hides overflow.
98
+
99
+ ## 9. Affordance and feedback
100
+
101
+ **Principle:** what can be acted on looks like it, and every action visibly answers.
102
+
103
+ - [hard] Every interactive element looks interactive without hovering. Text links are distinct from body text by more than colour alone, unless their position makes them obvious (a nav bar).
104
+ - [hard] Nothing that looks interactive is not. A card that looks clickable is clickable, or loses the look.
105
+ - [soft] Each action has a visible result frame: a saved state, a toast, the item appearing in the list, a progress indicator for anything over a second.
106
+ - [soft] Destructive actions look different from safe ones and are never the default or most prominent option.
107
+
108
+ ## 10. Accessibility
109
+
110
+ **Principle:** the screen works for people who see, move and read differently.
111
+
112
+ - [hard] The focused state of every interactive element shows a visible indicator with at least 3:1 contrast against what is around it. Check it in the focus frame.
113
+ - [hard] Targets are at least 24×24 CSS pixels, or have that much space around them (WCAG 2.2 AA). The app list raises this for touch.
114
+ - [hard] Every input has a visible label. A placeholder alone is not a label.
115
+ - [hard] Text is real text, not text in an image, except in logos.
116
+ - [soft] The screen still reads at 200% text size: nothing important is cut off in the zoomed frame.
117
+
118
+ ## 11. Copy
119
+
120
+ **Principle:** words do the job of the screen in the product's own voice.
121
+
122
+ - [hard] No placeholder copy: no lorem ipsum, no "Title", no "Button", no "User Name".
123
+ - [soft] Buttons say what happens: "Send invoice", not "Submit", "OK", "Get started" or "Learn more".
124
+ - [soft] Headings are short. A heading that runs over two lines at its size is a sentence that belongs in the body.
125
+ - [soft] The voice matches `DESIGN.md`. Read three strings aloud: they sound like one product.
126
+ - [soft] No genre filler: unlock, supercharge, seamless, elevate, effortless, all-in-one, and "not just X, it's Y".
127
+
128
+ ## 12. Imagery
129
+
130
+ **Principle:** pictures show the real thing, or there are none.
131
+
132
+ - [soft] Images show this product's subject, people or interface. A stock scene that fits any product in the category fails.
133
+ - [soft] Where a picture belongs, there is a picture, not a grey box, a gradient or a text block pretending.
134
+ - [soft] Images share one treatment: one crop logic, one colour handling, one corner shape.
135
+ - [hard] Text over an image meets the contrast floor in rule 6 across the whole text area, not only on the darkest part.
136
+
137
+ ## 13. Responsive
138
+
139
+ **Principle:** each size is designed, not squeezed.
140
+
141
+ - [hard] At mobile width (360–390px) nothing scrolls sideways, nothing is clipped, and nothing overlaps.
142
+ - [hard] The primary action is reachable at every size without hunting: visible, or one obvious step away.
143
+ - [soft] The layout changes structure between sizes where it should: columns stack, tables become lists or scroll inside their own box, navigation collapses into one control.
144
+ - [soft] Type and spacing scale down a step on mobile, not to illegible sizes. Body text stays at least 16px.
145
+
146
+ ## 14. Tells
147
+
148
+ **Dated 2026-11-03. Reviewed each release.** Add new tells, retire ones that stopped being defaults.
149
+
150
+ A tell is a device that makes a screen look produced by default rather than designed for this product. Most began as good ideas. They are tells because they arrive without a reason. Every check here is **soft**: present, and `DESIGN.md` gives no reason for it. This list never says what to use instead. That comes from the direction.
151
+
152
+ - [soft] Purple-to-blue gradients on backgrounds, buttons, glows or headline text.
153
+ - [soft] Translucent blurred panels used on two or more surfaces.
154
+ - [soft] The same soft grey shadow under every card.
155
+ - [soft] A row of three identical feature cards, each an icon in a rounded square, a heading and two lines.
156
+ - [soft] Emoji used as icons or bullets.
157
+ - [soft] A tiny tracked uppercase label above every heading, or a pill badge ("New", "Beta") above the hero line.
158
+ - [soft] One word of a headline singled out in another face, colour or underline.
159
+ - [soft] A cream ground with a terracotta or rust accent, used as a shortcut to "warm".
160
+ - [soft] Decorative monospace labels, index numbering (01 / 02 / 03) as ornament, hairline rules boxing everything, or design-tool marks (crosshairs, crop marks) as decoration.
161
+ - [soft] A fake dashboard made of grey bars and donut charts where a real interface fragment should be.
162
+ - [soft] Invented social proof: logos, quotes, star rows or user counts the product does not have.
163
+ - [soft] Every section in the same layout, or the stock order hero, logos, features, testimonial, pricing, call to action, when the argument needs another.
164
+ - [soft] One medium corner radius on everything, chosen by default rather than on purpose.
165
+
166
+ Removing tells is not the goal. A screen with none and no idea fails rule 0.
167
+
168
+ ## Sites
169
+
170
+ Add these when the brief's surface is a site: the page a person lands on to understand or choose.
171
+
172
+ - [hard] The first screen at mobile and desktop says what this is and who it is for, without scrolling.
173
+ - [soft] Sections follow the order of the argument the brief makes, and each section is composed differently from the one before.
174
+ - [soft] There is one primary call to action, repeated at most at the end, with the same label.
175
+ - [soft] Proof is real (product shots, named customers the product has, numbers it can stand behind) or absent.
176
+
177
+ ## Apps
178
+
179
+ Add these when the brief's surface is an app: the tool a person comes back to.
180
+
181
+ - [hard] Touch targets on touch platforms are at least 44×44 pt (Apple) or 48×48 dp (Material), whichever platform it ships on. The web floor in rule 10 still applies.
182
+ - [hard] The person always knows where they are: the current place in navigation is marked, and the screen title matches the nav item.
183
+ - [soft] Density fits repeated use. Lists and tables show enough rows to work, not marketing-sized cards.
184
+ - [soft] Navigation keeps the same place and shape on every screen of the flow.
185
+ - [soft] Frequent actions are one step away. Rare and destructive ones may be further.
186
+
187
+ ## Sources
188
+
189
+ Ideas drawn from, in our own words: Gestalt principles of grouping; WCAG 2.2 (contrast 1.4.3 and 1.4.11, focus visible 2.4.7, target size 2.5.8, labels 3.3.2); Refactoring UI practice (Adam Wathan and Steve Schoger); Apple Human Interface Guidelines and Material Design basics (touch targets, navigation, states); and the tells registry of taste-skill by Leonxlnx (MIT).
@@ -2,12 +2,18 @@
2
2
  // Full-page capture. Unsticks fixed/sticky chrome first so Chrome does not
3
3
  // repeat the same fold. Node 22+. Uses an installed Chrome/Edge/Chromium.
4
4
  //
5
- // node capture.mjs <url> --out .design/refs/name.jpg
6
- // node capture.mjs <url> --out .design/refs/name.jpg --review /tmp/name-review.jpg
7
- // node capture.mjs <url> --out .design/refs/name.jpg --clip x,y,w,h
8
- // node capture.mjs <url> --out .design/refs/name.jpg --clip-selector "main"
5
+ // node capture.mjs <url> --out design-exploration/<slug>/refs/name.jpg
6
+ // node capture.mjs <url> --out design-exploration/<slug>/refs/name.jpg --review /tmp/name-review.jpg
7
+ // node capture.mjs <url> --out design-exploration/<slug>/refs/name.jpg --clip x,y,w,h
8
+ // node capture.mjs <url> --out design-exploration/<slug>/refs/name.jpg --clip-selector "main"
9
+ // node capture.mjs <url> --out /tmp/mobile.png --width 390
10
+ // node capture.mjs http://localhost:3000/app --out /tmp/app.png --cookie "session=abc; theme=dark" --strict
11
+ //
12
+ // A page that ends up at another address (a login, or a site's canonical
13
+ // www) is named on stderr. With --strict that is exit 1, so a 0 means the
14
+ // shot is of the page asked for.
9
15
  // node capture.mjs file:///abs/path/moodboard.html --out /tmp/moodboard.jpg
10
- // node capture.mjs file:///abs/path/shot.jpg --out .design/refs/name.jpg --clip x,y,w,h
16
+ // node capture.mjs file:///abs/path/shot.jpg --out design-exploration/<slug>/refs/name.jpg --clip x,y,w,h
11
17
  import { spawn, execSync } from "node:child_process";
12
18
  import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
13
19
  import { tmpdir } from "node:os";
@@ -26,12 +32,25 @@ const outArg = flag("out", "") || "";
26
32
  const reviewArg = flag("review", "") || "";
27
33
  const clipArg = flag("clip", "") || "";
28
34
  const clipSelector = flag("clip-selector", "") || "";
35
+ // Sent with every request to the page's own origin, as a logged-in browser would.
36
+ const cookieArg = flag("cookie", "") || "";
37
+ const strictAt = args.indexOf("--strict");
38
+ const strict = strictAt !== -1;
39
+ if (strict) args.splice(strictAt, 1);
40
+ // Below 768 the page gets a phone viewport: mobile layout, 2x pixels.
41
+ const width = Math.round(Number(flag("width", "1440")));
29
42
  if (!url || !/^(https?|file):\/\//.test(url) || !outArg) {
30
43
  console.error(
31
- 'usage: node capture.mjs <https://url | file:///path> --out .design/refs/name.jpg [--review /tmp/name-review.jpg] [--clip x,y,w,h | --clip-selector "css"]',
44
+ 'usage: node capture.mjs <https://url | file:///path> --out design-exploration/<slug>/refs/name.jpg [--review /tmp/name-review.jpg] [--clip x,y,w,h | --clip-selector "css"] [--width 390] [--cookie "name=value; …"] [--strict]',
32
45
  );
33
46
  process.exit(2);
34
47
  }
48
+ if (!Number.isFinite(width) || width < 200 || width > 3840) {
49
+ console.error("width must be a number from 200 to 3840");
50
+ process.exit(2);
51
+ }
52
+ const mobile = width < 768;
53
+ const height = mobile ? 844 : 900;
35
54
  if (clipArg && clipSelector) {
36
55
  console.error("pass --clip or --clip-selector, not both");
37
56
  process.exit(2);
@@ -129,7 +148,7 @@ proc = spawn(
129
148
  "--hide-scrollbars",
130
149
  "--mute-audio",
131
150
  "--force-color-profile=srgb",
132
- "--window-size=1440,900",
151
+ `--window-size=${width},${height}`,
133
152
  "about:blank",
134
153
  ],
135
154
  { stdio: ["ignore", "ignore", "pipe"] },
@@ -196,10 +215,10 @@ const page = (method, params, timeoutMs) => send(method, params, sessionId, time
196
215
  await page("Page.enable");
197
216
  await page("Runtime.enable");
198
217
  await page("Emulation.setDeviceMetricsOverride", {
199
- width: 1440,
200
- height: 900,
201
- deviceScaleFactor: 1,
202
- mobile: false,
218
+ width,
219
+ height,
220
+ deviceScaleFactor: mobile ? 2 : 1,
221
+ mobile,
203
222
  });
204
223
  // Chrome centres an image file and shrinks it to the window. A page that holds
205
224
  // it at full size from 0,0 makes --clip x,y,w,h the image's own pixels.
@@ -208,6 +227,22 @@ if (/^file:\/\/.*\.(png|jpe?g|webp|gif)$/i.test(url)) {
208
227
  target = `file://${join(dir, "image.html")}`;
209
228
  writeFileSync(join(dir, "image.html"), `<!doctype html><body style="margin:0;background:#000"><img src="${url.replace(/"/g, "%22")}" style="display:block">`);
210
229
  }
230
+ if (cookieArg && /^https?:/.test(url)) {
231
+ const cookies = cookieArg
232
+ .split(";")
233
+ .map((pair) => pair.trim())
234
+ .filter(Boolean)
235
+ .map((pair) => {
236
+ const at = pair.indexOf("=");
237
+ return { name: pair.slice(0, at), value: pair.slice(at + 1), url: new URL(url).origin };
238
+ });
239
+ if (cookies.some((cookie) => !cookie.name)) {
240
+ console.error('cookie must be "name=value; name=value"');
241
+ drop();
242
+ process.exit(2);
243
+ }
244
+ await page("Network.setCookies", { cookies });
245
+ }
211
246
  await page("Page.navigate", { url: target }, 40000);
212
247
  await sleep(2500);
213
248
 
@@ -310,6 +345,23 @@ await page("Runtime.evaluate", {
310
345
  });
311
346
  await sleep(400);
312
347
 
348
+ // A redirect can land late (an app checks the session after it loads), so
349
+ // the address is checked last, right before the shot.
350
+ if (target === url) {
351
+ const landed = (await page("Runtime.evaluate", { expression: "location.href", returnByValue: true })).result.value;
352
+ const where = (href) => {
353
+ const u = new URL(href);
354
+ return `${u.origin}${u.pathname.replace(/\/$/, "")}`;
355
+ };
356
+ if (where(landed) !== where(url)) {
357
+ console.error(`landed on ${landed}, not ${url}.${/^https?:/.test(landed) ? " Behind a login? Pass --cookie." : " Check the address."}`);
358
+ if (strict) {
359
+ drop();
360
+ process.exit(1);
361
+ }
362
+ }
363
+ }
364
+
313
365
  // --clip-selector takes the element's box in document coordinates, measured
314
366
  // after the unstick pass so the numbers match what the capture sees.
315
367
  let selected = null;
@@ -343,8 +395,8 @@ if (clipSelector) {
343
395
 
344
396
  const metrics = await page("Page.getLayoutMetrics");
345
397
  const size = metrics.cssContentSize || metrics.contentSize;
346
- const fullWidth = Math.max(1, Math.ceil(size.width || 1440));
347
- const fullHeight = Math.max(1, Math.min(Math.ceil(size.height || 900), 14000));
398
+ const fullWidth = Math.max(1, Math.ceil(size.width || width));
399
+ const fullHeight = Math.max(1, Math.min(Math.ceil(size.height || height), 14000));
348
400
  const clipBox = clip || (selected ? { ...selected, scale: 1 } : null);
349
401
  const shotClip = clipBox
350
402
  ? {
@@ -0,0 +1,190 @@
1
+ ---
2
+ name: design-direction
3
+ description: >
4
+ Find the direction for a product's look from what they like and from real
5
+ references: a wide pool from every source they choose, which they mark like
6
+ or no on a picker page, a sharper second search from those picks, then a
7
+ moodboard. Ideas and patterns, never tokens: colour and type are chosen
8
+ later, in design, on rendered screens.
9
+ Runs after docs/brief.md exists and the brief has a UI, or when design hits
10
+ a gap and needs references for one piece. Writes
11
+ design-exploration/<slug>/direction.md, a proposal, then offers to take it
12
+ into design.
13
+ ---
14
+
15
+ # Design direction
16
+
17
+ One file comes out: `design-exploration/<slug>/direction.md`, a proposal for how the product should look and sound. It is not official. `design` turns it into screens, and only an approved prototype becomes `DESIGN.md`.
18
+
19
+ Direction is the inspiration step: it looks at good designs and works to find ideas and patterns for something new. It never picks a colour, a typeface, a size or a spacing value, and it never writes `DESIGN.md`.
20
+
21
+ ## Gate
22
+
23
+ Look at the repo. Do not ask what is there.
24
+
25
+ 1. No `docs/brief.md` → run `idea` first. Stop.
26
+ 2. The brief says no UI (CLI, API, library) → there is no direction to find. Say so and stop.
27
+ 3. Called for one piece (a view, a section, a control, an empty state, "ideas for X"), usually by `design` at a gap → **One piece**.
28
+ 4. Otherwise → **Identity**. With a `DESIGN.md` already, this is a rebrand. Say that `DESIGN.md` stays as it is until `design` approves a new one.
29
+
30
+ ## Folder
31
+
32
+ Everything goes in `design-exploration/<slug>/`: `candidates.tsv` and `picker.html` (and `-2` for round 2), `board.md`, `refs/`, `moodboard.html`, `direction.md`. The first pass is `identity/`. One piece uses its own slug (`pricing`, `empty-state`). If the folder exists, use `<slug>-2`. Two explorations never share a folder.
33
+
34
+ On the first write, add `design-exploration/` to `.gitignore` if it is missing, and say why in one line: it is a working folder for inspiration, not part of the product. If `git ls-files design-exploration` already lists files, say so and leave `git rm -r --cached design-exploration` to them.
35
+
36
+ ## Identity
37
+
38
+ ### 1. Three questions, one round
39
+
40
+ Read `docs/brief.md` first. It gives the subject, the people, the surface (site or app), the key screens, and the identity nouns. Do not ask for any of that again. Send one message and wait. Do not search in that turn. These questions are how they steer the look, so always ask them, however the run was set up. Only they can say "go".
41
+
42
+ ```
43
+ Before I look, three questions. Skip any with "go" and I'll decide.
44
+
45
+ 1. How should <product> feel, and never feel? Any apps, sites, brands, books or places you love for this?
46
+ 2. Pictures or links you already like? Screenshots, links or files.
47
+ 3. Where should I look, and how many should end up on the moodboard? [x] <source> — <what it gives> … [ ] your own. Default 12. You'll pick from a much wider pool first.
48
+ ```
49
+
50
+ Default sources:
51
+
52
+ - **App:** popular Dribbble. No award galleries.
53
+ - **Site:** Awwwards, Recent. Dribbble for screens. Dark Mode Design only when the feel is dark. siteinspire is offered unticked: it refuses scripts, so it cannot be in the picker.
54
+ - **Imagery** (Wikimedia Commons): only when the brief's key screens need pictures.
55
+
56
+ Each of these was checked to work with this skill's scripts, without a login (2026-11-03). Do not add a source that has not been.
57
+
58
+ Anything skipped is yours to decide: say what you chose in one line, then search. A Figma link pasted before the search means the look already exists: say so, and offer `design` instead. If their answers contradict the brief, that is `grilling`, not a second round.
59
+
60
+ A picture they gave is a **seed**: a picker row with source `seed`, which starts liked, then a card with `link: none (shared in chat)` or its URL, never dropped. Seeds steer the queries ("more like this").
61
+
62
+ ### 2. Search wide
63
+
64
+ Read [sources.md](references/sources.md) before keeping anything. Do not narrate while looking. One line at the end is enough ("Found 64 across Dribbble, Awwwards and Recent, building the picker.").
65
+
66
+ - **They choose, so the pool is wide:** 40 to 80 candidates across the sources they chose. Cut only what is not a candidate: off-form, off-topic, under the source's quality floor, a near-twin from the same designer, anything sources.md drops. Never cut for taste here. A pool holding only what you would pick is the problem this step exists to fix.
67
+ - **Query the form, not the word.** "writing app" returns T-shirts. `product-design?q=text+editor+screen` returns screens.
68
+ - **Thin is a search problem.** Before calling a field thin, search at least three more forms, and the objects in the brief's identity nouns: the product's world often beats its category. Still thin: say what was missing rather than lowering the filter.
69
+ - **One row per candidate** in `design-exploration/<slug>/candidates.tsv`: `title<TAB>thumbnail<TAB>link<TAB>source<TAB>meta`. The thumbnail is the listing's own: sources.md says where each source keeps it. `meta` is optional, one short line (designer, likes, award).
70
+ - **Nothing is captured yet.** The picker shows listing thumbnails, which is a view, not a capture.
71
+
72
+ ### 3. Pick
73
+
74
+ ```
75
+ node <skill>/scripts/picker.mjs design-exploration/<slug>/candidates.tsv --out design-exploration/<slug>/picker.html
76
+ ```
77
+
78
+ Look at it yourself first (`capture.mjs "file://$PWD/design-exploration/<slug>/picker.html" --out <scratch>/picker.jpg`). Drop or replace a row whose thumbnail is broken or blank, and run it again. Then say where it is and ask one line:
79
+
80
+ > Open the picker: click like on what pulls you, no on what feels wrong, add a why if you have one, then paste the picks here.
81
+
82
+ Each id is the round's letter and its row number in that round's TSV, comments not counted: `a7` is row 7 of `candidates.tsv`.
83
+
84
+ **Read the picks back**, in up to four lines, and wait for their yes or correction:
85
+
86
+ - what the likes share: a layout, an arrangement, a kind of picture, a density, a mood, with ids
87
+ - what the noes share
88
+ - the search this points to next
89
+
90
+ > Is that it, or what did I miss?
91
+
92
+ **Round 2, once.** Search again from the corrected read, sharper than round 1: the forms the likes share, the same designer or studio, the same gallery tag or category, and the shared pattern on the other sources (a liked Dribbble concept becomes a search for live sites with that pattern). Leave out what the noes share. 20 to 40 rows in `candidates-2.tsv`, then `picker.mjs … --round 2 --out design-exploration/<slug>/picker-2.html`, and the same ask. Skip round 2 when they say the likes already cover it. There is never a third round.
93
+
94
+ **The likes are the shortlist.** Open each at full size and drop what fails sources.md, naming each drop and why in one line. Keep up to the number they chose (default 12): later-round likes and the clearest patterns first. Capture only these (`node <skill>/scripts/capture.mjs <url> --out design-exploration/<slug>/refs/<name>.jpg`). Nothing is kept from a thumbnail.
95
+
96
+ - **App:** a Dribbble concept has never faced real content. Keep it only if its idea survives the brief's longest names and its empty state.
97
+ - **Site:** live sites outweigh Dribbble shots.
98
+
99
+ If they say "go" or "you choose" instead of picking, pick from the pool yourself, closest to the brief, and say so in one line.
100
+
101
+ ### 4. Write `board.md`
102
+
103
+ A few header lines, then one card per keep.
104
+
105
+ ```
106
+ Asked: <feel, never feel, loves, or none>
107
+ Sources: <what was searched, and any skip: "Awwwards: no fit">
108
+ Picked: <the likes, by id, and what they share>
109
+ Noes: <what the noes share, or none>
110
+ Missing: <what the search could not find, or none>
111
+
112
+ ### <name>
113
+ - link: <the page a person can open, or "none (shared in chat)">
114
+ - shot: design-exploration/<slug>/refs/<file>
115
+ - pattern: <the idea that inspires, about six words: a layout, an arrangement, a way of showing data, a voice>
116
+ - why: <why it fits this brief, one line>
117
+ ```
118
+
119
+ `pattern` is the moodboard caption, so write it as a pattern ("one column, the date as the spine"), never as their brand ("Linear's purple").
120
+
121
+ ### 5. Lead on the moodboard
122
+
123
+ ```
124
+ node <skill>/scripts/moodboard.mjs design-exploration/<slug>/board.md --out design-exploration/<slug>/moodboard.html
125
+ ```
126
+
127
+ Look at it yourself first (`capture.mjs "file://$PWD/design-exploration/<slug>/moodboard.html" --out <scratch>/moodboard.jpg`). Fix a wrong caption or a missing picture on the board and run it again. Then say where it is and that every tile links to its source, and ask one line:
128
+
129
+ > Which one leads, and does any feel wrong next to the others?
130
+
131
+ If they say "you choose", take the closest to the brief and say which.
132
+
133
+ ### 6. Write `direction.md`
134
+
135
+ From their answer. Short: it is read by `design`, not by a client.
136
+
137
+ ```
138
+ # Direction: <product>
139
+
140
+ Proposal, not official. design turns this into screens. Only an approved prototype becomes DESIGN.md.
141
+
142
+ - idea: <the one thing this product's look says, in one sentence>
143
+ - feel: <their words for feel and never feel>
144
+ - patterns: <what inspires us, each with its reference: a layout, an arrangement, a kind of picture, a way of moving>
145
+ - ownable: <one concrete element made from the brief's identity nouns, so this is not the lead. For a lighthouse logbook: a lamp-glow marker on the active item. Unconfirmed until seen rendered>
146
+ - voice: <how it talks: three adjectives and one sample line in that voice>
147
+ - leave: <what stays behind: each reference's name, colours and typefaces, what their noes share, and whatever they said feels wrong>
148
+
149
+ ## References
150
+ - leads: <card> — <link>
151
+ - also: <cards> — <links>
152
+ ```
153
+
154
+ - **The lead is the closest**, not the boldest: the subject's world is in the shot. It leads the feeling. It is not the brand.
155
+ - **No values.** No hex, no font name, no size. If a reference's colour or type is the point, describe the quality ("near-black ink on a warm page", "a condensed display face") and let `design` choose the value.
156
+
157
+ Then say the direction in chat in four lines (idea, patterns, ownable, leave), and end with one question. Wait for the answer, however the run was set up: the direction is theirs to correct before anything is built on it.
158
+
159
+ > Change anything, or take this into design?
160
+
161
+ Yes → load `design`. No → stop. The folder stays on this machine.
162
+
163
+ ## One piece
164
+
165
+ Usually called from `design` when a key screen has a gap no reference covers. Same card shape, same moodboard, its own slug.
166
+
167
+ 1. Read `DESIGN.md` if it exists, and the brief. They are the base: the piece fits the colour, type and voice already chosen and never changes them.
168
+ 2. Ask once, then wait, unless the caller already said what is needed:
169
+
170
+ ```
171
+ Any style or requirements for this? Optional.
172
+
173
+ A few ways to search:
174
+ - <a form you can type into a gallery: "a bar that fills once">
175
+ - <…>
176
+ ```
177
+
178
+ 3. Build a pool of 20 to 40. Include the same piece in other subjects. For a gap software has not solved, search outside software for the same form.
179
+ 4. One picker round, no round 2. Keep up to the number asked (default 8 for one piece) from their likes, opened at full size.
180
+ 5. Write `design-exploration/<slug>/board.md`, run the moodboard, and ask which they would take.
181
+ 6. Write a short `direction.md` for the piece: `patterns`, `leave`, and the references. Hand back to `design`.
182
+
183
+ ## Do not
184
+
185
+ - Pick colour, type, spacing, or any value. Write `DESIGN.md`. Code or lay out a page.
186
+ - Search before the three questions are answered, answer them yourself, or ask them a second round of questions. Run a third picker round.
187
+ - Cut the pool for taste before they pick. Pad the keep by lowering the filter. Keep a shot nobody opened at full size.
188
+ - Screenshot a source's listing or search page, or a candidate you are not keeping. Never stitch screenshots.
189
+ - Name a reference in `direction.md`'s idea, patterns or ownable as the thing to copy. Name the pattern.
190
+ - Put notes or skill feedback under `design-exploration/`. Use the chat.