chrome-debug

Use when debugging web applications in chrome via the remote debugging protocol. Provides capabilities for inspecting DOM, executing JS, taking screenshots, and automating browser interactions.

$ 安裝

git clone https://github.com/zenobi-us/dotfiles /tmp/dotfiles && cp -r /tmp/dotfiles/ai/files/skills/devtools/chrome-debug ~/.claude/skills/dotfiles

// tip: Run this command in your terminal to install the skill


name: chrome-debug description: Use when debugging web applications in chrome via the remote debugging protocol. Provides capabilities for inspecting DOM, executing JS, taking screenshots, and automating browser interactions.

Chrome Debugging and Browser Manipulation via Remote Debugging Prodocol

Overview

Chrome DevTools Protocol (CDP) enables remote browser automation and debugging.

This skill documents the integration pattern, startup requirements, and common workflows for debugging web applications via Agent with live browser interaction.

  • Live browser debugging alongside Agent conversations
  • Automated form filling and interaction testing
  • Visual feedback on application behavior
  • Immediate error diagnostics from console logs
  • Screenshot-based validation workflows

Prerequisites [CRITICAL]

mise x node@20 -- mcporter call 'chrome-devtools.getVersion'

This command must return Chrome version info. If it fails, get a human to help.

Available Tools

ToolPurpose
clickClick an element on the page
close_pageClose a browser page/tab
dragDrag and drop elements
emulateEmulate device settings (viewport, user agent, etc.)
evaluate_scriptExecute JavaScript code in the page context
fillFill input fields with text
fill_formFill and submit an entire form
get_console_messageGet a specific console message
get_network_requestGet details of a specific network request
handle_dialogHandle browser dialogs (alert, confirm, prompt)
hoverHover over an element to trigger hover states
list_console_messagesGet all console messages (logs, errors, warnings)
list_network_requestsGet all network requests made by the page
list_pagesList all open pages/tabs
navigate_pageNavigate to a URL
new_pageCreate a new browser page/tab
performance_analyze_insightAnalyze performance metrics and provide insights
performance_start_traceStart performance tracing
performance_stop_traceStop performance tracing and get results
press_keyPress keyboard keys (Enter, Tab, Escape, etc.)
resize_pageResize the browser viewport
select_pageSelect a specific page/tab to work with
take_screenshotCapture a screenshot of the current page
take_snapshotTake a DOM snapshot for inspection
upload_fileUpload files via file input fields
wait_forWait for elements, navigation, or conditions

Quick Reference

Taskmcporter Call
Check Chrome listeningmise x node@20 -- mcporter call 'chrome-devtools.getVersion'
List browser tabsmise x node@20 -- mcporter call 'chrome-devtools.getTabs(targetId: "<id>")'
Take screenshotmise x node@20 -- mcporter call 'chrome-devtools.takeScreenshot(targetId: "<id>")'
Click elementmise x node@20 -- mcporter call 'chrome-devtools.clickElement(targetId: "<id>", selector: "#login")'
Fill form fieldmise x node@20 -- mcporter call 'chrome-devtools.fillFormField(targetId: "<id>", selector: "#email", value: "test@example.com")'
Get page contentmise x node@20 -- mcporter call 'chrome-devtools.getPageContent(targetId: "<id>")'
Navigate to URLmise x node@20 -- mcporter call 'chrome-devtools.navigateToUrl(targetId: "<id>", url: "http://localhost:3000")'
Run JavaScriptmise x node@20 -- mcporter call 'chrome-devtools.evaluateScript(targetId: "<id>", script: "document.title")'
Read consolemise x node@20 -- mcporter call 'chrome-devtools.getConsoleOutput(targetId: "<id>")'

Common Workflows

1. Inspect Web Application State

You: "Navigate to http://localhost:3000 and take a screenshot"
Agent uses Chrome DevTools Protocol → Takes screenshot → Returns visual state

2. Debug JavaScript Errors

You: "Open DevTools console and read the error messages"
Agent uses Chrome DevTools Protocol → Reads console → Explains errors

3. Automated Testing/Validation

You: "Fill the form with test data and submit it"
Agent uses Chrome DevTools Protocol → Automates interaction → Reports results

4. DOM Inspection

You: "Find the login button and tell me its HTML"
Agent uses Chrome DevTools Protocol → Inspects element → Returns HTML/attributes

Detailed Examples

Example 1: Hover Detection & Measurement

Hover an element and measure its dimensions after CSS transitions complete:

# Get target ID
TARGET_ID=$(mise x node@20 -- mcporter call 'chrome-devtools.getTabs' | jq -r '.[0].id')

# Hover the element and measure its computed dimensions
mise x node@20 -- mcporter call 'chrome-devtools.evaluateScript(targetId: "'$TARGET_ID'", script: "const el = document.querySelector(\".tooltip-trigger\"); const bounds = el.getBoundingClientRect(); el.dispatchEvent(new MouseEvent(\"mouseover\", { bubbles: true })); setTimeout(() => { const tooltip = document.querySelector(\".tooltip\"); const tooltipBounds = tooltip.getBoundingClientRect(); console.log(JSON.stringify({ trigger: { x: bounds.x, y: bounds.y, width: bounds.width, height: bounds.height }, tooltip: { x: tooltipBounds.x, y: tooltipBounds.y, width: tooltipBounds.width, height: tooltipBounds.height } })); }, 300);")'

Example 2: Performance Measurement & Storage

Execute JavaScript to measure page performance metrics and store results:

TARGET_ID=$(mise x node@20 -- mcporter call 'chrome-devtools.getTabs' | jq -r '.[0].id')

# Measure performance metrics
METRICS=$(mise x node@20 -- mcporter call 'chrome-devtools.evaluateScript(targetId: "'$TARGET_ID'", script: "const perf = performance.getEntriesByType(\"navigation\")[0]; { pageLoadTime: perf.loadEventEnd - perf.fetchStart, domInteractive: perf.domInteractive - perf.fetchStart, domContentLoaded: perf.domContentLoadedEventEnd - perf.fetchStart, firstPaint: performance.getEntriesByName(\"first-paint\")[0]?.startTime || null, memoryUsage: performance.memory ? performance.memory.usedJSHeapSize : null }")')

# Store results
echo "$METRICS" | jq '.' > ./perf-metrics-$(date +%s).json

Example 3: Screenshot Capture & Storage Workflow

Navigate, interact, and capture sequential screenshots:

TARGET_ID=$(mise x node@20 -- mcporter call 'chrome-devtools.getTabs' | jq -r '.[0].id')
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
SCREENSHOT_DIR="./screenshots/$TIMESTAMP"
mkdir -p "$SCREENSHOT_DIR"

# Take initial state screenshot
mise x node@20 -- mcporter call 'chrome-devtools.takeScreenshot(targetId: "'$TARGET_ID'")' > "$SCREENSHOT_DIR/01-initial.png"

# Navigate and take screenshot
mise x node@20 -- mcporter call 'chrome-devtools.navigateToUrl(targetId: "'$TARGET_ID'", url: "http://localhost:3000/page")'

# Wait for load and capture
sleep 2
mise x node@20 -- mcporter call 'chrome-devtools.takeScreenshot(targetId: "'$TARGET_ID'")' > "$SCREENSHOT_DIR/02-after-nav.png"

# Interact and capture
mise x node@20 -- mcporter call 'chrome-devtools.clickElement(targetId: "'$TARGET_ID'", selector: ".expand-button")'

sleep 1
mise x node@20 -- mcporter call 'chrome-devtools.takeScreenshot(targetId: "'$TARGET_ID'")' > "$SCREENSHOT_DIR/03-after-click.png"

# Generate summary
echo "Screenshots saved to: $SCREENSHOT_DIR"
ls -lh "$SCREENSHOT_DIR"

Real-World Impact

Integrating Chrome DevTools Protocol into mcporter enables:

  • Live browser debugging alongside Agent conversations
  • Automated form filling and interaction testing
  • Visual feedback on application behavior
  • Immediate error diagnostics from console logs
  • Screenshot-based validation workflows

Without this integration, debugging web applications requires context-switching between browser and Agent.