豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 753b64b

Browse files
committed
refactor: improve skill
1 parent 68a6ea0 commit 753b64b

File tree

2 files changed

+27
-33
lines changed

2 files changed

+27
-33
lines changed

skills/chrome-devtools-cli/SKILL.md

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,32 @@ name: chrome-devtools-cli
33
description: Use this to skill to write shell scripts or run shell commands to automate tasks in the browser or otherwise use Chrome DevTools via CLI.
44
---
55

6-
The `chrome-devtools-mcp` package includes a CLI interface that allows you to interact with the browser directly from your terminal. This is particularly useful for debugging or when you want an agent to generate scripts that automate browser actions.
6+
The `chrome-devtools-mcp` CLI lets you interact with the browser from your terminal.
77

8-
## Getting started
8+
## Setup
99

10-
Install the package globally to make the `chrome-devtools` command available:
10+
_Note: If this is your very first time using the CLI, see [references/installation.md](references/installation.md) for setup. Installation is a one-time prerequisite and is **not** part of the regular AI workflow._
1111

12-
```sh
13-
npm i chrome-devtools-mcp@latest -g
14-
chrome-devtools status # check if install worked.
15-
```
16-
17-
## How it works
12+
## AI Workflow
1813

19-
The CLI acts as a client to a background `chrome-devtools-mcp` daemon.
14+
1. **Execute**: Run tools directly (e.g., `chrome-devtools list_pages`). The background server starts implicitly; **do not** run `start`/`status`/`stop` before each use.
15+
2. **Inspect**: Use `take_snapshot` to get an element `<uid>`.
16+
3. **Act**: Use `click`, `fill`, etc. State persists across commands.
2017

21-
- **Automatic Start**: The first time you call a tool (e.g., `list_pages`), the CLI automatically starts the MCP server and the browser in the background if they aren't already running.
22-
- **Persistence**: The same background instance is reused for subsequent commands, preserving the browser state (open pages, cookies, etc.).
23-
- **Manual Control**: You can explicitly manage the background process using `start`, `stop`, and `status`. The `start` command forwards all subsequent arguments to the underlying MCP server (e.g., `--headless`, `--userDataDir`).
24-
25-
Snapshots looks like this:
18+
Snapshot example:
2619

2720
```
2821
uid=1_0 RootWebArea "Example Domain" url="https://example.com/"
2922
uid=1_1 heading "Example Domain" level="1"
30-
uid=1_2 StaticText "This domain is for use in documentation examples without needing permission. Avoid use in operations."
31-
uid=1_3 link "Learn more" url="https://iana.org/domains/example"
32-
uid=1_4 StaticText "Learn more
3323
```
3424

3525
## Command Usage
3626

37-
The CLI supports all tools available in the Chrome DevTools MCP by default.
38-
3927
```sh
4028
chrome-devtools <tool> [arguments] [flags]
4129
```
4230

43-
- **Required Arguments**: Passed as positional arguments.
44-
- **Optional Arguments**: Passed as flags (e.g., `--filePath`, `--fullPage`).
45-
- **--help**: Each command supports `--help` for details about arguments.
46-
47-
Each command accepts `--output-format=json` to output in JSON format. The default format is Markdown (`md`).
31+
Use `--help` on any command. Output defaults to Markdown, use `--output-format=json` for JSON.
4832

4933
## Input Automation (<uid> from snapshot)
5034

@@ -57,8 +41,6 @@ chrome-devtools drag "src" "dst" # Drag an element onto another element
5741
chrome-devtools drag "src" "dst" --includeSnapshot true # Drag an element and return a snapshot
5842
chrome-devtools fill "id" "text" # Type text into an input or select an option
5943
chrome-devtools fill "id" "text" --includeSnapshot true # Fill an element and return a snapshot
60-
chrome-devtools fill_form "json" # Fill out multiple form elements at once
61-
chrome-devtools fill_form "json" --includeSnapshot true # Fill a form and return a snapshot
6244
chrome-devtools handle_dialog accept # Handle a browser dialog
6345
chrome-devtools handle_dialog dismiss --promptText "hi" # Dismiss a dialog with prompt text
6446
chrome-devtools hover "id" # Hover over the provided element
@@ -86,8 +68,6 @@ chrome-devtools new_page "https://example.com" --background true --timeout 5000
8668
chrome-devtools new_page "https://example.com" --isolatedContext "ctx" # Create new page with isolated context
8769
chrome-devtools select_page 1 # Select a page as a context for future tool calls
8870
chrome-devtools select_page 1 --bringToFront true # Select a page and bring it to front
89-
chrome-devtools wait_for "Success!" # Wait for the specified text to appear on the page
90-
chrome-devtools wait_for "Success!" --timeout 10000 # Wait for text with a timeout
9171
```
9272

9373
## Emulation
@@ -115,11 +95,11 @@ chrome-devtools take_memory_snapshot "./snap.heapsnapshot" # Capture a memory he
11595

11696
```bash
11797
chrome-devtools get_network_request # Get the currently selected network request
118-
chrome-devtools get_network_request --reqid 1 --requestFilePath req.json # Get request by id and save to file
119-
chrome-devtools get_network_request --responseFilePath res.json # Save response body to file
98+
chrome-devtools get_network_request --reqid 1 --requestFilePath req.md # Get request by id and save to file
99+
chrome-devtools get_network_request --responseFilePath res.md # Save response body to file
120100
chrome-devtools list_network_requests # List all network requests
121101
chrome-devtools list_network_requests --pageSize 50 --pageIdx 0 # List network requests with pagination
122-
chrome-devtools list_network_requests --resourceTypes '["Fetch"]' # Filter requests by resource type
102+
chrome-devtools list_network_requests --resourceTypes Fetch # Filter requests by resource type
123103
chrome-devtools list_network_requests --includePreservedRequests true # Include preserved requests
124104
```
125105

@@ -134,7 +114,7 @@ chrome-devtools lighthouse_audit --mode "snapshot" --device "mobile" # Run Light
134114
chrome-devtools lighthouse_audit --outputDirPath ./out # Run Lighthouse audit and save reports
135115
chrome-devtools list_console_messages # List all console messages
136116
chrome-devtools list_console_messages --pageSize 20 --pageIdx 1 # List console messages with pagination
137-
chrome-devtools list_console_messages --types '["error"]' # Filter console messages by type
117+
chrome-devtools list_console_messages --types error --types info # Filter console messages by type
138118
chrome-devtools list_console_messages --includePreservedMessages true # Include preserved messages
139119
chrome-devtools take_screenshot # Take a screenshot of the page viewport
140120
chrome-devtools take_screenshot --fullPage true --format "jpeg" --quality 80 # Take a full page screenshot as JPEG with quality
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Installation
2+
3+
Install the package globally to make the `chrome-devtools` command available. You only need to do this the first time you use it.
4+
5+
```sh
6+
npm i chrome-devtools-mcp@latest -g
7+
chrome-devtools status # check if install worked.
8+
```
9+
10+
## Troubleshooting
11+
12+
- **Command not found:** If `chrome-devtools` is not recognized, ensure your global npm `bin` directory is in your system's `PATH`. Restart your terminal or source your shell configuration file (e.g., `.bashrc`, `.zshrc`).
13+
- **Permission errors:** If you encounter `EACCES` or permission errors during installation, avoid using `sudo`. Instead, use a node version manager like `nvm`, or configure npm to use a different global directory.
14+
- **Old version running:** Run `chrome-devtools stop && npm uninstall -g chrome-devtools-mcp` before reinstalling, or ensure the latest version is being picked up by your path.

0 commit comments

Comments
 (0)