Visual Verification
ptb verify catches visual drift between your code and the Figma design by comparing a screenshot of your running component against the thumbnail captured during ptb scan. No live Figma connection required at verify time.
How it Works
- Scan captures a reference.
ptb scansaves a thumbnail for each component to.ptb/thumbnails/. This is the ground truth. - Verify screenshots your implementation. With Storybook running locally,
ptb verifyuses Playwright to capture the component at its default variant. - Pixel diff. The two images are compared and a similarity score (0.0–1.0) is returned. A score ≥ 0.90 passes. An annotated diff image highlights exactly where the discrepancy is.
CLI Usage
ptb verify component Button # verify a single component
ptb verify component . # verify all implemented components
ptb verify component Button --story Primary # target a specific Storybook story
ptb verify component Button --fresh-figma # re-fetch screenshot live from Figma
Storybook must be running on
localhost:6006(or the port configured inptb.config.json) for the CLI verify to work.
MCP Usage
From your AI IDE chat:
run_verify({ name: "Button" })
run_verify({ name: "Button", story: "Primary" })
The AI can read the diff image and adjust styles to fix failing areas without you describing what's wrong.
Interpreting Results
| Score | Status | Typical cause |
|---|---|---|
| ≥ 0.90 | Pass | Implementation matches design |
| 0.75–0.89 | Warning | Minor spacing or color deviation |
| < 0.75 | Fail | Significant structural difference |
The annotated diff image is saved to .ptb/verify/<component-name>.diff.png after each run.
Tips
- Run
ptb scanagain if the Figma design has changed since you last scanned — the thumbnail needs to be fresh. - Storybook stories generated by
ptb generate-componentsare pre-wired to match the Figma default variant, making verification accurate out of the box. - Use
ptb verify component .after bulk implementing all components to catch regressions before stamping.
Next Steps
Once implementation passes verification, stamp it with State & Freshness Commands.