capture-pr-visuals
Skill8 starsChanged 9 months agoMITView on GitHub
Auto-capture screenshots and GIFs of the running app for PR documentation using Playwright and project context from chalk.json
- Deletes or force-pushes
- Installs packages
In this repository79 other files it gives its agents.
- AGENTS.mdAGENTS.md
- analyze-competitorsSkill
- analyze-dependenciesSkill
- analyze-metricsSkill
- audit-accessibilitySkill
- audit-api-consistencySkill
- audit-performanceSkill
- audit-securitySkill
- commitSkill
- create-adrSkill
- create-api-designSkill
- create-bug-reportSkill
- create-commit-messageSkill
- create-data-modelSkill
- create-decision-logSkill
- create-docSkill
- create-estimationSkill
- create-experiment-designSkill
- create-feature-flag-planSkill
- create-gtm-briefSkill
- create-handoffSkill
- create-incident-reportSkill
- create-interview-guideSkill
- create-jtbd-canvasSkill
- create-metrics-frameworkSkill
- create-onboarding-guideSkill
- create-ostSkill
- create-planSkill
- create-postmortemSkill
- create-pr-descriptionSkill
- create-prdSkill
- create-prSkill
- create-release-checklistSkill
- create-release-notesSkill
- create-retroSkill
- create-reviewSkill
- create-rfcSkill
- create-roadmapSkill
- create-rollback-planSkill
- create-runbookSkill
- create-shape-up-pitchSkill
- create-stakeholder-updateSkill
- create-test-planSkill
- create-threat-modelSkill
- create-user-storiesSkill
- debug-systematicSkill
- fastapi-endpoint-patternsSkill
- fix-findingsSkill
- fix-reviewSkill
- flutter-platform-patternsSkill
- flutter-state-managementSkill
- flutter-version-managementSkill
- flutter-widget-patternsSkill
- manage-tech-debtSkill
- nextjs-api-patternsSkill
- nextjs-app-router-patternsSkill
- nextjs-performanceSkill
- product-context-docsSkill
- project-skill-creatorSkill
- project-standardsSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. About 0 are common, 10 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
Read .chalk/chalk.json to get:
- Very specific: line 32
If chalk.json doesn't exist or is missing key fields, auto-discover:
- Very specific: line 53
If auto-discovery also fails, ask the user for the dev URL and routes.
- Distinctive: line 66
If the user provided specific routes as arguments, use those instead.
- Distinctive: line 68
If no route mapping is possible (backend-only changes), inform the user and ask which pages to capture.
- Very specific: line 77
Start the dev server in the background using dev.command from chalk.json
- Distinctive: line 78
Wait for it to be ready (poll until HTTP response)
- Distinctive: line 89
Check for ffmpeg (needed for GIF generation):
- Very specific: line 95
If ffmpeg is missing, warn: "ffmpeg not found — screenshots only (no GIFs).
- Distinctive: line 168
Add project-specific interactions if relevant
- Distinctive: line 178
If ffmpeg is available:
- Distinctive: line 195
Commit the new visual artifacts:
- Very specific: line 218
Delete the temporary capture script: rm -f .chalk/local/capture-script.ts
- Distinctive: line 219
If the dev server was started by this skill, ask the user if they want to stop it
- Very specific: line 223
NEVER modify package.json or install permanent dependencies
- Very specific: line 224
Always use npx for Playwright and tsx
- Distinctive: line 226
If capture fails for a route, log a warning but continue with other routes
- Very specific: line 233
If chalk.json has project.framework: "electron" or package.json has electron as a dependency:
- Distinctive: line 235
Check the dev server output or config for the renderer URL
- Very specific: line 236
Use that renderer URL as BASE_URL (not the Electron window)
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
Capture screenshots and GIFs of the running application for PR visual documentation. Reads chalk.json for dev server and route info, falls back to auto-discovery if chalk docs don't exist. Uses Playwright via npx.
Workflow
Step 1: Read Project Context
Read .chalk/chalk.json to get:
dev.command— how to start the dev serverdev.port— what port it runs ondev.url— the full URLroutes[]— what pages to captureproject.framework— for framework-specific handling (e.g., Electron)
Fallback: No chalk.json
If chalk.json doesn't exist or is missing key fields, auto-discover:
- Read
package.json— detect framework from dependencies:next→ Next.js (port 3000, file-based routing)vite/@vitejs/plugin-react→ Vite SPA (port 5173)react-scripts→ CRA (port 3000)nuxt→ Nuxt (port 3000)@angular/core→ Angular (port 4200)svelte/@sveltejs/kit→ SvelteKit (port 5173)electron/electron-vite→ Electron (renderer on separate port)vue→ Vue (port 5173 or 8080)
- Detect routes — scan based on framework:
- File-based routing: glob
app/**/page.{tsx,jsx,ts,js}orpages/**/*.{tsx,jsx,vue} - React Router: grep for
<RouteorcreateBrowserRouterinsrc/ - Vue Router: grep for
path:in router configs - Query-param routing (Electron): grep for
searchParams.get - Fallback: scan
src/pages/,src/views/,src/app/,src/routes/
- File-based routing: glob
- Confirm with user — show auto-detected URL and routes, let them correct before proceeding.
If auto-discovery also fails, ask the user for the dev URL and routes. Suggest running /setup-chalk for future use.
Step 2: Analyze PR Changes
git diff main..HEAD --name-only
git diff main..HEAD --statMap changed files to affected routes using chalk.json routes[].src or the architecture docs. For example:
- Changes in
src/pages/dashboard/→/dashboardroute - Changes in
src/components/Header.tsx→ all pages (shared component)
If the user provided specific routes as arguments, use those instead.
If no route mapping is possible (backend-only changes), inform the user and ask which pages to capture.
Step 3: Ensure Dev Server is Running
curl -s -o /dev/null -w "%{http_code}" http://localhost:<PORT> 2>/dev/nullIf not running:
- Start the dev server in the background using
dev.commandfrom chalk.json - Wait for it to be ready (poll until HTTP response)
- For Electron apps: the renderer is served on a separate port during dev — detect from config or output
Note the PID if starting the server so it can be stopped later.
Step 4: Ensure Playwright is Available
npx playwright install chromium 2>/dev/null || echo "Playwright install failed"Check for ffmpeg (needed for GIF generation):
which ffmpeg 2>/dev/nullIf ffmpeg is missing, warn: "ffmpeg not found — screenshots only (no GIFs). Install with brew install ffmpeg for GIF support."
Step 5: Clean Old Artifacts and Capture New Ones
First, clean any previous screenshots to ensure a fresh capture:
rm -rf .github/pr-screenshots/ 2>/dev/null
mkdir -p .github/pr-screenshots/Then create a temporary capture script at .chalk/local/capture-script.ts:
import { chromium } from 'playwright';
import { mkdirSync } from 'fs';
import { join } from 'path';
const BASE_URL = '<DETECTED_URL>';
const ROUTES: { path: string; name: string }[] = [
// Populated from chalk.json routes or Step 2 analysis
];
const OUTPUT_DIR = '.github/pr-screenshots';
const VIDEO_DIR = join(OUTPUT_DIR, 'videos');
(async () => {
mkdirSync(OUTPUT_DIR, { recursive: true });
mkdirSync(VIDEO_DIR, { recursive: true });
const browser = await chromium.launch({ headless: true });
for (const route of ROUTES) {
const context = await browser.newContext({
viewport: { width: 1280, height: 800 },
recordVideo: { dir: VIDEO_DIR, size: { width: 1280, height: 800 } },
});
const page = await context.newPage();
try {
await page.goto(`${BASE_URL}${route.path}`, {
waitUntil: 'networkidle',
timeout: 15000,
});
await page.screenshot({
path: join(OUTPUT_DIR, `${route.name}.png`),
fullPage: true,
});
// Brief interaction for video
await page.evaluate(() => window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' }));
await page.waitForTimeout(1500);
await page.evaluate(() => window.scrollTo({ top: 0, behavior: 'smooth' }));
await page.waitForTimeout(1500);
} catch (err) {
console.error(`Failed to capture ${route.name}: ${err}`);
}
await page.close();
await context.close();
}
await browser.close();
console.log('Capture complete.');
})();Adapt the script based on the project:
- Set
BASE_URLfrom chalk.jsondev.urlor detected URL - Populate
ROUTESfrom chalk.json or Step 2 analysis - For Electron query-param routing, use paths like
?home=true - Add project-specific interactions if relevant
Execute:
npx tsx .chalk/local/capture-script.tsStep 6: Convert Videos to GIFs
If ffmpeg is available:
for f in .github/pr-screenshots/videos/*.webm; do
name=$(basename "$f" .webm)
ffmpeg -y -i "$f" -vf "fps=10,scale=1280:-1:flags=lanczos" -loop 0 ".github/pr-screenshots/${name}.gif" 2>/dev/null
doneClean up videos:
rm -rf .github/pr-screenshots/videosStep 7: Commit Artifacts
Commit the new visual artifacts:
git add .github/pr-screenshots/
git commit -m "chore: add PR visual artifacts"Step 8: Output
Print markdown references for the PR body:
## Visual Preview
### <Page Name>

Suggest: "Visual artifacts committed. Run /create-pr to create the PR with embedded screenshots."
Step 9: Cleanup
- Delete the temporary capture script:
rm -f .chalk/local/capture-script.ts - If the dev server was started by this skill, ask the user if they want to stop it
Rules
- NEVER modify
package.jsonor install permanent dependencies - Always use
npxfor Playwright and tsx - Clean previous screenshots before capturing new ones
- If capture fails for a route, log a warning but continue with other routes
- The capture script is ephemeral — delete it after execution
- Screenshots go in
.github/pr-screenshots/(committed to the branch) - For auth-gated pages, warn the user those pages may need manual screenshots
Electron App Handling
If chalk.json has project.framework: "electron" or package.json has electron as a dependency:
- The renderer is served on a separate port during dev (auto-assigned by Vite)
- Check the dev server output or config for the renderer URL
- Use that renderer URL as
BASE_URL(not the Electron window) - Electron query-param routing (e.g.,
?home=true,?canvas) should be used as route paths
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.

