Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@
"skills": [
"./skills/browser-trace"
]
},
{
"name": "safe-browser",
"source": "./",
"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.",
"version": "0.0.1",
"author": {
"name": "Browserbase"
},
"category": "security",
"keywords": ["safe-browser", "domain-policy", "allowlist", "cdp", "fetch-interception", "claude-agent-sdk", "browser-security", "prompt-injection"],
"strict": false,
"skills": [
"./skills/safe-browser"
]
}
]
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This plugin includes the following skills (see `skills/` for details):
| [functions](skills/functions/SKILL.md) | Deploy serverless browser automation to Browserbase cloud using the `bb` CLI |
| [site-debugger](skills/site-debugger/SKILL.md) | Diagnose and fix failing browser automations — analyzes bot detection, selectors, timing, auth, and captchas, then generates a tested site playbook |
| [browser-trace](skills/browser-trace/SKILL.md) | Capture a full DevTools-protocol trace (CDP firehose, screenshots, DOM dumps) alongside any browser automation, then bisect the stream into per-page searchable buckets |
| [safe-browser](skills/safe-browser/SKILL.md) | Build local Claude Agent SDK browser agents whose only browser capability is a CDP-gated `safe_browser` tool with domain allowlist enforcement |
| [bb-usage](skills/bb-usage/SKILL.md) | Show Browserbase usage stats, session analytics, and cost forecasts in a terminal dashboard |
| [cookie-sync](skills/cookie-sync/SKILL.md) | Sync cookies from local Chrome to a Browserbase persistent context so the browse CLI can access authenticated sites |
| [fetch](skills/fetch/SKILL.md) | Fetch HTML or JSON from static pages without a browser session — inspect status codes, headers, follow redirects |
Expand Down Expand Up @@ -57,6 +58,7 @@ Once installed, you can ask Claude to browse or use the Browserbase CLI:
- *"Order me a pizza, you're already signed in on Doordash"*
- *"Use `bb` to list my Browserbase projects and show the output as JSON"*
- *"Initialize a new Browserbase Function with `bb functions init` and explain the next commands"*
- *"Use safe-browser to build a Hacker News scraper that only stays on the main site"*

Claude will handle the rest.

Expand Down
21 changes: 21 additions & 0 deletions skills/safe-browser/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Browserbase, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
94 changes: 94 additions & 0 deletions skills/safe-browser/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
name: safe-browser
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.
license: MIT
allowed-tools: Bash, Read, Write, Edit
---

# 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.
3 changes: 3 additions & 0 deletions skills/safe-browser/templates/claude-agent-sdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.env
artifacts/
Loading