stagehand

Stagehand:Browserbase 的 AI 浏览器自动化框架,旨在将自然语言操作与确定性代码结合,适用于需要 Playwright 级别控制、结构化提取及缓存与稳定重复网络任务的生产工作流程。

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "stagehand":https://skillpi.com/zh/skills/deepskill-a5010cb7accc9b135b94158ae90071b7c4e0beb71a6cd4dd489fdd31b87904f9。安装前核对上游来源和版本:https://skillhub.cn/skills/user_3c6cb52e/stagehand-browser-automation。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

skillhub.cn

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

Stagehand:Browserbase 的 AI 浏览器自动化框架,旨在将自然语言操作与确定性代码结合,适用于需要 Playwright 级别控制、结构化提取及缓存与稳定重复网络任务的生产工作流程。

0 下载

介绍来源: third_party · user_3c6cb52e · 1.0.0 参考来源

SkillPi 解读

能完成的任务
来源文档未说明。
适合谁
来源文档未说明。
输入和输出
来源文档未说明。
软件、账号及付费要求
来源文档未说明。
限制与区别
来源文档未说明。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: stagehand
description: >-
  Builds web automations with Stagehand by BrowserBase, the AI-powered browser
  automation framework that controls web pages through natural language
  instructions. Acts on, extracts data from, and observes pages using plain
  English commands instead of brittle CSS selectors — powered by GPT-4o or
  Claude for visual understanding of page layouts. Use when writing browser
  automation, scraping dynamic sites, or replacing fragile Playwright selectors.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: AI & Machine Learning
  tags:
    - browser-automation
    - ai-agent
    - computer-use
    - web-automation
    - natural-language
    - playwright

Stagehand — AI Browser Automation in Natural Language

You are an expert in Stagehand by BrowserBase, the AI-powered browser automation framework that lets you control web pages using natural language instructions. You help developers build web automations that act, extract data, and observe pages using plain English commands instead of brittle CSS selectors — powered by GPT-4o or Claude for visual understanding of page layouts.

Core Capabilities

Setup and Basic Actions

import { Stagehand } from "@browserbasehq/stagehand";

const stagehand = new Stagehand({
  env: "LOCAL",                           // "LOCAL" for Playwright, "BROWSERBASE" for cloud
  modelName: "gpt-4o",
  modelClientOptions: { apiKey: process.env.OPENAI_API_KEY },
  enableCaching: true,                    // Cache AI decisions for repeated patterns
});

await stagehand.init();
const page = stagehand.page;              // Standard Playwright page object

// Navigate
await page.goto("https://app.example.com");

// Act — natural language browser control
await stagehand.act({ action: "Click the sign-in button" });
await stagehand.act({ action: "Type 'user@example.com' into the email field" });
await stagehand.act({ action: "Select 'Enterprise' from the plan dropdown" });
await stagehand.act({ action: "Scroll down to the pricing section" });

// Act with variables — keep credentials out of prompts
await stagehand.act({
  action: "Log in with username %user% and password %pass%",
  variables: {
    user: process.env.USERNAME!,
    pass: process.env.PASSWORD!,
  },
});

Extract Structured Data

// Extract structured data from any page
const products = await stagehand.extract({
  instruction: "Extract all product listings with name, price, rating, and availability",
  schema: {
    type: "object",
    properties: {
      products: {
        type: "array",
        items: {
          type: "object",
          properties: {
            name: { type: "string" },
            price: { type: "number" },
            rating: { type: "number" },
            inStock: { type: "boolean" },
          },
          required: ["name", "price"],
        },
      },
    },
  },
});

// Extract from complex pages (tables, nested layouts)
const invoiceData = await stagehand.extract({
  instruction: "Extract the invoice number, date, line items with quantities and amounts, and the total",
  schema: invoiceSchema,
});

Observe — Find Elements Without Acting

// Observe returns possible actions without performing them
const actions = await stagehand.observe({
  instruction: "Find all clickable navigation items",
});
// Returns: [{description: "Home link", selector: "xpath=...", ...}, ...]

// Use observe for conditional logic
const buttons = await stagehand.observe({
  instruction: "Find the 'Accept cookies' button if it exists",
});
if (buttons.length > 0) {
  await stagehand.act({ action: "Dismiss the cookie popup" });
}

Cloud Execution with BrowserBase

// Run in cloud for parallel, scalable automation
const stagehand = new Stagehand({
  env: "BROWSERBASE",                     // Cloud-hosted browser
  modelName: "gpt-4o",
  browserbaseSessionCreateParams: {
    projectId: process.env.BROWSERBASE_PROJECT_ID!,
    proxies: true,                        // Residential proxy
  },
});

Installation

npm install @browserbasehq/stagehand
# Requires: OPENAI_API_KEY or ANTHROPIC_API_KEY
# Optional: BROWSERBASE_API_KEY + BROWSERBASE_PROJECT_ID for cloud

Best Practices

  1. Natural language for dynamic pages — Use act() for pages that change layout frequently; CSS selectors break, natural language adapts
  2. Variables for secrets — Never put credentials in action strings; use the variables parameter
  3. Enable caching — Set enableCaching: true to avoid repeated AI calls for identical actions; huge cost savings
  4. Combine with Playwright — Use stagehand.page for stable interactions (login forms) and stagehand.act() for dynamic ones
  5. Schema for extraction — Always provide a Zod/JSON schema to extract(); structured output is more reliable than free-text
  6. Observe before acting — Use observe() to check if elements exist before acting; prevents errors on conditional UI
  7. BrowserBase for scale — Use cloud browsers for parallel automation; local is fine for development and testing
  8. Model selection — GPT-4o for speed, Claude for complex visual reasoning; both work well for most tasks

当前收录版本

1.0.0

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值90/100

亮点

  • AI 浏览器自动化框架,直接解决网页自动化、动态网站抓取等核心任务痛点
  • 显著提升日常高频场景的效率,适用于生产工作流程
触发精准90/100

亮点

  • 触发词精准完整,覆盖多种变体,边界清晰
  • 明确指出使用场景:编写浏览器自动化、抓取动态站点、替代脆弱的 Playwright 选择器
结构规范90/100

亮点

  • Phase/步骤清晰,有出口条件,含端到端示例
  • frontmatter完整,单文件≤500行,文档结构良好
执行可靠90/100

亮点

  • 工具来源明确,参数正确,覆盖主要异常
  • 提供了详细的安装说明、API 使用示例和最佳实践,可靠性高
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 133 行
  • 账号、密钥或授权

    使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。

    主文档提及 · 第 39, 55, 141 行
文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • app.example.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

来源文档未说明。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。