# Safe Browser

Build local constrained-browser agents with a safe_browser tool that owns CDP, enforces...

- Repository: https://github.com/browserbase/skills (3748 stars)
- Category: AI and agents
- License: MIT
- Last updated: 2026-10-27
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add browserbase/skills --skill safe-browser -g -a claude-code -y`
Codex: `npx skills add browserbase/skills --skill safe-browser -g -a codex -y`
Cursor: `npx skills add browserbase/skills --skill safe-browser -g -a cursor -y`
Gemini CLI: `npx skills add browserbase/skills --skill safe-browser -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add browserbase/skills`

## Description

Build local constrained-browser agents with a safe_browser tool that owns CDP, enforces a domain allowlist with Fetch interception, and lets a runtime Claude Agent SDK agent complete browsing tasks without raw browser, shell, or CDP access. Use when the user wants an agent to browse or scrape while staying on approved domains, demo blocked off-domain navigation, or generate a safe browser client.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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.

The rest: https://github.com/browserbase/skills/blob/HEAD/skills/safe-browser/SKILL.md
