Skip to main content
JUMP TO:Quick StartCLI CommandsConfigurationPlaywright APIMCP ServerGitHub Actions
Guides / AI Fixes & the Fix-Pattern Database(13 of 37)

AI Fixes & the Fix-Pattern Database

EXPERIMENTAL. Suggestion generation and sandbox verification are separate opt-ins. Suggestions can exist without verification.

Frontguard can propose minimal CSS patches for detected layout regressions, test those candidate rules by injecting them into a live browser sandbox, and store accepted patterns locally in .frontguard/fix-patterns.json.

Closed-Loop AI CSS Fix and Sandbox Verification Engine
FIG 01 · CLOSED-LOOP AI CSS FIX — SPATIAL CLUSTER CONTEXT · MULTI-PROVIDER BYOK · SANDBOX RE-RENDER & PATTERN STORE

Experimental status

By default, Frontguard only performs pixel and perceptual SSIM comparison. Enabling generateFixes asks the vision model for a targeted CSS rule grounded on the regressed cluster selector (cluster.targetSelector). Enabling verifyFixes opens a sandbox page, injects the candidate CSS rule, re-captures the screenshot, and re-runs the diff against your baseline.

frontguard.config.ts: enabling candidate fixes & sandbox verification
export default {
  version: 1,
  baseUrl: 'http://localhost:3000',
  ai: {
    provider: 'openai', // default model 'gpt-6-luna'
  },
  generateFixes: true, // Opt-in 1: generate candidate CSS patch
  verifyFixes: true,   // Opt-in 2: inject CSS in sandbox & re-compare against baseline
  fixSandbox: 'local', // Or 'daytona' with DAYTONA_API_KEY configured
}

Verification

With generateFixes and verifyFixes enabled, Frontguard can apply a CSS suggestion in a sandbox, re-render, and label the outcome Verified or Unverified. A verified result is automatically recorded as an accepted local fix-pattern signal when that database is available.

Fix-pattern CLI workflow

You can curate the local fix-pattern store (.frontguard/fix-patterns.json) so recurring layout issues are matched locally before calling an external model:

terminal: managing local fix patterns
# Mark suggestion #1 from the latest run as accepted:
$ npx -p @frontguard/cli frontguard accept-fix 1

# Mark suggestion #2 as unhelpful (negative signal):
$ npx -p @frontguard/cli frontguard reject-fix 2

# Export curated patterns to commit or share across projects:
$ npx -p @frontguard/cli frontguard export-patterns > .frontguard/shared-patterns.json

Human review

That automatic record does not update screenshot baselines or guarantee correctness. Review every patch and run broader tests.