Communitygithub.com

design-spec-guard

Scaffold and enforce automated design-spec guardrails (design-tokens.json, static CSS/copy linter, Playwright runtime DOM pixel audit, build gate, and project AGENTS.md) in any frontend or prototype project. Use whenever a project establishes or updates a design specification, when the user asks to prevent spacing/radius/typography/theme/copy regressions permanently, or when invoking design-spec-guard.

¿Qué es design-spec-guard?

design-spec-guard is a Claude Code agent skill that scaffold and enforce automated design-spec guardrails (design-tokens.json, static CSS/copy linter, Playwright runtime DOM pixel audit, build gate, and project AGENTS.md) in any frontend or prototype project. Use whenever a project establishes or updates a design specification, when the user asks to prevent spacing/radius/typography/theme/copy regressions permanently, or when invoking design-spec-guard.

Compatible con✓Claude Code✓Codex CLI~Cursor✓Antigravity✓Gemini CLI
npx skills add https://github.com/shengbosun9-rgb/design-spec-guard/tree/HEAD

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

¿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/:

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.json to <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)
    • allowedRadiusPx
    • minFontSizePx & minHitTargetPx (e.g. 44 on mobile touch apps, 32/36 on desktop SaaS if specified)
    • forbiddenChars & forbiddenCopy (only what this project's spec forbids)
    • cssPaths, sourcePaths, ignoreFiles
    • isolatedThemeScope (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.mjs to <project-root>/scripts/lint-design.mjs.
  • Add "lint:design": "node scripts/lint-design.mjs" to package.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 wire npm run lint:design into pre-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.ts into 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" to package.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

5. Write Project AGENTS.md

  • Merge resources/AGENTS.ui-section.template.md into the project root AGENTS.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

  1. Run npm run lint:design.
  2. 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.
  3. Run npm run build and npm run test:spec (when configured) until exit code is 0 with 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.

Skills relacionados