frontend-preview
Skill2 starsChanged 3 months agoMITView on GitHub
Phase 5 of ACF (optional). Launches a local frontend preview of the changes, produces a visual diff (before/after, like git red/green but on the web), and optionally captures a screenshot for vision-model review. Use when ACF detects frontend changes, or when the user asks to "preview the frontend", "see the visual diff", or "screenshot the change".
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- context-loadSkill
- stack-auditSkill
- issue-craftSkill
- pr-contextSkill
- label-metadataSkill
- compactionSkill
- cavemanSkill
- graph-scopeSkill
- acfSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 15 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 54
If a server is already running, use it instead of starting a new one.
- Distinctive: line 75
Use Playwright (or the browser preview tool) to:
- Distinctive: line 96
No untracked files exist outside the current change set that the stash would clobber
- Distinctive: line 104
If git stash pop reports conflicts, stop and surface them to the user:
- Distinctive: line 119
Do NOT force-resolve or discard changes
- Distinctive: line 120
Run git stash list to confirm the stash is still saved
- Distinctive: line 121
Run git status to see conflicted files
- Very specific: line 125
If the user wants to abort: git checkout -- .
- Distinctive: line 127
Always verify git status returns to the pre-stash state before continuing with the "after" screenshot
- Distinctive: line 149
If Playwright or a dev server is not available, frontend-preview degrades to:
- Distinctive: line 154
Do NOT block the PR on frontend-preview — it's an enhancement, not a gate.
- Distinctive: line 158
If Playwright is not available, try alternatives in order:
- Distinctive: line 182
GitHub API rate limits: not applicable to screenshot capture.
- Distinctive: line 189
Commands fail: if screenshot capture fails (page not found, timeout), record the error and fall back to Lightweight Mode.
- Distinctive: line 194
If frontend-preview was run:
- Very specific: line 195
Add a ## Frontend Preview section to the PR body
- Very specific: line 197
Add an AC checkbox: - [ ] Visual change verified on /route
- Distinctive: line 199
If frontend-preview was NOT run (no frontend changes):
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Frontend-Preview
Provides visual verification for frontend changes before a PR is opened. This is the "kiro hook" equivalent implemented as a skill trigger.
When to Trigger
Trigger frontend-preview when the diff touches:
*.html,*.css,*.scss,*.tailwind*.tsx,*.jsx,*.vue,*.svelte*.astro,*.njk,*.hbs- Any file under
frontend/,src/components/,templates/,views/
Workflow
1. Detect Affected Routes
From the diff, infer which routes/pages are affected:
- File
src/pages/contributors.tsx→ route/contributors - File
src/components/Navbar.tsx→ all routes (global component) - File
src/styles/theme.css→ all routes
2. Launch Dev Server (if not running)
Dev server detection:
- Check
package.jsonscripts for a dev server command:
Common script names:# Extract script names from package.json node -e "const s=require('./package.json').scripts||{}; \ console.log(Object.keys(s).filter(k=>['dev','start','serve'].includes(k)).join(' '))"dev,start,serve. - Check common ports for an already-running dev server:
If a server is already running, use it instead of starting a new one.# Check if a dev server is already running on common ports for port in 3000 5173 8080 4000 4200 8000 8888; do curl -s "http://localhost:$port" >/dev/null 2>&1 && echo "running:$port" done Framework-specific commands (if detected from dependencies):
Framework Detection Dev command Default port Next.js nextin depsnpm run dev3000 Vite vitein depsnpm run dev5173 CRA react-scriptsin depsnpm start3000 Vue (Vite) @vitejs/plugin-vuenpm run dev5173 SvelteKit @sveltejs/kitin depsnpm run dev5173 Nuxt nuxtin depsnpm run dev3000 Astro astroin depsnpm run dev4321
# Launch the dev server using the detected command
npm run dev # or: pnpm dev, yarn dev, bun dev3. Navigate to Affected Route
Use Playwright (or the browser preview tool) to:
- Navigate to the affected route (e.g.,
http://localhost:3000/contributors) - Capture a screenshot of the current (changed) state
4. Visual Diff (Before/After)
To produce a git-style visual diff on the web:
- Before:
git stashthe changes, screenshot the route,git stash pop - After: screenshot the route with changes applied
- Diff: overlay the two screenshots, highlighting changed regions in red (removed) / green (added)
This mimics git diff but for rendered web pages.
Stash safety:
git stash --include-untracked is safe to use when ALL of the following are
true:
git status --porcelainshows only the files related to the current change (no unrelated staged or unstaged modifications)- No untracked files exist outside the current change set that the stash would clobber
- The working tree has no merge conflicts in progress (
git diff --checkpasses) - The stash will be popped immediately after the "before" screenshot (no other git operations in between)
Conflict surfacing format:
If git stash pop reports conflicts, stop and surface them to the user:
⚠️ Stash pop conflict detected — manual resolution required.
Conflicted files:
- <file1>
- <file2>
Your stashed changes are preserved in the stash stack.
Run `git stash list` to verify, then resolve conflicts manually.Recovery procedure if stash pop fails:
- Do NOT force-resolve or discard changes
- Run
git stash listto confirm the stash is still saved - Run
git statusto see conflicted files - Surface the conflict list to the user (format above)
- The user can resolve manually with
git checkout --theirs <file>orgit checkout --ours <file>, thengit stash dropwhen done - If the user wants to abort:
git checkout -- . && git stash popto retry, orgit stash applyto apply without dropping - Always verify
git statusreturns to the pre-stash state before continuing with the "after" screenshot
5. Screenshot for Vision Review
Capture a screenshot and attach it to the PR so vision-capable models can review the visual change:
# Save screenshot
playwright screenshot --url http://localhost:3000/contributors \
--output /tmp/frontend-preview.pngThe screenshot is referenced in the PR body:
## Frontend Preview
Lightweight Mode
If Playwright or a dev server is not available, frontend-preview degrades to:
- Listing the affected routes
- Describing the expected visual change based on the diff
- Recommending manual verification
Do NOT block the PR on frontend-preview — it's an enhancement, not a gate.
Playwright Fallback
If Playwright is not available, try alternatives in order:
- Puppeteer (if installed):
node -e "const p=require('puppeteer'); \ (async()=>{const b=await p.launch();const pg=await b.newPage(); \ await pg.goto('http://localhost:3000/contributors'); \ await pg.screenshot({path:'/tmp/frontend-preview.png'}); \ await b.close();})()" - Manual screenshot instructions — if no headless browser is available:
- Report: "No headless browser found (Playwright/Puppeteer). Manual screenshot needed."
- Provide the URL to screenshot:
http://localhost:3000/contributors - Instruct the user to take a screenshot and attach it to the PR
- Always degrade gracefully — never block the PR. If no screenshot can be captured, fall back to Lightweight Mode (list routes + describe changes).
Error Handling
ghCLI not installed: frontend-preview does not requireghfor screenshots. If attaching to a PR fails, save the screenshot locally and instruct the user to attach it manually.ghnot authenticated: same as above — save screenshot locally.- GitHub API rate limits: not applicable to screenshot capture. If PR attachment fails due to rate limits, save locally and attach later.
- Dev server not running and cannot start: fall back to Lightweight Mode. Report "Dev server not available — listing affected routes and describing expected changes instead."
- Playwright not installed: see Playwright Fallback above. Try Puppeteer, then manual instructions, then Lightweight Mode.
- Commands fail: if screenshot capture fails (page not found, timeout), record the error and fall back to Lightweight Mode. Do not block the PR.
Integration with PR-Context
If frontend-preview was run:
- Add a
## Frontend Previewsection to the PR body - Attach the screenshot
- Add an AC checkbox:
- [ ] Visual change verified on /route
If frontend-preview was NOT run (no frontend changes):
- Skip this phase entirely
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

