sg-visual-fix
/sg-visual-fix — Fix Annotated Screenshots
Take human-annotated screenshots from /sg-visual-review, analyze the marked problems, fix the code, and produce before/after comparison.
Recommended model: Sonnet 4.6 for mineures fixes (CSS tweaks, copy changes, small layout nits). Switch to Opus 4.7 if the annotations point to a full component refonte or cross-file logic change. Use
/model sonnetor/model opusaccordingly.
Flow
Human annotates screenshots in review.html
→ clicks "Validate & Generate Report"
→ fix-manifest.json is saved to the server via POST /save-manifest
→ runs /sg-visual-fix
→ AI reads each annotated screenshot
→ AI reads the annotation coordinates (problem region)
→ AI identifies the visual bug in that region
→ AI traces to source code (component, CSS, data)
→ AI implements the fix
→ AI rebuilds the app
→ AI re-runs the specific test to capture "after" screenshot
→ AI generates before/after comparison page
How This Skill Works (LLM-Driven)
Important: This skill is LLM-driven and non-deterministic. The same annotated screenshot can produce different fixes across runs because the LLM interprets the visual issue differently each time. This is by design — visual debugging requires judgment, not pattern matching.
| Skill | Execution model | Deterministic? |
|---|---|---|
sg-code-audit |
Parallel agents with structured checklist | Yes (same checklist → same bugs) |
sg-visual-run |
Scripted steps + LLM assertions | Mostly (steps are mechanical; only llm-check varies) |
sg-visual-fix |
LLM reads screenshot → traces to code → implements fix | No (different interpretation each run) |
If a fix doesn't work, re-run or provide more specific annotation notes to guide the LLM.
Invocations
| Command | Behavior |
|---|---|
/sg-visual-fix |
Process the most recent fix manifest in visual-tests/_results/ |
/sg-visual-fix <path> |
Process a specific fix manifest JSON file |
Instructions
Step 1: Load the Fix Manifest
Find the manifest file:
- If argument provided: use that path
- Otherwise: read
visual-tests/_results/fix-manifest.json(saved by the review page server)
The manifest action field determines how to process each test:
validate-and-fix— Read annotated screenshot, trace to source code, implement fix, rebuild, capture after screenshot.redo_entirely— Re-run the test from scratch (re-execute all steps against the live app) and fix based on the fresh screenshot. Do not use the stored before-screenshot; re-capture now.revert_to_before— Restore the before-screenshot version of affected files usinggit checkout -- <file>(revert code changes). Then re-run the test to confirm the revert worked.
The manifest contains:
{
"action": "validate-and-fix",
"tests": [
{
"test": "auth/login",
"url": "http://localhost:3000/login",
"screenshot": "screenshots/login-load.png",
"annotations": [
{ "x1": 0.2, "y1": 0.3, "x2": 0.8, "y2": 0.6 }
],
"steps": [...]
}
]
}
Step 2: For Each Annotated Test
2a. Read the "before" screenshot
# Read the screenshot file — screenshot_path is relative to visual-tests/_results/screenshots/
# Use the full path directly: visual-tests/_results/screenshots/{original}.png
Read(visual-tests/_results/screenshots/{original}.png)
Focus on the annotated regions (x1/y1 to x2/y2 as percentages of image dimensions). Describe what you see in each marked region:
- UI errors (broken layout, wrong colors, misaligned elements)
- Data issues (wrong text, missing content, empty state that should have data)
- Error messages (toasts, modals, HTTP errors)
2b. Trace to source code
Based on the URL and visual issue:
- Find the page component (use route to find
app/.../page.tsx) - Identify which component renders the problematic region
- Read the component code
- Identify the root cause (CSS issue, data mapping bug, missing prop, etc.)
2c. Implement the fix
Apply the minimal fix. Follow project rules:
- Read before writing
- No speculative changes
- Typecheck after each fix
2d. Rebuild and capture "after" screenshot
Read build_command from visual-tests/_config.yaml:
- If
build_commandis a non-null string: execute it - If
build_command: null: no rebuild needed — proceed directly to re-run - If
build_commandis absent from config entirely: auto-detect before asking the user:- Check
package.json→scripts.buildorscripts.dev→ proposenpm run buildornpm run dev - Check for
docker-compose.yml/docker-compose.yaml→ proposedocker compose up -d --build - Check
playwright.config.js/.ts→webServer.command - If detected, use it and print:
Auto-detected build command: {command} - If nothing detected, ask the user how to rebuild, then proceed
- Check
# Examples of build_command values in _config.yaml:
# build_command: "docker compose up -d --build frontend"
# build_command: "npm run build"
# build_command: null # no rebuild needed — skip rebuild step
# {test_url} is derived from the test manifest's first open step:
# manifest.steps.find(s => s.action === 'open').url
# {test-id} is the manifest path with slashes replaced by hyphens
# e.g. "auth/login" becomes "auth-login", "dashboard/home" becomes "dashboard-home"
# Re-run the specific test steps
agent-browser open {test_url}
# ... execute test steps from manifest
agent-browser screenshot --full visual-tests/_results/screenshots/{test-id}-after.png
2e. Save before/after pair
Copy the original screenshot (path is visual-tests/_results/screenshots/{original-filename}.png — do NOT add an extra screenshots/ prefix):
cp visual-tests/_results/screenshots/{original-filename}.png visual-tests/_results/screenshots/{test-id}-before.png
Step 3: Generate Before/After Comparison
Regenerate the review page with a "Comparison" tab:
node visual-tests/build-review.mjs
This rebuilds review.html without starting a new server. If the review server is not already running, start it separately:
node visual-tests/build-review.mjs --serve
The review page shows before/after screenshots when pairs exist (matching {slug}-before.png and {slug}-after.png in the screenshots directory).
Step 3b: Stop Review Server
After all fixes are applied and verified, stop the review server:
node visual-tests/build-review.mjs --stop
Step 4: Commit and Report
git add <fixed files> visual-tests/_results/screenshots/*-after.png
git commit -m "fix(visual): fix N annotated issues from human review"
Report to user:
Visual Review Fix Complete:
- {N} annotated issues processed
- {M} fixed, {K} need further investigation
- Before/after comparison: visual-tests/_results/review.html (Comparison tab)
- Rebuilt: (build_command from _config.yaml)
Important Rules
- ALWAYS read the "before" screenshot with the Read tool before attempting any fix
- ALWAYS focus on the annotated region coordinates — the human marked exactly where the problem is
- ALWAYS capture an "after" screenshot using the same test steps
- ALWAYS verify the fix visually (read the "after" screenshot)
- If a fix requires backend changes, run the appropriate build_command
- If you can't identify the issue from the screenshot, say so — don't guess
More from bacoco/shipguard
sg-scout
GitHub intelligence for ShipGuard — scans repos for code audit, debugging, and self-improving agent techniques, then files actionable improvement proposals. Use when you want to discover new approaches, benchmark against similar tools, or find inspiration for ShipGuard improvements. Trigger on "sg-scout", "scout github", "find skills", "benchmark shipguard", "veille technique", "competitive analysis", "what are others doing", "find improvements".
1sg-improve
Auto-improve ShipGuard from real session learnings. Run this after any /sg-code-audit, /sg-visual-run, or debugging session. Analyzes what worked, what broke, and what was slow — saves project-specific learnings locally (zone sizing, patterns, infra timing) and files generic improvements as GitHub issues. The local learnings feed back into the next audit run automatically. Trigger on "sg-improve", "improve shipguard", "ameliore shipguard", "shipguard feedback", "session insights", "retex", "retrospective", "what did we learn".
1sg-record
Record browser interactions as replayable ShipGuard test manifests. Opens a Playwright browser with a floating toolbar — user navigates, clicks Check to mark assertions, clicks Stop to generate YAML. Trigger on "sg-record", "record test", "record interactions", "macro recorder", "enregistrer test", "enregistre les interactions".
1sg-visual-review
Generate an interactive HTML screenshot review page from Visual test results. Browse all test screenshots in a grid, filter by status/category, annotate problems with a pen tool, multi-select failed tests, and export re-run manifests. Trigger on "sg-visual-review", "visual review", "review screenshots", "show test results", "review visual", "visual-review", "show results", "test review".
1sg-code-audit
Parallel AI codebase audit — dispatches agents to find and fix bugs across the entire repo. Produces structured JSON results viewable in /sg-visual-review. Trigger on "sg-code-audit", "code audit", "audit codebase", "find bugs", "code-audit", "audit code", "static audit", "security audit", "ship guard".
1sg-visual-run
Execute Visual test manifests using agent-browser with hybrid scripted+LLM assertions. Accepts natural language to describe what to test or what changed — the skill finds and runs the right tests, generating missing ones if needed. Trigger on "sg-visual-run", "visual run", "run visual tests", "test regressions", "run tests", "visual-run", "check if the app works", "I changed X check it still works".
1