A powerful visual comparison tool designed specifically for AI coding agents to achieve pixel-perfect website matching. Born from real-world experience building 1:1 website clones with AI assistance.
- Pixel-Perfect Comparison: Advanced image comparison using Puppeteer, Sharp, and Pixelmatch
- Smart Scroll Detection: Automatically finds optimal scroll positions for best matching
- Continuous Monitoring: Real-time visual regression testing during development
- AI Agent Integration: Purpose-built for Claude Code, Cursor AI, and other AI coding tools
- CLI & API: Both command-line interface and programmatic access
- Detailed Reporting: Comprehensive similarity scores and visual diff generation
npm install -g visual-matcher-ainpm install visual-matcher-aivisual-matcher compare -u http://localhost:3000 -r ./reference.pngvisual-matcher find-best -u http://localhost:3000 -r ./reference.png --start 0 --end 1500 --step 50visual-matcher watch -u http://localhost:3000 -r ./reference.png --interval 15visual-matcher compare \
--url http://localhost:3000 \
--reference ./target-design.png \
--output ./results \
--width 1920 \
--height 880 \
--scroll-y 900 \
--threshold 0.1const { compareScreenshots } = require('visual-matcher-ai');
const result = await compareScreenshots('http://localhost:3000', './reference.png', {
viewport: { width: 1920, height: 880 },
scrollY: 900
});
console.log(`Similarity: ${result.similarity}%`);const { VisualMatcher } = require('visual-matcher-ai');
const matcher = new VisualMatcher({
viewport: { width: 1920, height: 880 },
threshold: 0.1
});
// Find best scroll position
const bestMatch = await matcher.findOptimalScrollPosition(
'http://localhost:3000',
'./reference.png',
{ startY: 0, endY: 2000, step: 50 }
);
// Continuous monitoring
await matcher.continuousMatch('http://localhost:3000', './reference.png', {
interval: 15000,
onUpdate: (result) => {
console.log(`Current similarity: ${result.similarity}%`);
if (result.similarity > 95) {
console.log('π― Target achieved!');
}
}
});
await matcher.close();I'm building a website clone and need to achieve 95%+ visual similarity.
1. Start visual monitoring:
```bash
visual-matcher watch -u http://localhost:3000 -r ./target.png --interval 10- Make incremental changes to match the reference
- Monitor similarity scores in real-time
- Focus on major differences (>5% improvement) before micro-optimizations
### Cursor AI Integration
```javascript
// Add to your workspace settings
{
"visualMatcher.autoStart": true,
"visualMatcher.reference": "./design-reference.png",
"visualMatcher.target": "http://localhost:3000",
"visualMatcher.threshold": 95
}
# Add to your Dockerfile
RUN npm install -g visual-matcher-ai
# In your dev container
EXPOSE 3000
CMD ["visual-matcher", "watch", "-u", "http://localhost:3000", "-r", "/workspace/reference.png"]# 1. Find optimal viewport and scroll position
visual-matcher find-best -u https://target-site.com -r ./downloaded-reference.png
# 2. Start continuous monitoring during development
visual-matcher watch -u http://localhost:3000 -r ./reference.png --scroll-y 900
# 3. Build and iterate until 95%+ similarity achievedconst matcher = new VisualMatcher({
viewport: { width: 1200, height: 800 }
});
// Test specific component sections
const headerMatch = await matcher.compareImages('./header-reference.png', './current-header.png');
const heroMatch = await matcher.compareImages('./hero-reference.png', './current-hero.png');
console.log(`Header: ${headerMatch.similarity}%, Hero: ${heroMatch.similarity}%`);{
headless: true, // Run browser in headless mode
viewport: { width: 1920, height: 1080 }, // Browser viewport size
threshold: 0.1, // Pixelmatch sensitivity (0-1)
includeAA: false // Include anti-aliasing in comparison
}{
scrollY: 900, // Specific scroll position
fullPage: false, // Full page screenshot
outputPath: './screenshot.png', // Custom screenshot path
diffPath: './diff.png' // Custom diff image path
}- 95-100%: Pixel-perfect match β¨
- 85-94%: Excellent match β
- 70-84%: Good match, minor tweaks needed
β οΈ - <70%: Major structural differences β
- Start with major layout issues (backgrounds, positioning)
- Fix structural problems before micro-optimizations
- Use proper viewport and scroll position from reference
- Focus on 5-10% improvements rather than 1-2% tweaks
- Test at optimal scroll position for accurate comparison
# Install Chromium dependencies on Linux
apt-get install -y chromium-browser
# Docker Alpine
apk add chromium// Limit concurrent operations
const matcher = new VisualMatcher({ headless: true });
// Always close matcher when done
await matcher.close();// Increase timeout for slow sites
await page.goto(url, {
waitUntil: 'networkidle0',
timeout: 60000
});We welcome contributions! This tool was created from real experience building pixel-perfect clones with AI coding agents.
git clone https://github.com/codebruinc/visual-matcher-ai.git
cd visual-matcher-ai
npm install
npm run testnpm run example # Run CodeBru exampleMIT Β© 2025 CodeBru, Inc.
This tool was battle-tested while building a 1:1 clone of CodeBru.com, achieving 86% similarity through systematic optimization. Key learnings:
- Proper viewport matching is crucial (880px vs 1080px made huge difference)
- Optimal scroll position discovery improved accuracy by 40%
- Continuous monitoring prevented regressions during development
- Focus on major fixes first - 5% improvements vs 1% micro-optimizations
Built with β€οΈ for the AI coding community by CodeBru.com. Happy cloning! π