Live preview

From SethGammon/Citadel · View interactive version

Live preview is an AI agent skill from the GitHub repository SethGammon/Citadel. Mid-build visual verification loop. Takes screenshots of components during construction, not just after. Catches visual regressions and invisible features before they compound. Requires Playwright or similar screenshot tool.

How to use this skill

Skill file

/live-preview — Build-Verify-Fix Loop

Prerequisites

This skill requires a screenshot tool. Supported:

If no screenshot tool is available, this skill will tell you what to install and exit.

When to Use

Protocol

Step 1: DETECT

Determine what needs visual verification:

  1. Check which files were modified in the current session/phase
  2. Filter to view-layer files (.tsx, .jsx, .vue, .svelte, .html, .css)
  3. If no view-layer files found: exit early with message

"No view-layer files modified. Nothing to preview." Skip Steps 2-5.

This is expected for non-UI repos (CLI tools, libraries, agent harnesses).

  1. Map each modified file to a route or URL where it renders:

Step 2: CAPTURE

For each route/URL that needs verification:

  1. Ensure the dev server is running (start it if not)
  2. Take a screenshot:

```bash

npx playwright screenshot http://localhost:{port}/{route} .planning/screenshots/{route-slug}.png --full-page

```

  1. If Playwright isn't available, try:

```bash

# Check for playwright

npx playwright --version 2>/dev/null

# If not found, inform the user:

# "live-preview needs Playwright for screenshots. Install with: npm i -D playwright"

```

Step 3: VERIFY

For each screenshot:

  1. Read the screenshot (vision). Check:
  1. Record the result:

Step 4: FIX (if failures found)

For each FAIL or BLANK:

  1. Diagnose: is it a data issue, a rendering issue, or a missing import?
  2. Fix the root cause (not a band-aid)
  3. Re-capture and re-verify
  4. Maximum 2 fix attempts per component. If still failing, log it and move on.

Step 5: ARTIFACT

Save verification artifacts:

  1. Screenshots go to .planning/screenshots/{campaign-slug}/ (if in a campaign)

or .planning/screenshots/ (if standalone)

  1. In Codex, also register screenshots for the app artifact/browser workflow:

```bash

node scripts/codex-app-artifacts.js record --workflow live-preview --kind screenshot --path ".planning/screenshots/{route-slug}.png" --status pass

```

  1. Verify registered artifacts:

```bash

node scripts/codex-app-artifacts.js verify --require-artifacts

```

  1. Write a verification summary:

```markdown

## Visual Verification: {date}

| Route | File Modified | Result | Notes |

|-------|--------------|--------|-------|

| /dashboard | Dashboard.tsx | PASS | Renders correctly |

| /settings | SettingsPanel.tsx | FAIL → PASS | Fixed missing import, re-verified |

| /profile | ProfileCard.tsx | BLANK → PASS | Component wasn't mounted, fixed export |

```

Integration with Archon

When Archon delegates a build phase that modifies view files:

  1. After the sub-agent completes, Archon invokes /live-preview on the modified routes
  2. If any route is BLANK or FAIL, the phase is NOT marked complete
  3. The fix cycle runs before proceeding to the next phase
  4. This is part of Archon's Step 4 (Self-Correction) quality spot-check

What This Prevents

Fringe Cases

Contextual Gates

Disclosure: "Taking screenshots for visual verification. Images saved to .planning/screenshots/."

Reversibility: green — screenshots only; saves to .planning/screenshots/. No source files modified.

Trust gates:

Quality Gates

Exit Protocol

---HANDOFF---
- Live Preview: {N} routes verified
- Results: {pass}/{total} passed
- Failures: {list of routes that failed and what was wrong}
- Screenshots: .planning/screenshots/{path}
- Reversibility: green — delete .planning/screenshots/ to remove artifacts; no source files modified
---
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.