关于 Browser
Browser 是使用 agent-browser CLI 进行浏览器自动化的技能,面向需要自动操作网页的用户。它支持无头会话、持久化身份验证配置、页面交互、截图及可复用的任务配方。
主要功能
- 01通过 agent-browser CLI 自动操作网页
- 02持久化身份验证配置
- 03支持页面交互与截图
- 04批量执行会话命令
- 05运行 YAML 故事验证与配方
适用场景
- 01使用已保存的身份验证浏览网页
- 02截取网页截图或 PDF
- 03运行可重复的表单填写配方
- 04验证多个页面的 UI 故事
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ danielmiessler/ lifeos --skill browser安装后在 Claude Code 中输入/browser确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
README.mdRecipes/README.mdFormFill.mdSummarizePage.mdScreenshotCompare.mdStories/README.mdExampleApp.yamlHackerNews.yamlWorkflows/Automate.mdReviewStories.mdUpdate.md详细介绍
自定义设置
执行前,请检查以下位置是否有用户自定义设置:
~/.claude/PAI/USER/SKILLCUSTOMIZATIONS/Browser/
如果此目录存在,请加载并应用其中的任何 PREFERENCES.md、配置或资源。这些设置会覆盖默认行为。如果此目录不存在,则使用技能默认设置。
强制要求:语音通知(执行任何操作前必须完成)
调用此技能时,必须先发送此通知,然后才能执行任何操作。
-
发送语音通知:
curl -s -X POST http://localhost:31337/notify \ -H "Content-Type: application/json" \ -d '{"message": "Running the WORKFLOWNAME workflow in the Browser skill to ACTION"}' \ > /dev/null 2>&1 & -
输出文本通知:
Running the **WorkflowName** workflow in the **Browser** skill to ACTION...
这不是可选步骤。调用此技能后,请立即执行此 curl 命令。
Browser v10.0.0 — 浏览器自动化
工具: agent-browser — 具有持久身份验证配置文件的无头 Rust CLI 守护进程。
如果 agent-browser 无法运行,或者网站启用了机器人检测,请改用 Interceptor 技能。 Interceptor 是一款 Chrome 扩展,不带 CDP 指纹,可通过所有主要机器人检测检查。
网站需要身份验证吗?
使用 --profile ~/.agent-browser/profiles/<site>。如果配置文件已存在,身份验证会自动完成。如果不存在,请运行一次 --headed 完成登录,此后即可始终使用无头模式。
agent-browser
原生 Rust 守护进程。用于身份验证的持久配置文件。默认使用无头模式。
快速单次命令
agent-browser open https://example.com && agent-browser screenshot /tmp/shot.png
agent-browser open https://example.com && agent-browser screenshot --full /tmp/full.png
agent-browser open https://example.com && agent-browser pdf /tmp/page.pdf
基于会话的交互
# 1. OPEN
agent-browser open https://example.com
# 2. WORK
agent-browser snapshot # a11y tree with @eN refs (for AI)
agent-browser click @e12 # click by ref
agent-browser fill @e15 "hello" # fill input by ref
agent-browser screenshot /tmp/shot.png # screenshot
agent-browser eval "document.title" # run JS
# 3. CLOSE — when done
agent-browser close
已验证身份的浏览(按站点使用配置文件)
首次设置(有头模式,仅需一次):
# Close any running daemon first
agent-browser close --all
# Launch headed with persistent profile — log in manually
agent-browser --headed --profile ~/.agent-browser/profiles/<site> open https://example.com
# After login completes, all future runs reuse the profile headlessly
后续运行(无头模式,自动执行):
agent-browser --profile ~/.agent-browser/profiles/<site> open https://example.com
# Auth is automatic — cookies, IndexedDB, cache all persist
**添加新站点:**关闭守护进程,运行一次 --headed --profile ~/.agent-browser/profiles/<name>,登录即可。
身份验证保险库(替代方案)
agent-browser auth save mysite --url https://example.com --username user --password-stdin
agent-browser auth login mysite # auto-fills login form
agent-browser auth list # show saved profiles
批量执行
# Send multiple commands in one shot (fewer tool calls = fewer tokens)
echo '[["open","https://example.com"],["snapshot"],["click","@e12"]]' | agent-browser batch
高级功能
# Connect to already-running Chrome
agent-browser --auto-connect snapshot
# Network interception
agent-browser route "**/*.{png,jpg}" abort # block images
agent-browser route "https://api.com/*" mock '{"data":"test"}'
# Device emulation
agent-browser --device "iPhone 15" open https://example.com
# Session persistence (cookies + localStorage by name)
agent-browser --session-name myapp open https://example.com
agent-browser 规则
- 守护进程模型 — 第一个命令会启动守护进程,后续命令可立即连接。
- 引用使用 @eN 语法 — 使用
@e12,而不是e12。 - 配置文件会持久保存所有内容 — Cookie、IndexedDB、缓存和 localStorage。
- 使用
agent-browser close或close --all关闭,以终止守护进程。
将浏览器工作委派给 Agent
需要并行或在后台进行浏览器工作时(例如抓取多个页面、监控),请使用浏览器操作说明启动通用 Agent。无需专用的浏览器 Agent 类型——本技能本身就是这方面的专业能力。
Agent(subagent_type="general-purpose", prompt="
Use agent-browser CLI for all browser work.
Commands: open <url>, snapshot, click @eN, fill @eN 'text', screenshot /path.
For authenticated sites: --profile ~/.agent-browser/profiles/<site>
Refs use @eN syntax from snapshots.
[your specific task instructions here]
")
如需并行隔离,每个 Agent 使用 --session <name>:
Agent 1: agent-browser --session scrape1 open https://site-a.com
Agent 2: agent-browser --session scrape2 open https://site-b.com
**备用方案:**如果 agent-browser 失败或网站启用了机器人检测,请改用 Interceptor 技能。
**旧版内置 Agent——已弃用,请勿调用。**BrowserAgent 和 UIReviewer 是 Claude Code 内置组件,其内部实现无法修改;它们会运行 PAI 已不再使用的浏览器自动化。所有浏览器工作都应通过 Interceptor 技能(验证、已验证身份的流程)或 agent-browser(无头抓取)执行。
工作流路由
| 触发词 | 工作流 | 功能 |
|---|---|---|
| “review stories”、“run stories”、“ui review”、“validate stories” | Workflows/ReviewStories.md | 将 YAML 故事分派给多个并行 UIReviewer |
| “automate”、“recipe”、“template”或某个配方名称 | Workflows/Automate.md | 加载并执行参数化配方模板 |
| “update”、“check version” | Workflows/Update.md | 验证浏览器工具是否为最新版本且运行正常 |
Stories — YAML 用户故事验证
使用 YAML 定义用户故事,并通过并行运行的 UIReviewer Agent 对其进行验证。
目录:skills/Browser/Stories/
name: App Name
url: https://example.com
stories:
- name: Story name
steps:
- action: click
target: "LLM-readable description"
assertions:
- type: snapshot_contains
text: "expected text"
运行方式:"review stories" 或 "run stories in HackerNews.yaml"
配方 — 参数化模板
可重复使用的 Markdown 模板,支持注入 {PROMPT}。
目录: skills/Browser/Recipes/
| 配方 | 描述 | 工具 |
|---|---|---|
SummarizePage.md | 提取内容摘要 | BrowserAgent |
ScreenshotCompare.md | 对比前后状态 | agent-browser |
FormFill.md | 填写表单字段 | agent-browser |
运行方式:"automate SummarizePage for https://example.com"
执行日志
完成任何工作流后,追加一条 JSONL 记录:
echo '{"ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","skill":"Browser","workflow":"WORKFLOW_USED","input":"8_WORD_SUMMARY","status":"ok|error","duration_s":SECONDS}' >> ~/.claude/PAI/MEMORY/SKILLS/execution.jsonl