chrome-devtools-cli
它能做什么
它为 AI 智能体提供一个命令行工具,通过 DevTools 驱动 Chrome。适用于想用脚本自动化浏览器任务或测试网站的人。
适用场景
- ✓当你想要一个脚本,用来打开网页、点击按钮或填写表单时。
- ✓当你需要页面快照,以便找到自动化测试所需的元素时。
- ✓当你想从终端检查网页的行为时。
技能链接
https://github.com/humanlayer/humanlayer/blob/main/.claude/skills/chrome-devtools-cli/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我在 Chrome 中打开我的网站,填写联系表单,并告诉我它是否提交成功。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会先为页面拍一个文字快照,找到每个元素,然后点击或输入。浏览器会话在命令之间保持打开,所以各步骤可以相互衔接。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
The chrome-devtools-mcp CLI lets you interact with the browser from your terminal.
Setup
Note: If this is your very first time using the CLI, see references/installation.md for setup. Installation is a one-time prerequisite and is not part of the regular AI workflow.
AI Workflow
- Execute: Run tools directly (e.g.,
chrome-devtools list_pages). The background server starts implicitly; do not runstart/status/stopbefore each use. - Inspect: Use
take_snapshotto get an element<uid>. - Act: Use
click,fill, etc. State persists across commands.
Snapshot example:
uid=1_0 RootWebArea "Example Domain" url="https://example.com/"
uid=1_1 heading "Example Domain" level="1"
Command Usage
chrome-devtools <tool> [arguments] [flags]
Use --help on any command. Output defaults to Markdown, use --output-format=json for JSON.
Input Automation (<uid> from snapshot)
chrome-devtools take_snapshot --help # Help message for commands, works for any command.
chrome-devtools take_snapshot # Take a text snapshot of the page to get UIDs for elements
chrome-devtools click "id" # Clicks on the provided element
chrome-devtools click "id" --dblClick true --includeSnapshot true # Double clicks and returns a snapshot
chrome-devtools drag "src" "dst" # Drag an element onto another element
chrome-devtools drag "src" "dst" --includeSnapshot true # Drag an element and return a snapshot
chrome-devtools fill "id" "text" # Type text into an input or select an option
chrome-devtools fill "id" "text" --includeSnapshot true # Fill an element and return a snapshot
chrome-devtools handle_dialog accept # Handle a browser dialog
chrome-devtools handle_dialog dismiss --promptText "hi" # Dismiss a dialog with prompt text
chrome-devtools hover "id" # Hover over the provided element
chrome-devtools hover "id" --includeSnapshot true # Hover over an element and return a snapshot
chrome-devtools press_key "Enter" # Press a key or key combination
chrome-devtools press_key "Control+A" --includeSnapshot true # Press a key and return a snapshot
chrome-devtools type_text "hello" # Type text using keyboard into a focused input
chrome-devtools type_text "hello" --submitKey "Enter" # Type text and press a submit key
chrome-devtools upload_file "id" "file.txt" # Upload a file through a provided element
chrome-devtools upload_file "id" "file.txt" --includeSnapshot true # Upload a file and return a snapshot
Navigation
chrome-devtools close_page 1 # Closes the page by its index
chrome-devtools list_pages # Get a list of pages open in the browser
chrome-devtools navigate_page --url "https://example.com" # Navigates the currently selected page to a URL
chrome-devtools navigate_page --type "reload" --ignoreCache true # Reload page ignoring cache
chrome-devtools navigate_page --url "https://example.com" --timeout 5000 # Navigate with a timeout
chrome-devtools navigate_page --handleBeforeUnload "accept" # Handle before unload dialog
chrome-devtools navigate_page --type "back" --initScript "foo()" # Navigate back and run an init script
chrome-devtools new_page "https://example.com" # Creates a new page
chrome-devtools new_page "https://example.com" --background true --timeout 5000 # Create new page in background
chrome-devtools new_page "https://example.com" --isolatedContext "ctx" # Create new page with isolated context
chrome-devtools select_page 1 # Select a page as a context for future tool calls
chrome-devtools select_page 1 --bringToFront true # Select a page and bring it to front
Emulation
chrome-devtools emulate --networkConditions "Offline" # Emulate network conditions
chrome-devtools emulate --cpuThrottlingRate 4 --geolocation "0,0" # Emulate CPU throttling and geolocation
chrome-devtools emulate --colorScheme "dark" --viewport "1920x1080" # Emulate color scheme and viewport
chrome-devtools emulate --userAgent "Mozilla/5.0..." # Emulate user agent
chrome-devtools resize_page 1920 1080 # Resizes the selected page's window
Performance
chrome-devtools performance_analyze_insight "1" "LCPBreakdown" # Get more details on a specific Performance Insight
chrome-devtools performance_start_trace true false # Starts a performance trace recording
chrome-devtools performance_start_trace true true --filePath t.gz # Start trace and save to a file
chrome-devtools performance_stop_trace # Stops the active performance t
常见问题
我需要先设置什么吗?
需要。首次使用前要进行一次性安装,具体见该技能的设置说明。
我能把输出作为数据获取吗?
可以。添加 JSON 输出选项后,会返回结构化结果,而不是 Markdown。
为什么智能体要先拍快照?
快照会列出每个元素及其 ID,智能体需要这些 ID 才能点击或填写该元素。
详情
作者的原始描述
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.
repo: humanlayer/humanlayer
热度
- GitHub 星标
- 13k
- 排名
- #11383
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
asd-ste100
13k教你的智能体把难懂的英文改写成短句、每句只有一个意思,方便人和其他软件阅读。
better-github-skill
13k帮你的智能体查看拉取请求的状态、阅读其审查评论,并借助现成的 GitHub 脚本找出 CI 构建失败的原因。
calldiff
13k帮你的智能体比较代码库中两个 git 版本之间的函数调用链,让代码审查能看出行为发生了什么变化。
effect-program-design
13k帮你的智能体设计并测试可用于生产环境的 Effect v4 程序,包括清晰的服务、类型化错误、层以及对资源的安全处理。