Skip to content

Commit 264b165

Browse files
omalleyandyclaude
andcommitted
docs: recreate skill docs for v0.17.0
Rebuild all four skill reference docs from current codebase: - SKILL.md: main overview with capabilities, workflows, CLI, features - network-and-console-breakdown.md: collector/formatter data flow - network-for-scraping-discovery.md: network-first API discovery guide - reference.md: quick tool reference for all 30 tools Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c1d0632 commit 264b165

4 files changed

Lines changed: 579 additions & 27 deletions

File tree

skills/chrome-devtools/SKILL.md

Lines changed: 84 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,101 @@
11
---
22
name: chrome-devtools
3-
description: Uses Chrome DevTools via MCP for efficient debugging, troubleshooting and browser automation. Use when debugging web pages, automating browser interactions, analyzing performance, or inspecting network requests.
3+
description: >
4+
Chrome DevTools MCP server for browser automation, debugging,
5+
network inspection, console analysis, and performance tracing.
6+
Controls Chrome via Puppeteer/CDP. v0.17.0.
47
---
58

69
## Core Concepts
710

8-
**Browser lifecycle**: Browser starts automatically on first tool call using a persistent Chrome profile. Configure via CLI args in the MCP server configuration: `npx chrome-devtools-mcp@latest --help`.
11+
**Browser lifecycle**: Browser starts on first tool call using a
12+
persistent Chrome profile. Configure via CLI args:
13+
`npx chrome-devtools-mcp@latest --help`.
914

10-
**Page selection**: Tools operate on the currently selected page. Use `list_pages` to see available pages, then `select_page` to switch context.
15+
**Page selection**: Tools operate on the currently selected page.
16+
`list_pages` to see pages, `select_page` to switch context.
1117

12-
**Element interaction**: Use `take_snapshot` to get page structure with element `uid`s. Each element has a unique `uid` for interaction. If an element isn't found, take a fresh snapshot - the element may have been removed or the page changed.
18+
**Element interaction**: `take_snapshot` returns an a11y tree with
19+
unique `uid` references. Use UIDs with `click`, `fill`, `drag`, etc.
20+
Always take a fresh snapshot if elements aren't found.
1321

14-
## Workflow Patterns
15-
16-
### Before interacting with a page
17-
18-
1. Navigate: `navigate_page` or `new_page`
19-
2. Wait: `wait_for` to ensure content is loaded if you know what you look for.
20-
3. Snapshot: `take_snapshot` to understand page structure
21-
4. Interact: Use element `uid`s from snapshot for `click`, `fill`, etc.
22-
23-
### Efficient data retrieval
22+
## Capabilities at a Glance
2423

25-
- Use `filePath` parameter for large outputs (screenshots, snapshots, traces)
26-
- Use pagination (`pageIdx`, `pageSize`) and filtering (`types`) to minimize data
27-
- Set `includeSnapshot: false` on input actions unless you need updated page state
24+
| Category | Tools | Key Use |
25+
|----------|-------|---------|
26+
| **Snapshots** | `take_snapshot`, `take_screenshot` | See page structure/visuals |
27+
| **Input** | `click`, `fill`, `fill_form`, `press_key`, `drag`, `hover`, `upload_file`, `handle_dialog` | Interact with elements |
28+
| **Navigation** | `navigate_page`, `new_page`, `close_page`, `list_pages`, `select_page`, `wait_for` | Control page lifecycle |
29+
| **Network** | `list_network_requests`, `get_network_request` | Inspect HTTP traffic |
30+
| **Console** | `list_console_messages`, `get_console_message` | Debug logs/errors |
31+
| **Performance** | `performance_start_trace`, `performance_stop_trace`, `performance_analyze_insight` | CWV scores, bottlenecks |
32+
| **Emulation** | `emulate`, `resize_page` | Device/network simulation |
33+
| **Script** | `evaluate_script` | Run JS in page context |
34+
| **Extensions** | `install_extension`, `uninstall_extension`, `list_extensions`, `reload_extension` | Manage Chrome extensions |
2835

29-
### Tool selection
30-
31-
- **Automation/interaction**: `take_snapshot` (text-based, faster, better for automation)
32-
- **Visual inspection**: `take_screenshot` (when user needs to see visual state)
33-
- **Additional details**: `evaluate_script` for data not in accessibility tree
34-
35-
### Parallel execution
36+
## Workflow Patterns
3637

37-
You can send multiple tool calls in parallel, but maintain correct order: navigate → wait → snapshot → interact.
38+
### Standard page interaction
39+
1. Navigate: `navigate_page` or `new_page`
40+
2. Wait: `wait_for` if you know expected content
41+
3. Snapshot: `take_snapshot` to get element UIDs
42+
4. Interact: `click`, `fill`, etc. using UIDs
43+
44+
### Network-first scraping
45+
1. `navigate_page` to target URL
46+
2. `list_network_requests(resourceTypes: ["xhr", "fetch"])` to find APIs
47+
3. `get_network_request(reqid)` to inspect response bodies
48+
4. Or use `evaluate_script` with `fetch()` for reliable data retrieval
49+
50+
### Console debugging
51+
1. Navigate to page (errors collected automatically)
52+
2. `list_console_messages(types: ["error"])` to find errors
53+
3. `get_console_message(msgid)` for full stack trace + cause chain
54+
4. Source-mapped locations show original file/line/column
55+
56+
### Performance analysis
57+
1. `navigate_page` to target URL first
58+
2. `performance_start_trace(reload: true, autoStop: true)`
59+
3. Review CWV scores + insight sets in response
60+
4. `performance_analyze_insight(insightSetId, insightName)` for details
61+
5. CrUX field data included by default (disable: `--no-performance-crux`)
62+
63+
## Key Features (v0.17.0)
64+
65+
- **CrUX field data**: Real-user LCP, INP, CLS in performance traces
66+
- **Error.cause chains**: Full cause hierarchy for uncaught errors
67+
- **Error objects in console.log**: Message + stack when logging Errors
68+
- **Source-mapped stacks**: Original file/line/column (v0.16.0+)
69+
- **Ignored script filtering**: Internal frames hidden from traces
70+
- **Navigation scoping**: Data split per navigation, 3 preserved
71+
- **Lazy formatting**: Bodies/stacks resolved only when requested
72+
73+
## Efficiency Tips
74+
75+
- Use `filePath` for large outputs (screenshots, traces, snapshots)
76+
- Use pagination (`pageIdx`, `pageSize`) and type filters to limit data
77+
- Set `includeSnapshot: false` on input actions when snapshot not needed
78+
- Response bodies expire fast -- fetch promptly or use `evaluate_script`
79+
- Prefer `take_snapshot` over `take_screenshot` for automation
80+
- Parallel tool calls OK, but maintain order: navigate -> wait -> snap
81+
82+
## CLI Quick Reference
83+
84+
```
85+
--browserUrl URL Connect via HTTP CDP endpoint
86+
--wsEndpoint URL Connect via WebSocket
87+
--autoConnect Auto-find running Chrome 144+
88+
--executablePath PATH Launch specific Chrome binary
89+
--isolated Temp profile, auto-cleaned
90+
--headless No UI
91+
--viewport WxH Initial viewport size
92+
--no-usage-statistics Disable telemetry
93+
--no-performance-crux Disable CrUX in traces
94+
--no-category-network Disable network tools
95+
```
3896

3997
## Troubleshooting
4098

41-
If `chrome-devtools-mcp` is insufficient, guide users to use Chrome DevTools UI:
42-
99+
If chrome-devtools-mcp is insufficient, guide users to Chrome DevTools:
43100
- https://developer.chrome.com/docs/devtools
44101
- https://developer.chrome.com/docs/devtools/ai-assistance
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# Network & Console Data Flow
2+
3+
Deep dive into how Chrome DevTools MCP collects, stores, and formats
4+
network requests and console messages.
5+
6+
## Collection Layer (PageCollector.ts)
7+
8+
### Storage Model
9+
10+
Both collectors use `PageCollector<T>` base class with per-navigation
11+
bucketing:
12+
13+
```
14+
WeakMap<Page, T[][]>
15+
Page -> [
16+
[items from current navigation], // bucket 0
17+
[items from previous navigation], // bucket 1
18+
[items from 2 navigations ago], // bucket 2
19+
]
20+
```
21+
22+
On `framenavigated` (main frame), a new empty bucket is pushed and the
23+
oldest is dropped. This gives 3-navigation retention.
24+
25+
Each item gets a **stable ID** (monotonic counter per page) that
26+
persists across the session. IDs are used as `reqid` and `msgid` in
27+
tool responses.
28+
29+
### NetworkCollector
30+
31+
- Subscribes to `page.on('request')` for every HTTPRequest
32+
- On navigation, keeps the triggering request in the new bucket
33+
(so the navigation request itself is visible)
34+
- Stores raw `HTTPRequest` objects (Puppeteer)
35+
36+
### ConsoleCollector
37+
38+
Collects three types of items into one stream:
39+
40+
| Type | Source | How Collected |
41+
|------|--------|---------------|
42+
| `ConsoleMessage` | `console.log/warn/error/...` | `page.on('console')` |
43+
| `UncaughtError` | Unhandled exceptions | CDP `Runtime.exceptionThrown` |
44+
| `AggregatedIssue` | DevTools audit issues | CDP `Audits.issueAdded` |
45+
46+
Uses `PageEventSubscriber` internally to bridge Puppeteer events to CDP:
47+
- Enables `Audits.enable()` on the CDP session
48+
- Runs `IssueAggregator` to deduplicate issues by primary key
49+
- Resets issue tracking on navigation
50+
51+
## Formatting Layer (Formatters)
52+
53+
### NetworkFormatter
54+
55+
**Short format** (`toString()`):
56+
```
57+
reqid=1 GET https://example.com/api/data [200]
58+
reqid=2 POST https://example.com/submit [302]
59+
```
60+
61+
**Detailed format** (`toStringDetailed()`):
62+
```markdown
63+
## Request: GET https://example.com/api/data
64+
### Request headers
65+
- Accept: application/json
66+
- Cookie: session=abc123
67+
68+
### Response headers
69+
- Content-Type: application/json
70+
- Cache-Control: no-cache
71+
72+
### Response body
73+
{"users": [{"id": 1, "name": "Alice"}]}
74+
```
75+
76+
Key behaviors:
77+
- **Lazy loading**: Bodies only fetched when `fetchData: true`
78+
- **Size limit**: Response bodies truncated at 10KB inline
79+
- **File save**: `requestFilePath`/`responseFilePath` bypass truncation
80+
- **Binary check**: Non-UTF-8 responses show `<binary data>`
81+
- **Redirect chains**: Recursively formatted with indentation
82+
- **Expiration**: Bodies expire from browser memory quickly
83+
84+
### ConsoleFormatter
85+
86+
**Short format** (`toString()`):
87+
```
88+
msgid=1 [log] Hello world (0 args)
89+
msgid=2 [error] TypeError: Cannot read properties of undefined (1 args)
90+
```
91+
92+
**Detailed format** (`toStringDetailed()`):
93+
```markdown
94+
## Console message
95+
- msgid: 2
96+
- type: error
97+
- text: TypeError: Cannot read properties of undefined
98+
99+
### Arguments
100+
- Argument 0: {"type": "object", "value": {...}}
101+
102+
### Stack trace
103+
at fetchData (src/api.ts:42:15)
104+
at handleClick (src/components/Button.tsx:18:5)
105+
--- setTimeout ---
106+
at scheduleUpdate (src/scheduler.ts:7:3)
107+
108+
### Caused by: NetworkError: Failed to fetch
109+
at doFetch (src/api.ts:30:11)
110+
at fetchData (src/api.ts:40:20)
111+
```
112+
113+
Key behaviors:
114+
- **Argument resolution**: Async `jsonValue()` extraction from RemoteObjects
115+
- **Source-mapped stacks**: Waits up to 1000ms for source maps to load
116+
via `SymbolizedError.createStackTrace()`
117+
- **Error.cause chains** (v0.17.0): Recursively resolves `error.cause`
118+
property, each rendered as "Caused by:" section
119+
- **Error objects in console.log** (v0.17.0): When an Error instance is
120+
passed to `console.log()`, shows its message and stack trace
121+
- **Frame filtering**: Frames from ignored scripts (node_modules,
122+
browser internals) are hidden
123+
- **50-line limit**: Stack traces capped at 50 frames
124+
- **Async fragments**: Shows async boundaries ("--- setTimeout ---")
125+
126+
### IssueFormatter
127+
128+
**Short format**: `msgid=3 [issue] Mixed Content (count: 2)`
129+
130+
**Detailed format**: Markdown with issue description, learn-more links,
131+
and affected resources (elements mapped to `uid`, requests to `reqid`).
132+
133+
Issues are aggregated -- multiple occurrences of the same issue type
134+
are pooled into one `AggregatedIssue` with a count.
135+
136+
## SymbolizedError (DevtoolsUtils.ts)
137+
138+
Central class for resolved error data with source-mapped stack traces.
139+
140+
### Creation paths
141+
142+
1. `fromDetails(opts)` -- From `Runtime.ExceptionDetails` (uncaught)
143+
2. `fromError(opts)` -- From `RemoteObject` with `subtype='error'`
144+
(error objects in console.log)
145+
146+
### Resolution process
147+
148+
1. Extract message from exception details
149+
2. Collect script IDs from all call frames (sync + async)
150+
3. Wait for scripts to parse (`waitForScript`, up to 1000ms)
151+
4. Wait for source maps (`sourceMapManager.sourceMapForClientPromise`)
152+
5. Call `DebuggerWorkspaceBinding.createStackTraceFromProtocolRuntime()`
153+
6. Result: frames with original file paths, line numbers, column numbers
154+
155+
### Cause chain
156+
157+
Walks `error.cause` property via CDP `Runtime.getProperties`:
158+
1. Get error object's properties
159+
2. Find `cause` property
160+
3. If cause is an Error, recursively create `SymbolizedError`
161+
4. Result: linked list of `SymbolizedError` objects
162+
163+
## Practical Tips
164+
165+
### Catching API responses
166+
167+
```
168+
# Option A: Network panel (bodies may expire)
169+
list_network_requests(resourceTypes: ["xhr", "fetch"])
170+
get_network_request(reqid=5, responseFilePath: "response.json")
171+
172+
# Option B: evaluate_script (reliable, no expiration)
173+
evaluate_script(function: "async () => {
174+
const r = await fetch('/api/data');
175+
return r.json();
176+
}")
177+
```
178+
179+
### Debugging errors efficiently
180+
181+
```
182+
# 1. Find errors
183+
list_console_messages(types: ["error"])
184+
185+
# 2. Get details (stack trace + cause chain)
186+
get_console_message(msgid=2)
187+
188+
# 3. Check preserved messages from prior navigations
189+
list_console_messages(includePreservedMessages: true)
190+
```
191+
192+
### Monitoring network across navigations
193+
194+
```
195+
# See requests from last 3 page loads
196+
list_network_requests(includePreservedRequests: true)
197+
198+
# Filter to just API calls
199+
list_network_requests(resourceTypes: ["xhr", "fetch"])
200+
```

0 commit comments

Comments
 (0)