Skip to content

Commit 8985eb5

Browse files
danielfochcodejunkie99
andauthored
[codex] Add DESIGN.md skill support (#21)
* Add DESIGN.md skill support * fix(design-md): narrow triggers, add precondition, align activation, register decision Follow-up to PR #21 (the original adds the design-md skill). Cross-model review (Claude + Codex) flagged 9 issues; addressing all of them in one commit so the PR can land. P1 — Triggers were too broad. Original list included "UI", "frontend", "components", "styling" — substring-matched against every UI task in any project, even ones with no DESIGN.md. Existing skills (git-proxy, deploy-checklist) use 4–7 specific phrases. Trimmed to 7 narrow triggers focused on DESIGN.md / Google Stitch / design tokens / design system / visual design. P2 — Missing precondition. Skill is only useful when DESIGN.md exists at the project root. git-proxy uses ["..git exists"]; design-md now uses ["DESIGN.md exists at project root"] following the same pattern. Skill loader short-circuits when the file isn't there. P2 — Activation rules drifted between AGENTS.md and the manifest. AGENTS.md said to load the skill "during UI, frontend, component, styling, or prototype work" while the manifest used a different (overly broad) trigger set. Same task, different harness, different behavior. AGENTS.md now mirrors the manifest's narrower trigger list and notes the preconditions-gated load. P2 — Skill body had no "don't modify DESIGN.md by default" guard. For a contract file, read-only-by-default is the right posture. Added an explicit "Default: read-only" section + a constraint that says "do not modify DESIGN.md unless the user explicitly asks". Implementation work consumes the contract; it doesn't edit it. P3 — Skill was not logged in .agent/memory/semantic/DECISIONS.md. docs/writing-skills.md:50 says new skills must be logged there. Added a 2026-04-26 entry covering the decision, rationale, and rejected alternatives. P3 — Self-rewrite hook didn't follow the repo's own format. Replaced the vague "if UI work repeatedly drifts" prose with the standard "after every 5 uses OR on any failure" template from docs/writing-skills.md:36-44 with concrete steps and a commit message format. P3 — Stale "five seed skills" copy. README.md:124 said "five" and docs/demo/src/scenes/Outro.tsx:6 hardcoded `value: "5"` for seed skills, but the same PR adds a sixth. Both bumped to 6. P3 — Validation guidance overstated the manual fallback. The CLI checks contrast ratios and orphaned tokens; the manual checklist doesn't. Note that the manual fallback is best-effort and re-run the CLI when network is available. Codex confirmed `@google/design.md` exists on npm and the CLI commands in the skill body are correct (https://github.com/google-labs-code/design.md). --------- Co-authored-by: codejunkie99 <email@email.com>
1 parent 5d8bc82 commit 8985eb5

8 files changed

Lines changed: 144 additions & 3 deletions

File tree

.agent/AGENTS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ are the exact failure mode this layer prevents.
4141
- Load a full `SKILL.md` only when its triggers match the current task
4242
- Every skill has a self-rewrite hook; invoke it after failures
4343

44+
## Design Systems
45+
- If the project root contains `DESIGN.md`, treat it as the source of truth
46+
for visual design decisions and load `skills/design-md/SKILL.md` when a
47+
task mentions `DESIGN.md`, Google Stitch, design tokens, design system,
48+
or visual design. (The skill's `preconditions` field gates loading on
49+
`DESIGN.md` actually existing — keep this rule in lockstep with
50+
`skills/_manifest.jsonl` to avoid same-task / different-harness drift.)
51+
- Prefer exact tokens, component rules, and design rationale from
52+
`DESIGN.md` over invented colors, typography, spacing, shadows, or motion.
53+
- Do not modify `DESIGN.md` unless the user explicitly asks for a design
54+
system change; implementation work consumes the contract, it doesn't
55+
edit it.
56+
4457
## Protocols
4558
- `protocols/permissions.md` — read before any tool call
4659
- `protocols/tool_schemas/` — typed interfaces for external tools

.agent/memory/semantic/DECISIONS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@
1414
**Rationale:** Each layer has different retention and retrieval needs. Flat memory breaks at ~6 weeks.
1515
**Alternatives considered:** Flat directory (fails at scale), vector store (over-engineered for single user).
1616
**Status:** active
17+
18+
## 2026-04-26: Add `design-md` seed skill (DESIGN.md / Google Stitch)
19+
**Decision:** Ship a sixth seed skill, `design-md`, that points coding agents at a root `DESIGN.md` (Google Stitch format) as the visual-system source of truth. Loads only when `DESIGN.md` exists at the project root, default behavior is read-only on the contract file, and validation prefers `npx @google/design.md lint DESIGN.md` over hand-checks.
20+
**Rationale:** `DESIGN.md` is becoming a de facto contract for AI-driven UI work; without an explicit skill, agents invent ad-hoc tokens that drift from the user's design system. Gating on `DESIGN.md`-existence keeps the skill silent on projects that don't use the format.
21+
**Alternatives considered:** Bundle the rules into `git-proxy` or `skillforge` (wrong scope, wrong triggers); leave it to per-project `.agent/skills/` overrides (loses the cross-harness benefit); broader triggers like "UI"/"frontend"/"components"/"styling" (too generic, loads on every UI task even without DESIGN.md).
22+
**Status:** active

.agent/skills/_index.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,15 @@ Pre-deployment verification against a structured checklist.
2626
Triggers: "deploy", "ship", "release", "go live"
2727
Constraints: all tests passing, no unresolved TODOs in diff,
2828
requires human approval for production.
29+
30+
## design-md
31+
Uses a root `DESIGN.md` as the portable visual system contract for
32+
Google Stitch workflows. Loads only when `DESIGN.md` exists at the
33+
project root.
34+
Triggers: "DESIGN.md", "design.md", "Google Stitch", "design tokens",
35+
"design system", "visual design"
36+
Preconditions: DESIGN.md exists at project root.
37+
Constraints: prefer DESIGN.md tokens over invented values, do not modify
38+
DESIGN.md unless the user explicitly asks, preserve unknown sections when
39+
an edit IS authorised, validate with `npx @google/design.md lint DESIGN.md`
40+
when available.

.agent/skills/_manifest.jsonl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
{"name":"git-proxy","version":"2026-01-01","triggers":["commit","push","branch","merge","rebase","pull request","PR"],"tools":["bash"],"preconditions":[".git exists"],"constraints":["never force push to main","never force push to protected branches","run tests before push"],"category":"operations"}
44
{"name":"debug-investigator","version":"2026-01-01","triggers":["debug","why is this failing","investigate","stack trace","bug"],"tools":["bash","memory_reflect"],"preconditions":[],"constraints":["reproduce before fixing","fix root cause, not symptoms"],"category":"engineering"}
55
{"name":"deploy-checklist","version":"2026-01-01","triggers":["deploy","ship","release","go live"],"tools":["bash"],"preconditions":[],"constraints":["all tests passing","no unresolved TODOs in diff","requires human approval for production"],"category":"operations"}
6+
{"name":"design-md","version":"2026-04-26","triggers":["DESIGN.md","design.md","Google Stitch","Stitch","design tokens","design system","visual design"],"tools":["bash","memory_reflect"],"preconditions":["DESIGN.md exists at project root"],"constraints":["prefer DESIGN.md tokens over invented values","do not modify DESIGN.md unless the user explicitly asks","preserve unknown sections when an edit IS authorised","validate when tooling is available"],"category":"design"}

.agent/skills/design-md/SKILL.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
name: design-md
3+
version: 2026-04-26
4+
triggers: ["DESIGN.md", "design.md", "Google Stitch", "Stitch", "design tokens", "design system", "visual design"]
5+
tools: [bash, memory_reflect]
6+
preconditions: ["DESIGN.md exists at project root"]
7+
constraints: ["prefer DESIGN.md tokens over invented values", "do not modify DESIGN.md unless the user explicitly asks", "preserve unknown sections when an edit IS authorised", "validate when tooling is available"]
8+
---
9+
10+
# DESIGN.md — portable visual system contract
11+
12+
Use this skill when a task touches Google Stitch's `DESIGN.md` format or
13+
the project explicitly references its design system / design tokens. The
14+
skill loads only when `DESIGN.md` exists at the project root (see
15+
`preconditions` above), so general UI / frontend / component work that
16+
isn't tied to a `DESIGN.md` won't trip it.
17+
18+
## Source of truth
19+
- `DESIGN.md` is a contract file. Read it before changing visual UI.
20+
- Treat YAML front matter tokens as normative values: colors, typography,
21+
spacing, radius, and component tokens are exact inputs to code.
22+
- Treat the Markdown body as design rationale: it explains mood, hierarchy,
23+
interaction intent, and where tokens should or should not be used.
24+
- If no `DESIGN.md` exists this skill is inactive; for new UI, offer to
25+
create one or ask for a brand/reference, but don't generate one
26+
unprompted.
27+
28+
## Default: read-only
29+
**Do not modify `DESIGN.md` unless the user explicitly asks for a design
30+
system change.** Implementation work consumes the contract; it does not
31+
edit it. Token additions, renames, or section restructures land in their
32+
own commit with a clear message and (ideally) a Stitch round-trip.
33+
34+
## Implementation rules
35+
1. Map tokens into the local styling system already in use: CSS variables,
36+
Tailwind theme values, design-token JSON, component props, or native
37+
styles.
38+
2. Use token references and component patterns from `DESIGN.md` instead of
39+
hard-coded one-off values.
40+
3. Keep accessibility constraints intact. Do not weaken contrast, focus,
41+
reduced-motion, or touch-target guidance unless the user explicitly
42+
asks.
43+
44+
## When an edit IS authorised
45+
1. Preserve unknown headings and extra prose; other agents or Stitch may
46+
own them.
47+
2. Express component variants as related entries
48+
(`button-primary`, `button-primary-hover`, etc.).
49+
3. Land token / structure changes in their own commit, separate from the
50+
feature consuming them.
51+
52+
## Validation
53+
- If Node/npm tooling is available, lint with:
54+
55+
```bash
56+
npx @google/design.md lint DESIGN.md
57+
```
58+
59+
- For design system changes, diff before/after:
60+
61+
```bash
62+
npx @google/design.md diff DESIGN.before.md DESIGN.md
63+
```
64+
65+
- If the CLI is unavailable or network/dependency policy blocks it, the
66+
manual fallback is best-effort only — check for broken `{path.to.token}`
67+
references, missing primary color / typography tokens, duplicate section
68+
headings, and section order. The CLI ALSO checks contrast ratios and
69+
orphaned tokens; the manual fallback does not, so re-run the CLI when
70+
you regain network access.
71+
72+
## Expected sections
73+
The Google draft spec uses YAML front matter plus Markdown sections.
74+
Common sections:
75+
76+
- `## Overview`
77+
- `## Colors`
78+
- `## Typography`
79+
- `## Layout`
80+
- `## Elevation & Depth`
81+
- `## Shapes`
82+
- `## Components`
83+
- `## Do's and Don'ts`
84+
85+
## Self-rewrite hook
86+
After every 5 uses OR on any failure:
87+
1. Read the last N skill-specific episodic entries.
88+
2. If a new failure mode has appeared (e.g. tokens drifting away from
89+
DESIGN.md, accessibility rules being weakened, unauthorised edits to
90+
the contract file), append it to this skill's `KNOWLEDGE.md`.
91+
3. If a constraint was violated, escalate to `semantic/LESSONS.md`.
92+
4. Commit: `skill-update: design-md, <one-line reason>`.

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ See [`docs/architecture.md`](docs/architecture.md) for the full lifecycle.
188188

189189
Every guide shows the folder structure. This repo gives you the folder
190190
structure **plus the files that actually go inside**: a working portable
191-
brain with five seed skills, four memory layers, enforced permissions, a
191+
brain with six seed skills, four memory layers, enforced permissions, a
192192
nightly staging cycle, host-agent review tools, and adapters for multiple
193193
harnesses.
194194

@@ -201,7 +201,9 @@ harnesses.
201201
a required rationale. No unattended reasoning, no provider coupling.
202202
- **Skills** — progressive disclosure. A lightweight manifest always
203203
loads; full `SKILL.md` files only load when triggers match the task.
204-
Every skill ships with a self-rewrite hook.
204+
Every skill ships with a self-rewrite hook. The bundled `design-md`
205+
skill teaches agents to use a root `DESIGN.md` as the visual source of
206+
truth for UI and Google Stitch workflows.
205207
- **Protocols** — typed tool schemas, a `permissions.md` that the
206208
pre-tool-call hook enforces, and a delegation contract for sub-agents.
207209

@@ -315,6 +317,8 @@ verify_codex_fixes.py # v0.8.0 regression checks (33 checks)
315317
- **git-proxy** — all git ops, with safety constraints
316318
- **debug-investigator** — reproduce → isolate → hypothesize → verify
317319
- **deploy-checklist** — the fence between staging and production
320+
- **design-md** — uses Google Stitch-style `DESIGN.md` files as portable
321+
design-system context for UI, frontend, and component work
318322

319323
## How it compounds
320324

docs/demo/src/scenes/Outro.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { COLORS, FONT } from "../tokens";
33

44
const STATS = [
55
{ value: "7", label: "harnesses" },
6-
{ value: "5", label: "seed skills" },
6+
{ value: "6", label: "seed skills" },
77
{ value: "4", label: "memory layers" },
88
];
99

docs/getting-started.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ Open your harness and ask it anything. The first few days it will feel
4242
stateless. After ~2 weeks you'll notice it checking past lessons, logging
4343
failures with reflection, and (if you let it) proposing skill rewrites.
4444

45+
## Optional: add a visual system with `DESIGN.md`
46+
47+
If your project has UI, drop a Google Stitch-style `DESIGN.md` file in the
48+
project root. The bundled `design-md` skill tells compatible agents to use
49+
that file as the source of truth for colors, typography, spacing, component
50+
rules, and design rationale instead of inventing visual choices.
51+
52+
When Node tooling is available, agents can validate the file with:
53+
54+
```bash
55+
npx @google/design.md lint DESIGN.md
56+
```
57+
4558
## Verify the wiring
4659
```bash
4760
python3 .agent/tools/budget_tracker.py "commit and push"

0 commit comments

Comments
 (0)