16 chapters · 94 min
Skills
Chapter 13 of 16
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…
2 minutes · 374 words · 6 sections
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.
Use the Claude Agent SDK local template:
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.mjsTo watch the local browser instead of running headless:
SAFE_BROWSER_HEADLESS=false node hn-scraper-demo.mjsIf Chromium is missing:
npx playwright install chromiumUser 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 hostsExpose 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.
Always run the generated demo and show concrete output. A passing demo must prove:
safe_browser.https://news.ycombinator.com.Fetch.requestPaused for that URL.Fetch.failRequest.news.ycombinator.com.The template script already performs these assertions.
safe_browser.Install this repository
npx skills add browserbase/skills/plugin marketplace add browserbase/skillsSkills install per repository, not per chapter — the CLI has no documented per-skill form, so we do not print one.
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.
The verbatim description from this skill’s front matter — the string an agent matches on to decide whether to load it.
Bash,Read,Write,Editskills/safe-browser/SKILL.mdmain, last pushed 5 August 2026.SKILL.md, not by matching a directory convention. One layout observed: skills/*/SKILL.md.h1 and no skipped levels:.claude-plugin/marketplace.json by Browserbase, declaring 5 plugins. It is read for editorial metadata only — never as the skill index, which is always the repository tree./browserbase/skills.md.md5 files · 64 KB
Everything this skill ships beside its prose. All of it is set here, as subchapters of chapter 13.
Templates, schemas and fixtures the skill draws on.
Everything else published alongside the skill.