src/skills/runtime/patchright-browser/SKILL.md
This skill should be used when the model needs real webpage access, long-form page text extraction or transcription, or to inspect and drive the Patchright browser CLI, verify Chrome root state, and diagnose browser instances and tabs in msgcode.
npx skillsauth add 42atom/msgcode patchright-browserInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
本 skill 是 Patchright 浏览器能力说明书,用来说明 browser 原生工具与 msgcode browser CLI 的正确分工、长文网页处理主链、以及排障合同。
browser 工具(Patchright + Chrome-as-State)browser 工具,也不重新发明第二套浏览器底座在以下场景读取并使用本 skill:
msgcode browser 检查或执行浏览器命令优先入口:browser 原生工具
browser 工具browser 拿正文;如果 tabs.text 已返回 textPath,直接把它当原文主文件,再分段处理msgcode browser ... 主要用于:
先把 Patchright 当成唯一正式浏览器底座,不要使用 agent-browser。
适用:
动作:
browser 工具bash + msgcode browser ...适用:
.md动作:
browser 打开并读取正文tabs.text 已返回 textPath,直接复用它;只有没有 textPath 时,才手工落盘原文文件bash 分段读取到结尾wc -l 和 tail 做结尾校验后,再回复完成适用:
tabId动作:
instanceId / tabId 是否真实有效msgcode browser snapshot/text/eval 查 DOM、正文长度和当前标签页状态browser 原生工具,不要先走 bash 包 CLI。msgcode browser ...。tabs.text 返回的 textPath;没有 textPath 时,再手工落盘原文文件。msgcode browser root --ensure --jsoninstances stop 和 tabs list 不是无参命令,必须传真实 instanceId。instanceId 不是人工编号,必须来自真实返回值,通常来自 instances launch --json、instances list --json、tabs open --json 等结构化结果。tabId 不是人工编号,不是 1、2、3 这种顺序号。tabId 必须来自真实返回值,通常来自 tabs open --json、tabs list --json、snapshot --json、text --json 等结构化结果里的 tabId。tabId。不要猜旧页签,更不要直接写死 tabId=1。browser 工具;需要排障、查看状态或验证 CLI 合同时,再走本 skill。适用于“把网页完整整理成 Markdown / 保存图片链接 / 不允许只拿半篇”的任务。
browser 读取正文,不要直接根据标题或短预览写结果。tabs.text 已返回 textPath,直接把它当原文主文件;否则第一时间把正文落盘成原文文件。<slug>.raw.txt 和 <slug>.md。bash 分段读取,直到读到文件结尾。推荐命令:
RAW_FILE="<browser返回的textPath或你手工落盘的原文文件>"
OUT_FILE="<按任务生成的结果文件名>"
wc -l "$RAW_FILE"
sed -n '1,200p' "$RAW_FILE"
sed -n '201,400p' "$RAW_FILE"
tail -n 40 "$RAW_FILE"
rg -o 'https?://[^ )]+' "$RAW_FILE"
wc -l "$OUT_FILE"
tail -n 20 "$OUT_FILE"
如果文章更长,就继续向后分段:
sed -n '401,600p' "$RAW_FILE"
sed -n '601,800p' "$RAW_FILE"
只有确认已经读到结尾,才允许回复“已完成”。
browser 返回的标题、URL、短预览当成完整正文snapshot,不核对真实正文文本tabId / 旧 instanceId适用:
核心约束:
node scripts/chromium-cookies-export.mjs --list --browser chrome
node scripts/chromium-cookies-export.mjs --list --browser edge
node scripts/chromium-cookies-export.mjs --list --browser brave
node scripts/chromium-cookies-export.mjs --browser chrome --domain x.com
node scripts/chromium-cookies-export.mjs --browser chrome --domain twitter.com
node scripts/chromium-cookies-export.mjs --browser chrome --domain google.com
OUT="/tmp/chrome-profile1-google.cookies.json"
node scripts/chromium-cookies-export.mjs --browser chrome --domain google.com --profile "Profile 1" --out "$OUT"
ls -lh "$OUT"
OUT_DIR="/tmp/chrome-cookies-out"
node scripts/chromium-cookies-export.mjs --browser chrome --domain google.com --out-dir "$OUT_DIR"
ls -lah "$OUT_DIR"
如果你担心文件落盘残留,可以用 --redact 写出脱敏版本(只用于验证流程,无法用于注入登录态)。
优先按这个顺序处理:
tabId 是真实有效的snapshot 检查页面是否有“展开 / 更多 / 继续阅读”按钮eval 或 text 确认正文长度是否明显异常不要直接把“不完整的一次读取结果”当成最终真相源。
msgcode browser root --ensure --json
msgcode browser profiles list --json
msgcode browser instances list --json
msgcode browser instances launch --mode headed --root-name work-default --json
msgcode browser tabs open --url https://example.com --json
msgcode browser tabs list --instance-id <real-instance-id> --json
msgcode browser instances stop --instance-id <real-instance-id> --json
msgcode browser snapshot --tab-id <real-tab-id> --compact --json
msgcode browser text --tab-id <real-tab-id> --json
msgcode browser eval --tab-id <real-tab-id> --expression 'document.body.innerText.length' --json
msgcode browser action --tab-id <real-tab-id> --kind click --ref '{"role":"link","name":"More info","index":0}' --json
正确示例:
instances launch --json 或 tabs open --jsoninstanceId 和 tabIdtabs list / instances stop 复用真实 instanceIdsnapshot、text、action、eval 复用真实 tabId错误示例:
tabs list --jsoninstances stop --jsontabs list --instance-id 1snapshot --tab-id 1text --tab-id 1action --tab-id 1 --kind click ...instances stop --instance-id 1tabIdinstanceIdtabs.action 必填 kind(click / type / press)ref 为 JSON:{"role":"...","name":"...","index":N}kind=type 时带 textkind=press 时带 key(如 Enter / Tab / Escape)tabs.snapshot 可带 --interactiveinstances.launch 可带 --port 指定调试端口(默认 9222)结论:不要“咬死 9222”。端口不是协议真相源,instanceId 才是。
9222;只以 instances.launch / instances.list / tabs.open 的结构化返回为准。instanceId 形如 chrome:<rootName>:<port>,其中 <port> 就是当前实例真实 CDP 端口;后续所有 tabs.* / instances.stop 都必须复用这个 instanceId。instances list --json,拿真实 instanceId,不要猜端口重试。instances.launch 启动了实例,最后要 instances stop 释放端口,避免后续任务误连到旧实例或端口被占用。推荐顺序:
root --ensureprofiles listinstances list / instances launchtabs opentabs listtext / snapshotaction / eval需要排障时,先看 root、instances、tabs 的结构化 JSON,不要直接猜当前浏览器状态,不要猜 tabId。
长文网页任务的完成前检查:
textPath,优先检查这个路径bash + msgcode browser ...agent-browser 作为正式浏览器通道data-ai
This skill should be used when the model needs detailed image understanding beyond the system preview summary, and needs a provider-neutral capability index.
development
# todo skill 触发:任务记录、查看待办、标记完成。 优先入口:`~/.config/msgcode/skills/todo/main.sh` 默认 workspace:当前目录 `$PWD`(可被 `--workspace` 覆盖)。 常用: - `bash ~/.config/msgcode/skills/todo/main.sh add "补充测试报告" --json` - `bash ~/.config/msgcode/skills/todo/main.sh list --json` - `bash ~/.config/msgcode/skills/todo/main.sh done <taskId> --json`
development
# thread skill 触发:查看/切换会话线程,读取线程消息。 优先入口:`msgcode thread ...` 常用: - `msgcode thread list --json` - `msgcode thread active --json` - `msgcode thread messages <thread-id> --limit 20 --json` - `msgcode thread switch <thread-id> --json`
development
This skill should be used when the model needs to create, inspect, enable, disable, or remove recurring schedules in msgcode, or when diagnosing schedule state in the current workspace.