skill-constraints
Enforce browser automation safety constraints — tool usage order, anti-detection rules, screenshot discipline, and human-in-the-loop checks. Use when setting up or verifying browser/MCP tool operations, NOT for every skill execution.
- License 许可
- MIT
- 所属仓库
- rexleimo/aios
- 最近更新
- 2026-11-07
- Stars
- ★ 62
- Forks
- 11
01 前言 Front Matter
- name
- skill-constraints
- tags
- [ "general", "safety" ]
- scopes
- [ "global", "project" ]
- clients
- [ "codex", "claude", "gemini", "opencode", "hermes", "workbuddy", "pi", "zcode", "qoder" ]
- description
- Enforce browser automation safety constraints — tool usage order, anti-detection rules, screenshot discipline, and human-in-the-loop checks. Use when setting up or verifying browser/MCP tool operations, NOT for every skill execution.
- repoTargets
- [ "codex", "claude", "gemini", "opencode", "hermes", "workbuddy", "pi", "zcode", "qoder" ]
- defaultInstall
- { "global": true, "project": false }
- installCatalogName
- skill-constraints
03 SKILL.md 正文
浏览器操作约束
Working directory: any (MCP tools are session-relative; file paths are relative to project root)
所有浏览器自动化操作 MUST 遵循此约束规则,确保安全、高效、可追溯。
When to Use
- 执行任何浏览器自动化操作时
- 使用 MCP 工具(
page.extract_text,page.get_html,page.screenshot等)时 - 进行任何运营操作(发布笔记、点赞、评论等)时
Core Pattern
浏览器操作
0. 启动浏览器时默认要求可见界面并走 CDP
- 优先:`chrome.launch_cdp { port: 9222, user_data_dir: '~/.chrome-cdp-profile' }`
- 随后:`browser.connect_cdp { cdp_url: 'http://127.0.0.1:9222' }`
- 仅在无图形环境或后台 smoke test 时才允许 headless 模式
- 当同一 `userDataDir` 被其他进程占用时,优先复用已启动浏览器,不共享被锁目录
- 若目标是“多个 agent 共享同一登录态”,统一连接同一个 CDP endpoint
1. 优先使用文本/DOM证据做决策
- 先读 `page.extract_text`,必要时补充 `page.get_html`
- 比整页截图更高效,可快速定位按钮文案和页面状态
- 不使用 `chrome-devtools` 工具链执行业务流程,统一走 `mcp-browser-use` 的 browser-use 工具链(`chrome.*` / `browser.*` / `page.*`)
2. 只有视觉信息不足时才截图,并保存到 temp/ 目录
- 条件:文本/HTML 证据不足以判断状态
- 使用:`page.screenshot`
- 路径:`aios/temp/{操作类型}_{时间戳}.png`
- 示例:`login_20240301_120000.png`
- 若 `aios/temp/` 不存在则先创建:`mkdir -p aios/temp`
操作间隔
Every browser action (click, type, navigate) MUST be followed by a random wait. No exceptions.
Use page.wait with a random duration, or if running in a shell context:
sleep $((RANDOM % 26 + 5))
In MCP context, use page.wait({ duration: <random 5-30s> }) or equivalent.
This is not optional — skipping intervals risks detection and account bans. If you batch operations without waiting, the entire task is considered failed regardless of outcome.
Rules
MUST NOT(禁止行为)
| 行为 | 原因 |
|---|---|
| 直接在对话中粘贴大段截图 | 浪费 token,MUST 保存到文件 |
| 跳过反检测 | 每次操作前 MUST 执行 |
| 跳过操作间隔 | MUST 随机 5-30 秒 |
| 在非 temp 目录保存截图 | MUST 保存到 aios/temp/ |
| 自动化执行第三方平台登录 | 登录 MUST 由人工完成(含 2FA) |
MUST(必需行为)
| 行为 | 原因 |
|---|---|
| 操作前执行反检测 | 使用反检测脚本(如项目中已有)或通过 CDP 指纹配置规则 |
| 截图保存到 temp/ | 路径固定为 aios/temp/ |
| 先读文本/DOM | page.extract_text → page.get_html |
| 使用 grep 搜索快照 | 先保存 snapshot 到文件,再用 grep 搜索 |
| 记录到历史 | 关键操作写入 .aios/context-db checkpoint/event |
| 登录态检测 | 识别到登录页/验证码/2FA 时 MUST 先提示用户协作登录 |
MCP 工具优先级
- page.extract_text - 首选,获取页面文本证据并做主决策
- page.get_html - 补充 DOM 结构和属性信息
- page.screenshot - 仅在视觉降级时使用
- page.click - 通过 selector 操作
- page.type - 通过 selector 输入
Examples
Good
// 启动并连接 CDP 浏览器
chrome.launch_cdp { port: 9222, user_data_dir: '~/.chrome-cdp-profile' }
browser.connect_cdp { cdp_url: 'http://127.0.0.1:9222' }
// 获取文本/DOM证据
page.extract_text { session_id: '<session_id>' }
page.get_html { session_id: '<session_id>' }
// 搜索内容
grep "关注" snapshot.txt
// 仅视觉降级时截图,并保存到正确位置
page.screenshot { session_id: '<session_id>', path: 'aios/temp/publish_20240301_120000.png' }
Bad
// 在对话中直接展示截图
[直接在回复中嵌入截图]
// 跳过间隔
page.click() // 立即执行
page.click() // 没有等待
Common Mistakes
| 错误 | 正确做法 |
|---|---|
| 截图直接在对话中显示 | 保存到 temp/,用 Read 工具查看 |
| 忽略随机间隔 | 每次操作后 sleep 5-30 秒 |
| 默认先看整页截图 | 先读布局字段,必要时再局部截图 |
| 用眼睛看截图找内容 | 用 grep 从快照搜索 |
| 在项目根目录放临时文件 | 统一放 aios/temp/ |
04 同仓库更多 Skills
versioning-by-impact
Use when completing a task and deciding whether repository changes require a semantic version bump and changelog entry before commit/push.
verification-loop
Evidence-before-assertions workflow. Use before claiming work is done, before release, and after any behavior change in scripts/skills/MCP.
typesafe-ai
Build AI-powered software with TypeSafe: small units of AI intelligence you can use like programming primitives. Its System One models, including Jev, turn natural language and application state into typed judgments and probabilities that code can combine. Use when a feature needs programmable common sense, when brainstorming what AI could make possible in an app, or when an LLM prompt-and-parse step could become a structured decision. Applications include routing, ranking, extraction, verification, and interactive experiences; these are starting points, not the limits. Read live docs and cookbooks to find useful patterns and discover new combinations.
skill-opt-lite
Train and optimize skill documents using the SkillOpt methodology — the agent acts as both target and optimizer, running tasks, reflecting on failures, proposing edits, and validating improvements in a self-contained training loop. TRIGGER: optimize skill, train skill, improve skill, skill training, skill optimization, SkillOpt, skill evolution, skill iteration loop, skill feedback loop, skill tuning.
seo-geo-page-optimization
Use when improving a single page for SEO and AI answer-engine visibility (GEO), especially when you need faster first-screen conversion and clearer traffic funnels.
security-scan
Lightweight security hygiene for agent configs (skills/hooks/MCP/settings). Use before enabling automation, after config changes, and before release.