bugshot
install
source · Clone the upstream repo
git clone https://github.com/Sreelal727/bugshot-skill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/Sreelal727/bugshot-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/bugshot" ~/.claude/skills/sreelal727-bugshot-skill-bugshot && rm -rf "$T"
manifest:
skills/bugshot/SKILL.mdsource content
BugShot — AI Bug Capture & Fix
You are an autonomous bug hunter. The user has a web app open in Chrome and something is broken. Your job: capture everything from the browser, diagnose the root cause, and fix the code. Zero manual work from the user.
Mode Selection
Check
$ARGUMENTS to determine mode:
| Arguments | Mode |
|---|---|
(empty), , or natural language like "it's broken" | Fix — capture, diagnose, fix, verify |
| Report — capture, diagnose, generate HTML report file |
or | GitHub — capture, diagnose, file GitHub issue via CLI |
or | Watch — continuously poll for new errors |
Phase 1: Capture
IMPORTANT: Load each MCP tool with ToolSearch before first use.
First, load and call
mcp__claude-in-chrome__tabs_context_mcp to get the active tab.
Then fire all of these in parallel:
1a. Screenshot
Load and call
mcp__claude-in-chrome__computer with action: screenshot.
This captures the viewport — study it for visual bugs (blank areas, broken layout, error messages rendered on screen, missing elements, overlapping content).
1b. Console Errors
Load and call
mcp__claude-in-chrome__read_console_messages with errors_only: true.
This returns all console.error output, uncaught exceptions, and unhandled promise rejections.
1c. Network Failures
Load and call
mcp__claude-in-chrome__read_network_requests.
Filter the results for status codes >= 400. Note the URL, method, and status of each failed request.
1d. Page Structure
Load and call
mcp__claude-in-chrome__read_page to get the DOM/accessibility tree.
Look for: empty containers, error boundary fallbacks, missing content, broken component trees.
1e. Page Metadata
Load and call
mcp__claude-in-chrome__javascript_tool with this code:
JSON.stringify({ url: location.href, title: document.title, viewport: innerWidth + 'x' + innerHeight, dpr: devicePixelRatio, userAgent: navigator.userAgent, readyState: document.readyState, framework: window.__NEXT_DATA__ ? 'Next.js ' + (window.__NEXT_DATA__.buildId || '') : window.__NUXT__ ? 'Nuxt' : window.__svelte_meta ? 'SvelteKit' : window.__REMIX_DEV_TOOLS ? 'Remix' : document.querySelector('[data-reactroot],[id="__next"]') ? 'React' : document.querySelector('[data-v-]') ? 'Vue' : document.querySelector('vite-error-overlay') ? 'Vite app' : 'unknown', errors: document.querySelectorAll('vite-error-overlay, nextjs-portal, [data-nextjs-dialog]').length > 0 ? 'dev-error-overlay-visible' : 'none' })
Phase 2: Diagnose
Analyze all captured data systematically:
2a. Parse Console Errors
For each error, extract:
- Error type (TypeError, ReferenceError, SyntaxError, etc.)
- File path and line number from stack trace
- The actual error message
2b. Correlate to Source Code
Use
Grep to find the source files referenced in error stack traces:
- Search for function names, component names, or file paths mentioned in errors
- Search for string literals from error messages
- For network endpoints (e.g.,
), search for the route handler/api/users
Use
Read to examine the identified source files and understand the bug.
2c. Trace Network Failures
For each failed request:
- Match the URL path to an API route/handler in the codebase
- Check if the endpoint exists (404 = missing route, 500 = server error)
- Read the handler code to understand what's failing
2d. Classify Root Cause
Categorize the bug as one of:
| Category | Indicators |
|---|---|
| JS Runtime Error | TypeError, ReferenceError in console, stack trace points to specific file |
| API/Network Failure | 4xx/5xx responses, CORS errors, |
| Rendering/Layout Bug | Visual issues in screenshot, empty DOM containers, CSS problems |
| Build/Config Error | Module not found, env vars undefined, import errors |
| Data/State Issue | props, empty API responses, stale state |
| Hydration Mismatch | React/Next.js hydration warnings, SSR/CSR content differs |
2e. Framework-Specific Patterns
Next.js:
= API route returning HTML error page instead of JSON. Check the API route file — likely a syntax error, missing export, or wrong HTTP method handler.Unexpected token '<', "<!DOCTYPE "... is not valid JSON
= server and client render different content. Check forHydration failed
,Date.now()
, or browser-only APIs used during SSR.Math.random()
= bad import path or missing dependency.Module not found
React:
= data not loaded yet, missing null check or loading state.Cannot read properties of undefined (reading 'map')
= hooks called conditionally or outside component body.Invalid hook call
= missing key inEach child in a list should have a unique "key" prop
..map()
Vite/Webpack:
= syntax error in source file.[vite] Pre-transform error
= dev server crashed, check terminal output.HMR connection lost
= wrong import path.Failed to resolve import
General:
- CORS errors = backend missing
header.Access-Control-Allow-Origin - 401/403 = auth token missing, expired, or insufficient permissions.
= backend/API server not running.ERR_CONNECTION_REFUSED
Phase 3: Act
Fix Mode (default)
- Read the identified source files with the
toolRead - Understand the bug from the diagnosis
- Apply the fix using the
toolEdit - If multiple files need changes, fix them all
- Proceed to Phase 4: Verify
Report Mode ($ARGUMENTS
= "report")
$ARGUMENTSGenerate a self-contained HTML bug report:
- Read the template at
${CLAUDE_SKILL_DIR}/report-template.html - Replace all
tokens with captured data:{{PLACEHOLDER}}
— auto-generated from first error message or "Bug Report"{{TITLE}}
— inferred: critical (crash/500), high (runtime error), medium (warning), low (cosmetic){{SEVERITY}}
— critical=#ef4444, high=#f97316, medium=#f59e0b, low=#3b82f6{{SEV_COLOR}}
— current ISO timestamp{{TIMESTAMP}}
— from metadata{{PAGE_URL}}
— Claude's one-paragraph summary of the bug{{DESCRIPTION}}
— if screenshot captured, embed as{{SCREENSHOT_SECTION}}<img src="data:image/...">
— Claude's root cause analysis formatted as HTML{{DIAGNOSIS_HTML}}
— table rows for browser, OS, viewport, DPR, user agent, framework{{ENVIRONMENT_HTML}}
— each error as a styled div{{CONSOLE_ERRORS_HTML}}
— each failed request as a styled div{{NETWORK_ERRORS_HTML}}
- Write the populated HTML to
in the project root./bugshot-report-{timestamp}.html - Tell the user the file path so they can open it in a browser
GitHub Mode ($ARGUMENTS
= "github" or "issue")
$ARGUMENTSFile a GitHub issue:
- Build a markdown body with these sections:
[error messages with stack traces]## Bug Report **URL:** [page url] **Severity:** [severity] **Framework:** [detected framework] ### Description [Claude's diagnosis summary] ### Console Errors### Failed Network Requests | Status | Method | URL | |---|---|---| | 500 | POST | /api/users | ### Environment | Property | Value | |---|---| | Browser | Chrome 132.0 | | OS | macOS 15.3 | | Viewport | 1920x1080 | ### Root Cause Analysis [Claude's detailed diagnosis] --- *Captured with [BugShot AI](https://github.com/Sreelal727/bugshot)* - Run:
gh issue create --title "[title]" --body "[body]" --label bug - Output the issue URL
Watch Mode ($ARGUMENTS
= "watch" or "monitor")
$ARGUMENTSContinuous error monitoring:
- Take initial baseline — read current console errors and network requests
- Inform the user: "Watching for new errors. I'll alert you when something breaks."
- Every 30 seconds:
- Re-read console messages (with
to get only new ones)auto_clear: true - Re-read network requests
- If new errors appear that weren't in the baseline:
- Take a screenshot
- Run full diagnosis (Phase 2)
- Alert the user with findings
- Ask if they want to fix or continue watching
- Re-read console messages (with
- Stop when the user says to stop
Phase 4: Verify (Fix mode only)
After applying fixes:
- Wait 2-3 seconds for hot reload / dev server refresh
- Take a fresh screenshot via
mcp__claude-in-chrome__computer - Re-read console errors via
mcp__claude-in-chrome__read_console_messages - Re-read network requests via
mcp__claude-in-chrome__read_network_requests - Compare before vs after:
- Are the original errors gone?
- Are there any NEW errors introduced?
- Does the screenshot show the expected content now?
- If still broken: analyze the remaining errors, apply a second fix, and verify again
- If fixed: proceed to Phase 5
Phase 5: Summary
Output a concise summary to the user:
For Fix mode:
Fixed: [one-line root cause] Changed: [list of files modified] Verified: [pass/fail — errors before vs after]
For Report mode:
Report saved: ./bugshot-report-[timestamp].html Found: [N] console errors, [N] failed requests Diagnosis: [one-line root cause]
For GitHub mode:
Issue filed: [github issue URL] Title: [issue title] Diagnosis: [one-line root cause]
For Watch mode:
Watching... [N] errors detected so far Latest: [most recent error summary]
Important Notes
- Always load MCP tools via
before first use in the sessionToolSearch - Call
FIRST before any other browser tooltabs_context_mcp - Never trigger JavaScript alerts/confirms/prompts — they block the browser
- If the browser extension is unresponsive after 2-3 attempts, tell the user
- For the screenshot, you are a multimodal AI — you CAN see and analyze the image
- When grepping the codebase, search broadly first (error message fragments), then narrow down
- If you can't find the source file from a stack trace, check for source maps or bundled output
- For monorepos, check package.json workspaces to understand the project structure