browser-automation by web-infra-dev/midscene-skills
npx skills add https://github.com/web-infra-dev/midscene-skills --skill browser-automation关键规则 — 违反将导致工作流中断:
- 切勿在后台运行 midscene 命令。 每个命令必须同步运行,以便您能在决定下一步操作前读取其输出(尤其是截图)。后台执行会破坏截图-分析-执行循环。
- 一次只运行一个 midscene 命令。 等待上一个命令完成,读取截图,然后决定下一个操作。切勿将多个命令链接在一起运行。
- 为每个命令预留足够的完成时间。 Midscene 命令涉及 AI 推理和屏幕交互,可能比典型的 shell 命令耗时更长。一个典型命令大约需要 1 分钟;复杂的
act命令可能需要更长时间。- 在结束前始终报告任务结果。 完成自动化任务后,您必须主动向用户总结结果 — 包括找到的关键数据、完成的动作、拍摄的截图以及任何相关发现。切勿在最后一个自动化步骤后静默结束;用户期望在单次交互中获得完整的响应。
使用 npx @midscene/web@1 实现网页浏览自动化。通过 Puppeteer 启动一个在 CLI 调用间持久运行的无头 Chrome — 命令之间不会丢失会话。每个 CLI 命令直接对应一个 MCP 工具 — 您(AI 代理)充当大脑,根据截图决定采取哪些操作。
在以下情况使用此技能:
如果您需要保持登录会话或操作用户现有的浏览器标签页,请改用 Chrome Bridge Automation 技能。
Midscene 需要具备强大视觉理解能力的模型。必须配置以下环境变量 — 可以设置为系统环境变量,也可以放在当前工作目录的 .env 文件中(Midscene 会自动加载 ):
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
.envMIDSCENE_MODEL_API_KEY="your-api-key"
MIDSCENE_MODEL_NAME="model-name"
MIDSCENE_MODEL_BASE_URL="https://..."
MIDSCENE_MODEL_FAMILY="family-identifier"
示例:Gemini (Gemini-3-Flash)
MIDSCENE_MODEL_API_KEY="your-google-api-key"
MIDSCENE_MODEL_NAME="gemini-3-flash"
MIDSCENE_MODEL_BASE_URL="https://generativelanguage.googleapis.com/v1beta/openai/"
MIDSCENE_MODEL_FAMILY="gemini"
示例:Qwen 3.5
MIDSCENE_MODEL_API_KEY="your-aliyun-api-key"
MIDSCENE_MODEL_NAME="qwen3.5-plus"
MIDSCENE_MODEL_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
MIDSCENE_MODEL_FAMILY="qwen3.5"
MIDSCENE_MODEL_REASONING_ENABLED="false"
# 如果使用 OpenRouter,请设置:
# MIDSCENE_MODEL_API_KEY="your-openrouter-api-key"
# MIDSCENE_MODEL_NAME="qwen/qwen3.5-plus"
# MIDSCENE_MODEL_BASE_URL="https://openrouter.ai/api/v1"
示例:豆包 Seed 2.0 Lite
MIDSCENE_MODEL_API_KEY="your-doubao-api-key"
MIDSCENE_MODEL_NAME="doubao-seed-2-0-lite"
MIDSCENE_MODEL_BASE_URL="https://ark.cn-beijing.volces.com/api/v3"
MIDSCENE_MODEL_FAMILY="doubao-seed"
常用模型:豆包 Seed 2.0 Lite、Qwen 3.5、智谱 GLM-4.6V、Gemini-3-Pro、Gemini-3-Flash。
如果模型未配置,请要求用户进行设置。有关支持的提供商,请参阅模型配置。
npx @midscene/web@1 connect --url https://example.com
npx @midscene/web@1 take_screenshot
截图后,在决定下一步操作前,请读取保存的图像文件以了解当前页面状态。
使用 act 与页面交互并获取结果。它在内部自主处理所有 UI 交互 — 点击、输入、滚动、悬停、等待和导航 — 因此您应该给它完整、高级别的复杂任务,而不是将其分解为小步骤。用自然语言描述您想做什么以及期望的效果:
# 具体指令
npx @midscene/web@1 act --prompt "click the Login button and fill in the email field with 'user@example.com'"
npx @midscene/web@1 act --prompt "scroll down and click the Submit button"
# 或目标驱动的指令
npx @midscene/web@1 act --prompt "click the country dropdown and select Japan"
断开与页面的连接,但保持浏览器运行:
npx @midscene/web@1 disconnect
完成后完全关闭浏览器:
npx @midscene/web@1 close
浏览器通过后台 Chrome 进程在 CLI 调用间持久运行。遵循以下模式:
act 执行期望的操作或目标驱动的指令。connect --url 导航到目标 URL。"the button",而要说 "the blue Submit button in the contact form"。"the red Buy Now button" 而不是 "#buy-btn"。close 关闭浏览器并释放资源。act 命令:在同一页面内执行连续操作时,将它们合并到一个 act 提示中,而不是拆分成多个命令。例如,"填写邮箱和密码字段,然后点击登录按钮" 应该是一个 act 调用,而不是三个。这减少了往返次数,避免了不必要的截图-分析循环,并且速度显著更快。示例 — 下拉选择:
npx @midscene/web@1 act --prompt "click the country dropdown and select Japan"
npx @midscene/web@1 take_screenshot
示例 — 表单交互:
npx @midscene/web@1 act --prompt "fill in the email field with 'user@example.com' and the password field with 'pass123', then click the Log In button"
npx @midscene/web@1 take_screenshot
.env 文件是否包含 MIDSCENE_MODEL_API_KEY=<your-key>。每周安装量
1.1K
仓库
GitHub 星标数
137
首次出现
2026年3月6日
安全审计
安装于
codex759
opencode757
cursor755
cline753
openclaw753
gemini-cli752
CRITICAL RULES — VIOLATIONS WILL BREAK THE WORKFLOW:
- Never run midscene commands in the background. Each command must run synchronously so you can read its output (especially screenshots) before deciding the next action. Background execution breaks the screenshot-analyze-act loop.
- Run only one midscene command at a time. Wait for the previous command to finish, read the screenshot, then decide the next action. Never chain multiple commands together.
- Allow enough time for each command to complete. Midscene commands involve AI inference and screen interaction, which can take longer than typical shell commands. A typical command needs about 1 minute; complex
actcommands may need even longer.- Always report task results before finishing. After completing the automation task, you MUST proactively summarize the results to the user — including key data found, actions completed, screenshots taken, and any relevant findings. Never silently end after the last automation step; the user expects a complete response in a single interaction.
Automate web browsing using npx @midscene/web@1. Launches a headless Chrome via Puppeteer that persists across CLI calls — no session loss between commands. Each CLI command maps directly to an MCP tool — you (the AI agent) act as the brain, deciding which actions to take based on screenshots.
Use this skill when:
If you need to preserve login sessions or work with the user's existing browser tabs, use the Chrome Bridge Automation skill instead.
Midscene requires models with strong visual grounding capabilities. The following environment variables must be configured — either as system environment variables or in a .env file in the current working directory (Midscene loads .env automatically):
MIDSCENE_MODEL_API_KEY="your-api-key"
MIDSCENE_MODEL_NAME="model-name"
MIDSCENE_MODEL_BASE_URL="https://..."
MIDSCENE_MODEL_FAMILY="family-identifier"
Example: Gemini (Gemini-3-Flash)
MIDSCENE_MODEL_API_KEY="your-google-api-key"
MIDSCENE_MODEL_NAME="gemini-3-flash"
MIDSCENE_MODEL_BASE_URL="https://generativelanguage.googleapis.com/v1beta/openai/"
MIDSCENE_MODEL_FAMILY="gemini"
Example: Qwen 3.5
MIDSCENE_MODEL_API_KEY="your-aliyun-api-key"
MIDSCENE_MODEL_NAME="qwen3.5-plus"
MIDSCENE_MODEL_BASE_URL="https://dashscope.aliyuncs.com/compatible-mode/v1"
MIDSCENE_MODEL_FAMILY="qwen3.5"
MIDSCENE_MODEL_REASONING_ENABLED="false"
# If using OpenRouter, set:
# MIDSCENE_MODEL_API_KEY="your-openrouter-api-key"
# MIDSCENE_MODEL_NAME="qwen/qwen3.5-plus"
# MIDSCENE_MODEL_BASE_URL="https://openrouter.ai/api/v1"
Example: Doubao Seed 2.0 Lite
MIDSCENE_MODEL_API_KEY="your-doubao-api-key"
MIDSCENE_MODEL_NAME="doubao-seed-2-0-lite"
MIDSCENE_MODEL_BASE_URL="https://ark.cn-beijing.volces.com/api/v3"
MIDSCENE_MODEL_FAMILY="doubao-seed"
Commonly used models: Doubao Seed 2.0 Lite, Qwen 3.5, Zhipu GLM-4.6V, Gemini-3-Pro, Gemini-3-Flash.
If the model is not configured, ask the user to set it up. See Model Configuration for supported providers.
npx @midscene/web@1 connect --url https://example.com
npx @midscene/web@1 take_screenshot
After taking a screenshot, read the saved image file to understand the current page state before deciding the next action.
Use act to interact with the page and get the result. It autonomously handles all UI interactions internally — clicking, typing, scrolling, hovering, waiting, and navigating — so you should give it complex, high-level tasks as a whole rather than breaking them into small steps. Describe what you want to do and the desired effect in natural language:
# specific instructions
npx @midscene/web@1 act --prompt "click the Login button and fill in the email field with 'user@example.com'"
npx @midscene/web@1 act --prompt "scroll down and click the Submit button"
# or target-driven instructions
npx @midscene/web@1 act --prompt "click the country dropdown and select Japan"
Disconnect from the page but keep the browser running:
npx @midscene/web@1 disconnect
Close the browser completely when finished:
npx @midscene/web@1 close
The browser persists across CLI calls via a background Chrome process. Follow this pattern:
act to perform the desired action or target-driven instructions.connect --url before any interaction."the button", say "the blue Submit button in the contact form"."the red Buy Now button" instead of "#buy-btn".close to shut down the browser and free resources.act command: When performing consecutive operations within the same page, combine them into one prompt instead of splitting them into separate commands. For example, "fill in the email and password fields, then click the Login button" should be a single call, not three. This reduces round-trips, avoids unnecessary screenshot-analyze cycles, and is significantly faster.Example — Dropdown selection:
npx @midscene/web@1 act --prompt "click the country dropdown and select Japan"
npx @midscene/web@1 take_screenshot
Example — Form interaction:
npx @midscene/web@1 act --prompt "fill in the email field with 'user@example.com' and the password field with 'pass123', then click the Log In button"
npx @midscene/web@1 take_screenshot
.env file contains MIDSCENE_MODEL_API_KEY=<your-key>.Weekly Installs
1.1K
Repository
GitHub Stars
137
First Seen
Mar 6, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
codex759
opencode757
cursor755
cline753
openclaw753
gemini-cli752
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装
NestJS专家服务 | 企业级TypeScript后端开发与架构设计
1,000 周安装
安全代码卫士:AI驱动的安全编码指南与最佳实践,防止SQL注入、XSS攻击
1,000 周安装
ESLint迁移到Oxlint完整指南:JavaScript/TypeScript项目性能优化工具
1,000 周安装
Chrome CDP 命令行工具:轻量级浏览器自动化,支持截图、执行JS、无障碍快照
1,000 周安装
Sanity内容建模最佳实践:结构化内容设计原则与无头CMS指南
1,000 周安装
AI Sprint规划器 - 敏捷团队Scrum迭代计划工具,自动估算故事点与容量管理
1,000 周安装
actact