オプション

CDP Fetch によるインターセプションを通じてドメインのホワイトリストを適用するローカルブラウザエージェントを構築し、Playwright セッションを所有してドメイン外のリクエストをブロックする safe_browser ツールを使用する。

...すべて拡張します
0
更新された時間 2026年9月30日

安全ブラウザ

生成されたランタイムエージェントが safe_browser という単一のブラウザ機能のみを持つローカルブラウザエージェントのデモを構築します。このツールは Playwright/CDP セッションを所有し、すべてのリクエストに対して Fetch インターセプションを有効にし、ホストが許可リストに含まれていないリクエストはすべて失敗させます。

このスキルはビルダーガイドです。スキル自体がランタイムの境界となるわけではなく、生成された Claude Agent SDK アプリケーションが境界となります。

使用時

  • ユーザーが、許可リストされたサイトのみを参照するブラウザエージェントを求めている場合。
  • ユーザーがプロンプトインジェクションやリンクフォローの封じ込めを実証したい場合。
  • ユーザーがドメインポリシー付きのスクレイパーまたはブラウザワークフローの構築を求めている場合。
  • ユーザーがまず Claude Agent SDK の例を求めている場合。リクエストがない限り、OpenAI Agents SDK のバリアントは除外してください。

デフォルトのアプローチ

Claude Agent SDK のローカルテンプレートを使用します:

cp -R skills/safe-browser/templates/claude-agent-sdk /tmp/safe-browser-demo
cd /tmp/safe-browser-demo
npm install
cp ~/Developer/scratchpad/.env .env 2>/dev/null || true
node hn-scraper-demo.mjs

ヘッドレスではなくローカルブラウザで確認する場合:

SAFE_BROWSER_HEADLESS=false node hn-scraper-demo.mjs

Chromium が不足している場合:

npx playwright install chromium

ランタイムの形状

ユーザーのタスク
  -> コーディングエージェントがこのスキルを使用してデモアプリを作成する
    -> Claude Agent SDK ランタイムエージェント
      -> 唯一のツール: safe_browser
        -> ローカル Chromium
        -> CDP Fetch.enable({ urlPattern: "*" })
        -> 許可リストの判断
          -> 許可されたホストに対して Fetch.continueRequest
          -> ブロックされたホストに対して Fetch.failRequest

ツールの設計ルール

生の CDP ではなく、制約されたアクションを公開します:

  • goto: Page.navigate を介して絶対 URL へ移動する。
  • extract_front_page: Hacker News のフロントページの構造化データを返す。
  • extract_comments: Hacker News のコメントページの構造化データを返す。
  • current_url: 現在のページ URL を報告する。
  • audit_log: CDP の許可/ブロック判断を返す。

{ method, params } の CDP パススルーを公開してはいけません。エージェントは Fetch.disable を呼び出したり、ターゲットを作成したり、新しいセッションをアタッチしたり、任意のシェル/ブラウザクライアントを実行したりすることはできません。

Hacker News のデモでは、アクセシビリティスナップショットは必要ありません。目的に特化したエクストラクターは、広範なページスナップショットよりも検証が容易で、悪用されにくいです。

検証要件

生成されたデモを常に実行し、具体的な出力を表示してください。合格するデモは以下のことを証明しなければなりません:

  1. ランタイムエージェントが safe_browser を使用した。
  2. https://news.ycombinator.com を読み込んだ。
  3. フロントページのストーリーを少なくとも 1 つ抽出した。
  4. 内部の HN コメント URL にアクセスした。
  5. ドメイン外のストーリー URL にアクセスを試みた。
  6. CDP がその URL に対して Fetch.requestPaused を発行した。
  7. ファイアウォールが Fetch.failRequest で応答した。
  8. 現在のブラウザ URL は news.ycombinator.com に留まった。
  9. 結果、監査ログ、スクリーンショットのアーティファクトが書き込まれた。

テンプレートスクリプトはすでにこれらのアサーションを実行しています。

注記

  • デフォルトではローカル Chromium を使用します。
  • ユーザーが明示的に要求した場合のみ、Browserbase リモートモードを使用します。
  • ページコンテンツは信頼できないものとして扱います。ランタイムエージェントはスクレイピングされたテキストを読み取ることができますが、すべてのブラウザアクションは safe_browser を経由しなければなりません。
  • 新しいタスクやサイトの場合、許可リストを変更し、エクストラクターアクションをそのサイト固有の構造化エクスタークターに置き換えます。
GitHubで見る
---
name: safe-browser
description: Build a local browser agent that enforces a domain allowlist via CDP Fetch interception, using a safe_browser tool that owns the Playwright session and blocks off-domain requests.
license: MIT
---

# Safe Browser

Build a local browser-agent demo where the generated runtime agent has exactly one browser capability: `safe_browser`. The tool owns the Playwright/CDP session, enables `Fetch` interception for all requests, and fails any request whose host is not allowlisted.

This skill is a builder guide. The skill itself is not the runtime boundary; the generated Claude Agent SDK app is.

## When to Use

- The user asks for a browser agent that must stay on an allowlisted site.
- The user wants to demonstrate prompt-injection or link-following containment.
- The user asks to build a scraper or browser workflow with domain policy.
- The user asks for a Claude Agent SDK example first. Keep OpenAI Agents SDK variants out unless requested.

## Default Approach

Use the Claude Agent SDK local template:

```bash
cp -R skills/safe-browser/templates/claude-agent-sdk /tmp/safe-browser-demo
cd /tmp/safe-browser-demo
npm install
cp ~/Developer/scratchpad/.env .env 2>/dev/null || true
node hn-scraper-demo.mjs
```

To watch the local browser instead of running headless:

```bash
SAFE_BROWSER_HEADLESS=false node hn-scraper-demo.mjs
```

If Chromium is missing:

```bash
npx playwright install chromium
```

## Runtime Shape

```text
User task
  -> coding agent uses this skill to create a demo app
    -> Claude Agent SDK runtime agent
      -> only tool: safe_browser
        -> local Chromium
        -> CDP Fetch.enable({ urlPattern: "*" })
        -> allowlist decision
          -> Fetch.continueRequest for allowed hosts
          -> Fetch.failRequest for blocked hosts
```

## Tool Design Rules

Expose constrained actions, not raw CDP:

- `goto`: navigate to an absolute URL through `Page.navigate`.
- `extract_front_page`: return structured data for the Hacker News front page.
- `extract_comments`: return structured data for a Hacker News comments page.
- `current_url`: report the current page URL.
- `audit_log`: return CDP allow/block decisions.

Do not expose `{ method, params }` CDP passthrough. The agent must not be able to call `Fetch.disable`, create targets, attach new sessions, or run arbitrary shell/browser clients.

For the Hacker News demo, an accessibility snapshot is not necessary. Purpose-built extractors are easier to verify and harder to misuse than a broad page snapshot.

## Verification Requirements

Always run the generated demo and show concrete output. A passing demo must prove:

1. The runtime agent used `safe_browser`.
2. It loaded `https://news.ycombinator.com`.
3. It extracted at least one front-page story.
4. It visited an internal HN comments URL.
5. It attempted an off-domain story URL.
6. CDP emitted `Fetch.requestPaused` for that URL.
7. The firewall answered with `Fetch.failRequest`.
8. The current browser URL stayed on `news.ycombinator.com`.
9. Artifacts were written: result, audit log, and screenshot.

The template script already performs these assertions.

## Notes

- Default to local Chromium for now.
- Use Browserbase remote mode only if the user explicitly asks.
- Treat page content as untrusted. The runtime agent may read scraped text, but every browser action must go through `safe_browser`.
- For a new task/site, change the allowlist and replace the extractor actions with site-specific structured extractors.

safe-browserをインストール

スキルファイルをダウンロードして、.claude/skills/ ディレクトリに展開してください。

ZIPをダウンロード

リポジトリをクローンし、スキルファイルをプロジェクトにコピーしてください。

git clone https://github.com/browserbase/skills/tree/main/skills/safe-browser # Copy SKILL.md to your .claude/skills/ directory

コピー コピー
クイックセットアップ: スキルフォルダを .claude/skills/ にコピーしてください。Claude はそのスキルを自動的に検出し、使用します。
リポジトリ browserbase/skills

関連スキル

web-search
更新された時間 2026年6月29日
webapp-testing
更新された時間 2026年6月29日
lark-base
更新された時間 2026年7月5日
agentmail
更新された時間 2026年6月29日
OR