match-reference
AGENTS.md1 starsChanged 2 months agoMITView on GitHub
Cross-agent instructions (Codex, Cursor, and any tool that reads AGENTS.md). Claude Code reads SKILL.md instead; both describe the same workflow over the same scripts in scripts/ (plain Node ≥ 18; npm install && npx playwright install chromium). The user wants to rebuild a frontend (near) pixel-identical to a visual reference: a design mockup, a screenshot of another site/app, a photo of a UI, an AI-generated concept, or an existing page to clone. Also usable for visual regression (diffing two of…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 32,671 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- match-referenceSkill
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Don't judge the match by eye.
- Very specific: line 19
Look for the reference first: an attached image, a path to a PNG/JPG, or a URL to clone (screenshot it with capture.mjs).
≈ “Common” is an estimate: at least 1 in 5 of the 41,581 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
match-reference — agent instructions
Cross-agent instructions (Codex, Cursor, and any tool that reads AGENTS.md).
Claude Code reads SKILL.md instead; both describe the same workflow over the
same scripts in scripts/ (plain Node ≥ 18; npm install && npx playwright install chromium).
When to use this
The user wants to rebuild a frontend (near) pixel-identical to a visual reference: a design mockup, a screenshot of another site/app, a photo of a UI, an AI-generated concept, or an existing page to clone. Also usable for visual regression (diffing two of the user's own pages). Not for functional testing or backend work.
Don't judge the match by eye. Measure it and act on a per-region fix list.
Input: the reference (recommended, not blocking)
Look for the reference first: an attached image, a path to a PNG/JPG, or a URL to
clone (screenshot it with capture.mjs). If missing, ask once. If the user has
none (visual regression), use one page as the golden reference and say the diff is
relative, not toward a design target.
The loop
- Golden reference (immutable). Save the target as a fixed PNG, e.g.
reference/target.png. Never modify it. - Screenshot your build, with the DOM map:
node scripts/capture.mjs <url> shots/mine.png --match reference/target.png --dom shots/mine.dom.json--matchshoots at the reference's exact pixel size;--domdumps every element's box + computed CSS so the analyzer can name what's wrong. It also pins viewport/scale/locale/timezone/light/reduced-motion and kills animations (add anhtml.visual-testCSS rule to zero animations/transitions/caret). - Analyze — get the fix list:
It prints a per-region fix list — each zone tagged colour / spacing / missing / text, with a perceptual colour delta (ΔE) + direction + target hex, the DOM element + its computed CSS, and a hypothesis of the cause — plus an overall diff % and SSIM, and a convergence verdict. It writesnode scripts/analyze.mjs reference/target.png shots/mine.png \ --out out --regions shots/mine.dom.json --history out/history.jsonout/analyze.json,out/diff.png, and oneout/regions/rNN.pngstrip (reference | your build | diff) per region. - LOOK, then fix. Open the region strips it lists (view the PNGs) — the picture shows what numbers can't. Fix the biggest region first, trusting the DOM element + CSS it points at.
- Re-capture, re-analyze against the same
--historyfile. TheCONVERGEline says improved / regressed / stalled / CLOSE ENOUGH. Stop at CLOSE ENOUGH (or when the remaining regions are content you shouldn't copy).
Different sizes, mobile, imprecise references
analyze.mjs needs both images at the same pixel size:
- Exact size:
capture.mjs ... --match reference/target.png. - Can't re-shoot:
resize.mjs <in> <out> <w> [h](retina @2x → give @1x width). - Mobile:
capture.mjs ... --device "iPhone 13"(any Playwright device). - Imprecise reference (photo of a screen, lossy/skewed): add
--tolerant,--align 8(finds+reports a small global shift),--mask "x,y,w,h;..."to ignore un-reproducible content. Treat the fix list as a guide, don't chase 0%.
Primitives
compare.mjs <ref> <cand> <diff.png> (plain % + pink diff; --engine odiff fast
path for huge pages), crop.mjs, resize.mjs — for manual work.
Golden rule: content beats pixels
Where the reference has mistakes or choices not to copy (wrong labels, extra
elements, fake data, an unreproducible photo), keep your version. The goal is the
look, not cloning the mockup's mistakes. --mask those zones or ignore them.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

