AI Fixes & the Fix-Pattern Database
Generate CSS fixes for visual regressions, verify them in a sandbox before suggesting, and teach Frontguard from the fixes you accept.
AI Fixes & the Fix-Pattern Database
Every competitor stops at "here's what changed." Frontguard goes further: here's what changed, here's a fix, and I re-rendered the page with the fix applied to confirm it works. Over time it learns which fixes you accept and reuses them.
Generating fixes
Set generateFixes: true to have the AI produce a minimal CSS patch for each
regression. Fixes target the highest-reliability categories — overflow/truncation,
spacing, responsive breakpoints, z-index/stacking, and color/opacity.
export default {
baseUrl: 'http://localhost:3000',
ai: { provider: 'openai', model: 'gpt-4o' },
generateFixes: true,
};The suggested fix appears in the console, HTML, and PR reports as a copy-pasteable
diff block.
Verifying fixes in a sandbox
A suggested fix is only useful if it actually works. With verifyFixes: true,
Frontguard:
- Applies the generated CSS patch in a sandbox,
- Re-renders the page with the patch injected,
- Re-compares the result against the baseline,
- Marks the fix ✅ Verified if it lands within threshold, or ⚠️ Unverified otherwise.
export default {
// …
generateFixes: true,
verifyFixes: true,
fixSandbox: 'local', // 'local' | 'daytona'
};| Sandbox | Description |
|---|---|
local | Injects the patch with a local Playwright page and re-renders. No external services. Default. |
daytona | Remote sandbox verification (requires a Daytona account). |
Verified fixes are visually distinct in reports — a green "Verified — re-rendered within threshold" badge — so reviewers know the fix was actually proven, not just suggested.
The fix-pattern database
Frontguard keeps a local SQLite database (via the optional better-sqlite3
dependency) of the fixes you accept and reject. This is the compounding moat:
the more fixes you accept, the more often Frontguard can reuse a known-good
pattern instead of asking the AI again.
frontguard accept-fix <id> # positive training signal
frontguard reject-fix <id> # negative signalfrontguard export-patterns > fix-patterns.jsonHow the learning loop works:
- Each accepted fix is stored with a context hash (category + route + viewport + diff magnitude).
- Before calling the AI, the pipeline probes the database for an accepted pattern matching the current context.
- A pattern is reused once it has been accepted ≥3 times with no rejections — so a one-off accept never overrides the model.
- Verified fixes are recorded as accepted automatically.
The fix-pattern database needs the optional native dependency:
npm install better-sqlite3. Without it, fix generation and verification still
work — only the learning/reuse layer is disabled.
AI Analysis
Enable AI-powered regression explanations with OpenAI or Anthropic. Understand why visual changes happened.
Accessibility Audits
Run axe-core accessibility checks in the same render pass as your visual tests — contrast, alt text, target size, focus, and heading order — surfaced in every report.