stagehand
BrowserBaseのStagehandのエキスパートとして、自然言語でウェブページの操作、データ抽出、状況把握を可能にし、開発者がGPT-4oやClaudeを活用して、柔軟なウェブ自動化を構築するSkill。
📜 元の英語説明(参考)
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.
🇯🇵 日本人クリエイター向け解説
BrowserBaseのStagehandのエキスパートとして、自然言語でウェブページの操作、データ抽出、状況把握を可能にし、開発者がGPT-4oやClaudeを活用して、柔軟なウェブ自動化を構築するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o stagehand.zip https://jpskill.com/download/15416.zip && unzip -o stagehand.zip && rm stagehand.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15416.zip -OutFile "$d\stagehand.zip"; Expand-Archive "$d\stagehand.zip" -DestinationPath $d -Force; ri "$d\stagehand.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
stagehand.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
stagehandフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Stagehand — 自然言語による AI ブラウザ自動化
BrowserBase の Stagehand は、自然言語の指示を使ってウェブページを制御できる、AI 搭載のブラウザ自動化フレームワークです。このフレームワークのエキスパートとして、開発者が、壊れやすい CSS セレクターの代わりに、平易な英語のコマンドを使って、アクションを実行し、データを抽出し、ページを観察するウェブ自動化を構築するのを支援します。ページのレイアウトの視覚的な理解には、GPT-4o または Claude が利用されます。
主要な機能
セットアップと基本的なアクション
import { Stagehand } from "@browserbasehq/stagehand";
const stagehand = new Stagehand({
env: "LOCAL", // Playwright の場合は "LOCAL"、クラウドの場合は "BROWSERBASE"
modelName: "gpt-4o",
modelClientOptions: { apiKey: process.env.OPENAI_API_KEY },
enableCaching: true, // 繰り返されるパターンに対して AI の決定をキャッシュする
});
await stagehand.init();
const page = stagehand.page; // 標準の Playwright ページオブジェクト
// ナビゲーション
await page.goto("https://app.example.com");
// アクション — 自然言語によるブラウザ制御
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" });
// 変数を使ったアクション — プロンプトから認証情報を除外する
await stagehand.act({
action: "Log in with username %user% and password %pass%",
variables: {
user: process.env.USERNAME!,
pass: process.env.PASSWORD!,
},
});
構造化されたデータの抽出
// 任意のページから構造化されたデータを抽出する
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"],
},
},
},
},
});
// 複雑なページ(テーブル、ネストされたレイアウト)から抽出する
const invoiceData = await stagehand.extract({
instruction: "Extract the invoice number, date, line items with quantities and amounts, and the total",
schema: invoiceSchema,
});
観察 — アクションを実行せずに要素を見つける
// observe は、実行可能なアクションを、実行せずに返します
const actions = await stagehand.observe({
instruction: "Find all clickable navigation items",
});
// 返り値: [{description: "Home link", selector: "xpath=...", ...}, ...]
// 条件付きロジックに observe を使用する
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" });
}
BrowserBase を使用したクラウド実行
// 並列でスケーラブルな自動化のためにクラウドで実行する
const stagehand = new Stagehand({
env: "BROWSERBASE", // クラウドホストされたブラウザ
modelName: "gpt-4o",
browserbaseSessionCreateParams: {
projectId: process.env.BROWSERBASE_PROJECT_ID!,
proxies: true, // レジデンシャルプロキシ
},
});
インストール
npm install @browserbasehq/stagehand
# 必須: OPENAI_API_KEY または ANTHROPIC_API_KEY
# オプション: クラウドの場合は BROWSERBASE_API_KEY + BROWSERBASE_PROJECT_ID
ベストプラクティス
- 動的なページには自然言語を — レイアウトが頻繁に変更されるページには
act()を使用します。CSS セレクターは壊れますが、自然言語は適応します。 - シークレットには変数を使用 — アクション文字列に認証情報を絶対に入れないでください。
variablesパラメーターを使用します。 - キャッシュを有効にする —
enableCaching: trueを設定して、同一のアクションに対する AI 呼び出しの繰り返しを回避します。大幅なコスト削減になります。 - Playwright と組み合わせる — 安定したインタラクション(ログインフォーム)には
stagehand.pageを使用し、動的なインタラクションにはstagehand.act()を使用します。 - 抽出にはスキーマを使用 —
extract()には常に Zod/JSON スキーマを提供してください。構造化された出力は、フリーテキストよりも信頼性が高くなります。 - アクションの前に観察する — アクションを実行する前に
observe()を使用して要素が存在するかどうかを確認します。条件付き UI でのエラーを防ぎます。 - スケールには BrowserBase を — 並列自動化にはクラウドブラウザを使用します。ローカルは開発とテストに適しています。
- モデルの選択 — 速度を重視する場合は GPT-4o、複雑な視覚的推論が必要な場合は Claude を使用します。どちらもほとんどのタスクでうまく機能します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
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
- Natural language for dynamic pages — Use
act()for pages that change layout frequently; CSS selectors break, natural language adapts - Variables for secrets — Never put credentials in action strings; use the
variablesparameter - Enable caching — Set
enableCaching: trueto avoid repeated AI calls for identical actions; huge cost savings - Combine with Playwright — Use
stagehand.pagefor stable interactions (login forms) andstagehand.act()for dynamic ones - Schema for extraction — Always provide a Zod/JSON schema to
extract(); structured output is more reliable than free-text - Observe before acting — Use
observe()to check if elements exist before acting; prevents errors on conditional UI - BrowserBase for scale — Use cloud browsers for parallel automation; local is fine for development and testing
- Model selection — GPT-4o for speed, Claude for complex visual reasoning; both work well for most tasks