¿Qué hace design-spec-guard?
Turn a written design specification into executable engineering guardrails so spacing drift (e.g. accidental 2px optical padding, margin + gap double-stacking), off-spec radii, forbidden typography/copy characters, small touch targets, narrow-viewport overflow, and light/dark theme leaks are blocked automatically at build and test time.
Bundled Templates
All reusable templates live under resources/:
resources/design-tokens.template.json— machine-readable spec contract (spacingGridPx,allowedSpacingPx,allowedRadiusPx,minFontSizePx,minHitTargetPx,forbiddenChars,forbiddenCopy, theme scope lock, audit routes/viewports).resources/lint-design.template.mjs— zero-dependency Node.js static linter readingdesign-tokens.json.resources/design-spec-audit.template.spec.ts— Playwright runtime DOM pixel & layout audit readingdesign-tokens.json.resources/AGENTS.ui-section.template.md— project-level UI rules & mandatory verification commands forAGENTS.md.
Workflow (6 Steps)
1. Identify the Single Source of Truth
- Locate the project's authoritative design spec document (or confirm with the user which single file is canonical).
- Never create parallel dated copies; record the canonical path in
design-tokens.json(specDoc).
2. Generate design-tokens.json from the Real Spec
- Copy
resources/design-tokens.template.jsonto<project-root>/design-tokens.json. - Populate only values grounded in the project's actual design spec and codebase — never invent tokens or copy another project's rules blindly:
spacingGridPx/allowedSpacingPx(e.g. 4px or 8px grid)allowedRadiusPxminFontSizePx&minHitTargetPx(e.g.44on mobile touch apps,32/36on desktop SaaS if specified)forbiddenChars&forbiddenCopy(only what this project's spec forbids)cssPaths,sourcePaths,ignoreFilesisolatedThemeScope(enable when an outer workbench/shell wraps an inner dark/light canvas or device frame)auditRoutes&auditViewports
3. Install Static Gate & Chain into Build
- Copy
resources/lint-design.template.mjsto<project-root>/scripts/lint-design.mjs. - Add
"lint:design": "node scripts/lint-design.mjs"topackage.json. - Prepend
npm run lint:design &&to production build scripts (build,build:web, etc.) so violations fail builds immediately. - If the repository has Git hooks (Husky / simple-git-hooks /
.git/hooks), optionally wirenpm run lint:designintopre-commit.
4. Install Runtime Pixel Audit (test:spec)
- If Playwright is installed (or user wants browser pixel verification), copy
resources/design-spec-audit.template.spec.tsinto the project's test directory (e.g.tests/design-spec-audit.spec.ts) and add"test:spec": "playwright test tests/design-spec-audit.spec.ts --workers=1"topackage.json. - Add project-specific geometric assertions directly in the spec file:
- Exact section/card sibling gaps via
getBoundingClientRect() - Heading-to-card left-edge alignment (
Math.abs(a.left - b.left) <= 1) - Zero asymmetric padding on section headings / title wrappers (
paddingTop === "0px",paddingBottom === "0px") - Isolated theme contrast assertions when dual themes exist
- Exact section/card sibling gaps via
5. Write Project AGENTS.md
- Merge
resources/AGENTS.ui-section.template.mdinto the project rootAGENTS.md(creating it if absent) so both Antigravity and Codex automatically obey the project's exact spec path, whitelist syntax, and pre-delivery commands.
6. Run Live, Triage Findings, and Verify
- Run
npm run lint:design. - For each flagged line:
- Real bug (e.g. stray
padding-top: 2px, off-grid margin, forbidden char in UI copy) → fix the code. - Intentional spec-approved optical exception or legacy compatibility regex → append
/* spec-whitelist: §<section> <reason> */(CSS) or// spec-whitelist: <reason>(JS/TS) on that exact line.
- Real bug (e.g. stray
- Run
npm run buildandnpm run test:spec(when configured) until exit code is0with 0 violations.
Maintenance Rule (Never Hit the Same Bug Twice)
Whenever a new class of design-spec regression is discovered during QA or review, do not only patch the CSS — add a corresponding check in design-tokens.json, scripts/lint-design.mjs, or tests/design-spec-audit.spec.ts before closing the fix.
Syncing Skill Updates to GitHub
Whenever this skill (SKILL.md or anything under resources/ / scripts/) is improved or extended, immediately run:
~/.gemini/config/skills/design-spec-guard/scripts/sync.sh "<brief summary of the update>"
so Antigravity, Codex (symlinked), and the GitHub remote remain permanently in sync.