{
  "markdown": "<div align=\"center\">\n\n<picture>\n  <source media=\"(prefers-color-scheme: dark)\" srcset=\"assets/logo-dark.svg\">\n  <img src=\"assets/logo-light.svg\" alt=\"pixelpact\" width=\"420\">\n</picture>\n\n**Your coding agent cannot see the page it just built. pixelpact measures it against the\nreference and hands back numbers.**\n\n[![CI](https://github.com/jamalkamaladdin/pixelpact/actions/workflows/ci.yml/badge.svg)](https://github.com/jamalkamaladdin/pixelpact/actions/workflows/ci.yml)\n[![npm](https://img.shields.io/npm/v/pixelpact.svg?color=0b7285)](https://www.npmjs.com/package/pixelpact)\n[![node](https://img.shields.io/node/v/pixelpact.svg?color=0b7285)](https://nodejs.org)\n[![license](https://img.shields.io/github/license/jamalkamaladdin/pixelpact?color=0b7285)](./LICENSE)\n\n</div>\n\nA coding agent writes the CSS and says it is done. It never sees the result. Nothing hands it a\nnumber, so the loop cannot close: the agent guesses, you open the page, you send it back, it\nguesses again. Every round costs you the one thing the agent was supposed to save.\n\nThe same gap exists without an agent, when a teammate says a section is finished and nobody in\nthe room has a measurement. The difference is that a person can at least look.\n\npixelpact reads the reference page and writes down what it actually renders: sizes, colors,\nspacing, typography, hover and focus states, animation keyframes, design tokens. That file is\nthe **contract**. Point pixelpact at the implementation and it answers with one line per\nproperty that drifted, which is precisely what an agent can act on.\n\n```bash\nnpx pixelpact extract https://reference.example.com -o contract.json\nnpx pixelpact check contract.json http://localhost:3000\n```\n\n## Works with\n\n<div align=\"center\">\n\n| **MCP clients** | **Playwright** | **GitHub Actions** | **Any framework** | **Figma** |\n| :-------------: | :------------: | :----------------: | :---------------: | :-------: |\n| Claude Code, Cursor, anything that speaks stdio MCP | the engine it drives | one comment on the pull request | it reads the DOM, not your stack | a frame as the reference, when you want one |\n\n*If a browser can render it, pixelpact can measure it.*\n\n</div>\n\n## For coding agents\n\nAn agent that writes UI code cannot tell whether it succeeded. `pixelpact-mcp` gives it the\nmeasurement, so the loop closes without a person in the middle: extract the contract once,\nthen let the agent check its own work, read the deviation list, fix, and check again.\n\n```jsonc\n// .mcp.json\n{\n  \"mcpServers\": {\n    \"pixelpact\": { \"command\": \"npx\", \"args\": [\"-y\", \"pixelpact-mcp\"] }\n  }\n}\n```\n\nTools exposed: `extract_contract`, `check_implementation`, `diff_pixels`,\n`read_contract_summary`.\n\n## Why this is not visual regression testing\n\nPercy, Chromatic, Applitools, BackstopJS and Pixeleye all compare your page against a baseline\nthat you approved earlier. That model works once the page already looks right and you want to\nkeep it that way. While you are still building toward a design, there is no baseline to\ncompare with, and the first run of a regression tool simply records whatever you produced.\n\n|                              | Visual regression tools            | pixelpact                          |\n| ---------------------------- | ---------------------------------- | ---------------------------------- |\n| Compares against             | a snapshot you approved earlier    | the reference design itself        |\n| Useful when                  | the UI is already correct          | the UI is being built              |\n| First run on a new page      | records, cannot judge              | measures against the reference     |\n| Answer you get               | an image diff to inspect by eye    | a value per property, with a delta |\n| Fits an autonomous agent     | needs a human to approve the diff  | the numbers close the loop         |\n\nThe two models are complementary. Use a regression tool to keep a finished page finished, and\npixelpact to get it finished in the first place.\n\n## Problems pixelpact solves\n\n| Without pixelpact | With pixelpact |\n| ----------------- | -------------- |\n| ❌ A coding agent writes CSS, declares it done, and a person has to open the page to find out that it is not. | ✅ The agent calls the MCP server, reads the deviations, fixes them and checks again. No person in the middle. |\n| ❌ Someone says the section is finished, you disagree, and neither of you has a number. The louder opinion wins. | ✅ Every value in the reference is asserted against your page. What failed is listed with expected, actual and the difference. |\n| ❌ A regression tool has nothing to compare a brand new page against, so its first run records whatever you happened to build. | ✅ The reference is the baseline from the first minute. Nothing has to be approved before the tool is useful. |\n| ❌ Hover, focus and animation values are almost never reviewed, because checking them by hand is slow and boring. | ✅ They are part of the contract, so they are measured on every run like any other value. |\n| ❌ An image diff tells you that something changed and leaves you to hunt for what. | ✅ Deviations name the element, the property, the expected value and the measured one. |\n| ❌ The design lives in a file nobody opens during code review. | ✅ The contract is committed JSON, so a pull request shows exactly which values moved. |\n\n## Install\n\n```bash\npnpm add -D pixelpact playwright\npnpm exec playwright install chromium\n```\n\n`playwright` is a peer dependency, so the browser download stays under your control and a\nproject that already has Playwright installs nothing extra. Node 22.12 or newer is required.\n\n## Quickstart\n\n**1. Extract the contract from the reference.**\n\n```bash\nnpx pixelpact extract https://reference.example.com \\\n  --selector \"main\" \\\n  --viewport desktop,mobile \\\n  --screenshots .pixelpact/shots \\\n  -o contract.json\n```\n\n**2. Measure your implementation.**\n\n```bash\nnpx pixelpact check contract.json http://localhost:3000 --viewport desktop\n```\n\n**3. Fix what it reports, then run it again.** The command exits `0` when everything is inside\ntolerance and `1` when it is not, so it drops straight into a script or a CI job.\n\n## What a contract looks like\n\nA contract is plain JSON, readable and diffable, with no proprietary format and no service\nbehind it.\n\n```jsonc\n{\n  \"version\": 1,\n  \"source\": { \"type\": \"url\", \"value\": \"https://reference.example.com\" },\n  \"root\": \"main\",\n  \"extractedAt\": \"2026-09-06T01:20:44.812Z\",\n  \"viewports\": [{ \"name\": \"desktop\", \"width\": 1440, \"height\": 900 }],\n  \"tokens\": { \"--brand-600\": \"rgb(11, 114, 133)\" },\n  \"keyframes\": { \"fade-up\": [{ \"offset\": \"0%\", \"css\": \"opacity: 0\" }] },\n  \"byViewport\": {\n    \"desktop\": {\n      \"documentHeight\": 4218,\n      \"elements\": [\n        {\n          \"selector\": \"main > header > a.cta\",\n          \"tag\": \"a\",\n          \"text\": \"Get started\",\n          \"box\": { \"x\": 120, \"y\": 32, \"w\": 148, \"h\": 44 },\n          \"styles\": {\n            \"background-color\": \"rgb(11, 114, 133)\",\n            \"font-size\": \"16px\",\n            \"border-radius\": \"8px\"\n          },\n          \"hover\": { \"background-color\": \"rgb(8, 90, 105)\" },\n          \"focus\": { \"outline\": \"2px solid rgb(11, 114, 133)\" }\n        }\n      ]\n    }\n  }\n}\n```\n\nBecause it is a file, you can commit it, review it in a pull request, hand it to another\ndeveloper, or hand it to an agent.\n\n## What a check prints\n\n<!-- SAMPLE:CHECK -->\n\n```text\npixelpact check  FAILED\n  target    http://localhost:4173/impl.html\n  reference http://localhost:4173/ref.html\n  viewport  desktop 1440x900\n  elements  14 matched, 0 missing of 14\n  checks    1056 passed, 10 failed (99.1% of 1066)\n\ndeviations (10)\nSELECTOR          PROPERTY                  EXPECTED                ACTUAL                  DIFF\nbody > main > h1  font-size                 48px                    44px                    4px\nbody > main > a   box.width                 117.75px                109.75px                8px\nbody > main > a   padding-right             24px                    20px                    4px\nbody > main > a   padding-left              24px                    20px                    4px\nbody > main > a   background-color          rgb(11, 114, 133)       rgb(37, 99, 235)        60.1 (color)\nbody > main > a   border-top-left-radius    8px                     4px                     4px\nbody > main > a   border-top-right-radius   8px                     4px                     4px\nbody > main > a   border-bottom-left-ra...  8px                     4px                     4px\nbody > main > a   border-bottom-right-r...  8px                     4px                     4px\nbody > main > a   focus.outline             rgb(11, 114, 133) s...  rgb(37, 99, 235) so...  differs\n```\n\n<!-- /SAMPLE:CHECK -->\n\nThat is a real run against two copies of one page with four declarations changed. Four edits\nproduce ten measured deviations, because padding moves the box width and one `border-radius`\nshorthand sets four corners. Run the same check against the reference itself and all 1066\nassertions pass, which is the property that matters: a passing check has to mean something.\n\nAdd `--json` to get the same report as a data structure, which is what CI jobs and agents read.\n\n## What a side by side run shows\n\n`check` says which values moved. `diff` says how many pixels moved. Neither tells a person\nwhere to look. `side` splits both pages into sections, puts them next to each other, and boxes\nwhat differs.\n\n```bash\nnpx pixelpact side https://reference.example.com http://localhost:3000 --widths 1440,390\n```\n\n```text\n#   SECTION   WIDTH   VERDICT  DIFF\n01  hero      1440px  PASS     0.000%\n02  features  1440px  FAIL     0.675%\n  .pixelpact/side/1440/02-features.png\n03  pricing   1440px  PASS     0.000%\n04  foot      1440px  FAIL     1.265%\n  .pixelpact/side/1440/04-foot.png\n```\n\n![One section compared side by side, differences boxed in red](assets/side-example.png)\n\nThat is a real run against the two files in [`examples/side`](./examples/side), which are\ncopies of one page where the card gap and the corner radius were changed. Reproduce it with:\n\n```bash\nnpx pixelpact side \"file://$PWD/examples/side/reference.html\" \\\n                   \"file://$PWD/examples/side/implementation.html\" --widths 1440\n```\n\nThis is the command to run before telling anyone that a page is finished.\n\n## Features\n\n<table>\n<tr>\n<td valign=\"top\" width=\"33%\"><strong>Contract from the reference</strong><br><br>Reads the page you are building toward and writes down every value it renders. Nothing to approve first.</td>\n<td valign=\"top\" width=\"33%\"><strong>Numbers, not opinions</strong><br><br>Each deviation carries the expected value, the measured value and the difference between them.</td>\n<td valign=\"top\" width=\"33%\"><strong>States, not just layout</strong><br><br>Interactive elements are hovered and focused, and only the properties that actually change are stored.</td>\n</tr>\n<tr>\n<td valign=\"top\"><strong>Tokens and keyframes</strong><br><br>Custom properties on the root element and named animation keyframes travel inside the contract.</td>\n<td valign=\"top\"><strong>Pixel comparison</strong><br><br>When every value passes and it still looks wrong, compare the screenshots and get a percentage.</td>\n<td valign=\"top\"><strong>Agent ready</strong><br><br>An MCP server exposes the same measurements, so a coding agent can close its own loop.</td>\n</tr>\n<tr>\n<td valign=\"top\"><strong>Pull request checks</strong><br><br>A composite Action runs the check and keeps one comment on the pull request up to date.</td>\n<td valign=\"top\"><strong>Plain JSON</strong><br><br>The contract is a file you can read, diff and review. No service, no account, nothing to log into.</td>\n<td valign=\"top\"><strong>Framework agnostic</strong><br><br>It measures the rendered DOM, so React, Vue, Svelte and hand written HTML are all the same to it.</td>\n</tr>\n</table>\n\n## Commands\n\n| Command                              | What it does                                                  |\n| ------------------------------------ | ------------------------------------------------------------- |\n| `pixelpact extract <url>`            | Reads the reference and writes a contract file                 |\n| `pixelpact check <contract> <url>`   | Measures an implementation, prints deviations, sets exit code  |\n| `pixelpact diff <contract> <url>`    | Pixel comparison against the screenshot stored in the contract |\n| `pixelpact side <reference> <url>`   | Section by section side by side images with the differences boxed |\n\nShared flags cover the browser context (`--viewport`, `--selector`, `--wait`, `--timeout`,\n`--locale`, `--timezone`, `--channel`, `--headful`), the output (`--out`, `--json`,\n`--quiet`), and the parts of extraction you may want to cap (`--max-elements`, `--max-states`,\n`--mask`). Run `pixelpact <command> --help` for the full list.\n\n### Exit codes\n\n| Code | Meaning                                                        |\n| ---- | -------------------------------------------------------------- |\n| `0`  | Everything inside tolerance                                     |\n| `1`  | Deviations found, or the pixel threshold was exceeded           |\n| `2`  | Usage error, for example a bad flag or a contract file that is missing |\n| `3`  | Runtime failure, for example no browser available or the page would not load |\n\n## Programmatic use\n\n```ts\nimport { extract, check, formatCheckReport, writeContract } from 'pixelpact-core'\n\nconst contract = await extract({\n  url: 'https://reference.example.com',\n  selector: 'main',\n  screenshotDir: '.pixelpact/shots',\n})\nawait writeContract('contract.json', contract)\n\nconst report = await check(contract, { url: 'http://localhost:3000' })\n\nconsole.log(formatCheckReport(report, { color: true }))\nif (!report.ok) process.exitCode = 1\n```\n\nEverything is typed, and the contract and report shapes are validated at the boundary, so a\nmalformed file fails with a readable message instead of a stack trace.\n\n## In CI\n\nThe Action measures a preview deployment against the contract committed in the repository and\nkeeps a single pull request comment up to date instead of adding one per push.\n\n```yaml\n- uses: jamalkamaladdin/pixelpact/action@v0\n  with:\n    contract: contract.json\n    url: ${{ steps.preview.outputs.url }}\n    viewport: desktop\n    tolerance: 1\n```\n\nIt needs `permissions: pull-requests: write` and no secret beyond the automatic\n`GITHUB_TOKEN`. Every input, every output and a complete workflow are in\n[action/README.md](./action/README.md).\n\n## Reading a Figma frame\n\n`extract` recognises a Figma url and reads the frame through the REST API. No browser is\nlaunched for this step.\n\n```bash\nexport FIGMA_TOKEN=figd_...\nnpx pixelpact extract \"https://www.figma.com/design/KEY/Name?node-id=12-345\" -o contract.json\nnpx pixelpact check contract.json http://localhost:3000\n```\n\nA Figma layer has no CSS selector, so a Figma contract binds to your markup through\n`data-contract` attributes. Name the element after the layer and matching stops depending on\nhow the design happened to nest its frames:\n\n```html\n<a class=\"btn btn-primary\" data-contract=\"Hero/CTA\">Get started</a>\n```\n\nAnything with no match is reported as missing rather than guessed from tag names.\n\nPublished styles come across as tokens: a color style as its color, a text style as a css font\nshorthand such as `600 60px/72px Geist`, an effect style as a box shadow. A fill that is a\ngradient or an image has no single css value, so it is left out and named in the warnings\nrather than approximated.\n\n## How it works\n\n1. Playwright opens the reference at each requested viewport, waits for fonts, network and\n   paint to settle, and dismisses cookie overlays.\n2. A single function is evaluated inside the page. It walks the DOM under your root selector\n   and records the computed style of every visible element, plus custom properties, keyframes,\n   and the geometry of each box.\n3. Interactive elements are hovered and focused, and only the properties that actually change\n   are stored, so a contract stays small enough to read.\n4. Checking repeats step 2 against your implementation, matches elements by\n   `data-contract` attribute, then by selector, then by tag and text, and compares property by\n   property. Lengths use a pixel tolerance, colors use a perceptual distance, and animations\n   are compared by name and timing rather than by string equality.\n\n## Repository layout\n\n| Package                                | Published as       | What it is                      |\n| -------------------------------------- | ------------------ | ------------------------------- |\n| [`packages/core`](./packages/core)     | `pixelpact-core`  | Extraction, checking, reporting |\n| [`packages/cli`](./packages/cli)       | `pixelpact`        | The `pixelpact` command         |\n| [`packages/mcp`](./packages/mcp)       | `pixelpact-mcp`   | MCP server for coding agents    |\n| [`action`](./action)                   | used from GitHub   | Action for pull request checks  |\n\n## FAQ\n\n**How does an agent use it?** Install `pixelpact-mcp`, point the MCP client at it, extract the\ncontract once, then let the agent call `check_implementation` after every edit and read the\ndeviation table it gets back.\n\n**How is this different from Percy or Chromatic?** They compare your page against a snapshot\nyou approved earlier, which assumes the page is already right. pixelpact compares it against\nthe reference, which is what you actually have while you are still building. The two fit\ntogether: pixelpact to get the page correct, a regression tool to keep it that way.\n\n**Do I need a baseline?** No. The reference is the baseline, and that is the entire point.\n\n**My markup does not match the reference structure. Will anything match?** Element matching\ntries the `data-contract` attribute first, then the selector, then the tag and its text. Put\n`data-contract=\"hero-cta\"` on your element and matching stops depending on how the reference\nhappened to nest its divs.\n\n**The page has content that changes on every load. Will a check ever pass?** Mask it.\n`--mask \".carousel\"` keeps a region out of the pixel comparison, and `--max-elements` stops a\nlong page from producing a contract nobody can read.\n\n**Which browsers?** Chromium through Playwright. Running a matrix across engines is out of\nscope on purpose: this tool measures agreement with a design, not differences between browsers.\n\n**Does a passing check mean the page is correct?** It means every value in the contract matched\ninside tolerance. Elements that exist in your page but not in the reference are not flagged,\nbecause the contract only describes what the reference contains. Run `diff` as well when\nnothing extra is allowed.\n\n## Status\n\nEverything described above is built and every number shown came from a real run: extraction\nfrom a live page and from Figma, checking, the pixel diff, the side by side images, the MCP\nserver and the Action.\n\nVersion 0.3. Settled enough to use, not settled enough to promise: the contract format will\ngain fields before 1.0. If a value you need is missing from it, open an issue and say which\none, because that is the fastest way for it to appear.\n\n## Contributing\n\nDevelopment setup, the commands, and the pull request flow are in\n[CONTRIBUTING.md](./CONTRIBUTING.md). Security reports go through\n[SECURITY.md](./SECURITY.md).\n\n## License\n\n[MIT](./LICENSE) © Jamal Kamaladdin\n",
  "bytes": 19453,
  "sha": "1075ea594ee216624ba3a2494ade544c52811a2bb789514a468c6dd44f5ec57b",
  "repo_slug": "jamalkamaladdin/pixelpact",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_jamalkamaladdin_pixelpact_2bb75952/readme"
}