Why URL Scrapers Fail at Generating DESIGN.md (and How We Built a 100% Local Extractor in 280 Lines of Zero-Dep JS)
If you have used Claude Code, Cursor, Windsurf, or Google Stitch to build a frontend this year, you know the pain: without an explicit design contract, every AI coding agent drifts toward the exact same generic dark-purp
If you have used Claude Code, Cursor, Windsurf, or Google Stitch to build a frontend this year, you know the pain: without an explicit design contract, every AI coding agent drifts toward the exact same generic dark-purple SaaS template.
That is why DESIGN.md (popularized by Google Stitch and the 130k+ star awesome-design-md movement) caught on so fast. Drop a plain Markdown file with semantic color tokens, typography scale, border radii, and strict Do/Don't rules into your repo root, and your coding agent immediately stops guessing.
The Problem With Web-Based DESIGN.md Extractors
Most DESIGN.md generators ask you to paste a public URL into a web form. That works for stripe.com, and fails almost everywhere real engineers actually work:
- Authenticated dashboards & internal tools โ a remote scraper hits a login redirect instead of your app.
-
localhost:3000& VPN staging builds โ remote crawlers cannot reach your local machine. - Client confidentiality โ sending pre-release client pages to a third-party scraping server is a non-starter.
-
No WCAG guardrails โ dumping raw hex codes without checking
inkvscanvasoron-primaryvsprimarycontrast ratios causes AI agents to generate unreadable buttons.
How We Solved It 100% Locally Inside the Browser
We just shipped SpecPeek v1.1.0 (activeTab-only, zero host_permissions, zero telemetry) plus a free client-side DESIGN.md Generator that runs entirely in your browser tab.
Here is the exact 3-step heuristic we use to turn messy computed DOM styles into a clean semantic DESIGN.md contract without calling any LLM or backend API:
1. Separate Canvas, Ink, and Interactive Accents During the DOM Walk
Instead of throwing every hex value into one flat bucket, we seed canvas from document.body / document.documentElement, track text colors separately for ink and muted, and weight button, a, and [role="button"] colors for primary and secondary:
const isInteractive =
tag === 'button' || tag === 'a' || el.getAttribute('role') === 'button';
if (bgC && bgC.a > 0.05) {
const hex = toHex(bgC);
bgCounts.set(hex, (bgCounts.get(hex) || 0) + 1);
if (isInteractive) accentCounts.set(hex, (accentCounts.get(hex) || 0) + 3);
}
2. Detect Dark vs Light Polarity & Compute Real W3C WCAG 2.1 Contrast
Using W3C relative luminance (0.2126*R + 0.7152*G + 0.0722*B), we classify theme: dark | light, pick the highest-frequency text token passing >= 4.5:1 against canvas as ink, and automatically select #ffffff or #0f172a for on-primary:
const isDark = colorLuminance(canvas) < 0.28;
const onPrimary =
safeContrast('#ffffff', primary) >= safeContrast('#0f172a', primary)
? '#ffffff'
: '#0f172a';
3. Emit Both YAML Front Matter + Strict Agent Do/Don't Rules
LLMs follow constraints far better when machine-readable tokens sit right above human-readable guardrails:
---
version: 1.0
name: "Linear Dark"
theme: dark
colors:
primary: "#6366f1"
on-primary: "#ffffff"
canvas: "#0b0d12"
surface: "#141824"
hairline: "#252c40"
ink: "#f8fafc"
muted: "#94a3b8"
spacing_base: 8px
radii: ["8px", "12px", "20px", "9999px"]
---
Try Both Right Now (Free, No Account Required)
-
Free Online
DESIGN.mdGenerator (paste CSS/Tailwind or customize 6 starter themes with live WCAG contrast checks): ๐ https://specpeek.kintolabs.com/tools/design-md-generator/ -
SpecPeek Browser Extension (1-click local inspection on any live site,
localhost, or logged-in dashboard โ Free core, optional $19 one-time Pro): ๐ Install SpecPeek on Microsoft Edge Add-ons ยท SpecPeek Homepage (Firefox AMO review in progress)
If you use DESIGN.md with Claude Code or Cursor, what sections have made the biggest difference in keeping generated UI on-brand? Drop a comment below!
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.