--- name: visual-debug description: "Diagnose why an existing implementation differs from reference evidence using AE/SSIM, pixel, section, computed-style, and transition diffs. Use for post-implementation mismatch or repair guidance; not baseline capture or full clone generation." metadata: filePattern: - "**/tmp/ref/**/static/**" - "**/tmp/ref/**/frames/**" - "**/tmp/ref/**/diff/**" - "**/side-by-side/**" bashPattern: - "compare.*metric" - "ffmpeg.*ssim" - "ae-compare" - "batch-compare" - "batch-scroll" - "computed-diff" - "auto-diagnose" priority: 90 --- # Visual Debug Diagnose an existing implementation against captured reference evidence with structural, AE, DSSIM, runtime, and transition checks. ## Boundary and return contract - Use this skill when reference and implementation evidence already exist. Route missing baseline evidence to `ui-capture`; route implementation, regeneration, and full clone orchestration to `ui-reverse-engineering` or the active caller. - Diagnose and return the failing artifact, selector or region, likely root cause, recommended fix, and exact verification command. The caller owns source edits unless it explicitly delegated repair. - Read `brief/WORKER_BRIEF.md` or `evidence-pack.json` first when present, then only the summaries and named drill-down artifacts needed for the failing hotspot. - If repair was delegated to you, read [`../ui-reverse-engineering/iteration-discipline.md`](../ui-reverse-engineering/iteration-discipline.md) before the repair loop. Attempt history and stop conditions survive delegation and compaction. Report checker defects with a reproducer unless shared-tool repair is already authorized; never edit an installed cache. - Matching text, heights, fired events, or a successful build does not prove appearance or trajectory parity. Compare background and foreground, media fit, and intermediate motion states. ## Required invariants **Do not read ref/impl images for routine comparison.** Start with summaries and AE/SSIM tools. For a failing position, run `auto-diagnose.sh`; read a diff image only if automated diagnosis finds nothing. Phase E is the required exception and must run in a delegated context. Pin the reference during iteration. Dynamic sites otherwise compare against a moving target: after the first complete reference capture, use frozen reference crops (`RECATCH_REF=0`) until evidence is genuinely stale. After any implementation edit, produce fresh implementation evidence before judging the fix. When evidence contains `window.scrollTo`, `scrollYProgress`, `setTimeout`, velocity, a guard ref around scroll-stop logic, or ScrollTrigger pin/scrub, require scroll state-machine proof of `initial → active/expanded → settled/returned`; a single endpoint frame is insufficient. Do not weaken thresholds or mask unexplained regions to clear a failure. Classify each failure as implementation, reference/capture, checker, or unknown before editing. Close every browser session you opened on success, failure, or interruption: ```bash agent-browser --session close ``` Never use `close --all`; other agents may own sessions. ## Start once per session Check required tools. If anything is missing, stop and surface the bootstrap command; do not execute a remote installer automatically. ```bash miss="" for c in agent-browser ffmpeg dssim; do command -v "$c" >/dev/null 2>&1 || miss+=" $c"; done { command -v magick >/dev/null 2>&1 || command -v convert >/dev/null 2>&1; } || miss+=" imagemagick" if [ -n "$miss" ]; then printf 'Missing system deps:%s\nBootstrap:\n tmp=$(mktemp) && curl -LsSf -o "$tmp" https://raw.githubusercontent.com/voidmatcha/ui-clone-skills/main/install.sh && bash "$tmp" && rm -f "$tmp"\n' "$miss" exit 1 fi ``` Resolve scripts from the active plugin or checkout: ```bash SCRIPTS_DIR="${VISUAL_DEBUG_SCRIPTS_DIR:-}" if [ -z "$SCRIPTS_DIR" ]; then for root in "${PLUGIN_ROOT:-}" "${CODEX_PLUGIN_ROOT:-}" "${CLAUDE_PLUGIN_ROOT:-}" "${UI_CLONE_ROOT:-}" "$PWD" "$PWD/.." "$PWD/../.." "${INSTALL_DIR:-$HOME/.local/share/ui-clone-skills}"; do [ -n "$root" ] && [ -f "$root/skills/visual-debug/scripts/ae-compare.sh" ] && SCRIPTS_DIR=$(cd "$root/skills/visual-debug/scripts" && pwd) && break done fi [ -n "$SCRIPTS_DIR" ] || { echo "Set VISUAL_DEBUG_SCRIPTS_DIR or PLUGIN_ROOT" >&2; exit 1; } ``` Run the scripts as `bash "$SCRIPTS_DIR/