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.md
source 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:

ArgumentsMode
(empty),
fix
, or natural language like "it's broken"
Fix — capture, diagnose, fix, verify
report
Report — capture, diagnose, generate HTML report file
github
or
issue
GitHub — capture, diagnose, file GitHub issue via
gh
CLI
watch
or
monitor
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.,
    /api/users
    ), search for the route handler

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:

CategoryIndicators
JS Runtime ErrorTypeError, ReferenceError in console, stack trace points to specific file
API/Network Failure4xx/5xx responses, CORS errors,
Failed to fetch
Rendering/Layout BugVisual issues in screenshot, empty DOM containers, CSS problems
Build/Config ErrorModule not found, env vars undefined, import errors
Data/State Issue
undefined
props, empty API responses, stale state
Hydration MismatchReact/Next.js hydration warnings, SSR/CSR content differs

2e. Framework-Specific Patterns

Next.js:

  • Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    = 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.
  • Hydration failed
    = server and client render different content. Check for
    Date.now()
    ,
    Math.random()
    , or browser-only APIs used during SSR.
  • Module not found
    = bad import path or missing dependency.

React:

  • Cannot read properties of undefined (reading 'map')
    = data not loaded yet, missing null check or loading state.
  • Invalid hook call
    = hooks called conditionally or outside component body.
  • Each child in a list should have a unique "key" prop
    = missing key in
    .map()
    .

Vite/Webpack:

  • [vite] Pre-transform error
    = syntax error in source file.
  • HMR connection lost
    = dev server crashed, check terminal output.
  • Failed to resolve import
    = wrong import path.

General:

  • CORS errors = backend missing
    Access-Control-Allow-Origin
    header.
  • 401/403 = auth token missing, expired, or insufficient permissions.
  • ERR_CONNECTION_REFUSED
    = backend/API server not running.

Phase 3: Act

Fix Mode (default)

  1. Read the identified source files with the
    Read
    tool
  2. Understand the bug from the diagnosis
  3. Apply the fix using the
    Edit
    tool
  4. If multiple files need changes, fix them all
  5. Proceed to Phase 4: Verify

Report Mode (
$ARGUMENTS
= "report")

Generate a self-contained HTML bug report:

  1. Read the template at
    ${CLAUDE_SKILL_DIR}/report-template.html
  2. Replace all
    {{PLACEHOLDER}}
    tokens with captured data:
    • {{TITLE}}
      — auto-generated from first error message or "Bug Report"
    • {{SEVERITY}}
      — inferred: critical (crash/500), high (runtime error), medium (warning), low (cosmetic)
    • {{SEV_COLOR}}
      — critical=#ef4444, high=#f97316, medium=#f59e0b, low=#3b82f6
    • {{TIMESTAMP}}
      — current ISO timestamp
    • {{PAGE_URL}}
      — from metadata
    • {{DESCRIPTION}}
      — Claude's one-paragraph summary of the bug
    • {{SCREENSHOT_SECTION}}
      — if screenshot captured, embed as
      <img src="data:image/...">
    • {{DIAGNOSIS_HTML}}
      — Claude's root cause analysis formatted as HTML
    • {{ENVIRONMENT_HTML}}
      — table rows for browser, OS, viewport, DPR, user agent, framework
    • {{CONSOLE_ERRORS_HTML}}
      — each error as a styled div
    • {{NETWORK_ERRORS_HTML}}
      — each failed request as a styled div
  3. Write the populated HTML to
    ./bugshot-report-{timestamp}.html
    in the project root
  4. Tell the user the file path so they can open it in a browser

GitHub Mode (
$ARGUMENTS
= "github" or "issue")

File a GitHub issue:

  1. Build a markdown body with these sections:
    ## Bug Report
    
    **URL:** [page url]
    **Severity:** [severity]
    **Framework:** [detected framework]
    
    ### Description
    [Claude's diagnosis summary]
    
    ### Console Errors
    
    [error messages with stack traces]
    
    ### 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)*
    
  2. Run:
    gh issue create --title "[title]" --body "[body]" --label bug
  3. Output the issue URL

Watch Mode (
$ARGUMENTS
= "watch" or "monitor")

Continuous error monitoring:

  1. Take initial baseline — read current console errors and network requests
  2. Inform the user: "Watching for new errors. I'll alert you when something breaks."
  3. Every 30 seconds:
    • Re-read console messages (with
      auto_clear: true
      to get only new ones)
    • 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
  4. Stop when the user says to stop

Phase 4: Verify (Fix mode only)

After applying fixes:

  1. Wait 2-3 seconds for hot reload / dev server refresh
  2. Take a fresh screenshot via
    mcp__claude-in-chrome__computer
  3. Re-read console errors via
    mcp__claude-in-chrome__read_console_messages
  4. Re-read network requests via
    mcp__claude-in-chrome__read_network_requests
  5. Compare before vs after:
    • Are the original errors gone?
    • Are there any NEW errors introduced?
    • Does the screenshot show the expected content now?
  6. If still broken: analyze the remaining errors, apply a second fix, and verify again
  7. 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
    ToolSearch
    before first use in the session
  • Call
    tabs_context_mcp
    FIRST before any other browser tool
  • 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