Guides

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.

frontguard.config.ts
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:

  1. Applies the generated CSS patch in a sandbox,
  2. Re-renders the page with the patch injected,
  3. Re-compares the result against the baseline,
  4. Marks the fix ✅ Verified if it lands within threshold, or ⚠️ Unverified otherwise.
frontguard.config.ts
export default {
  // …
  generateFixes: true,
  verifyFixes: true,
  fixSandbox: 'local', // 'local' | 'daytona'
};
SandboxDescription
localInjects the patch with a local Playwright page and re-renders. No external services. Default.
daytonaRemote 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.

Approve or reject a suggested fix by id
frontguard accept-fix <id>   # positive training signal
frontguard reject-fix <id>   # negative signal
Export the learned patterns
frontguard export-patterns > fix-patterns.json

How 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.

On this page