Guide Claude through deploying serverless browser automation using the official bb CLI
View on GitHubFebruary 4, 2026
Select agents to install to:
npx add-skill https://github.com/browserbase/skills/blob/main/skills/functions/SKILL.md -a claude-code --skill functionsInstallation paths:
.claude/skills/functions/# Browserbase Functions Skill
Guide Claude through deploying serverless browser automation using the official `bb` CLI.
## When to Use
Use this skill when:
- User wants to deploy automation to run on a schedule
- User needs a webhook endpoint for browser automation
- User wants to run automation in the cloud (not locally)
- User asks about Browserbase Functions
## Prerequisites
### 1. Get Credentials
Get API key and Project ID from: https://browserbase.com/settings
### 2. Set Environment Variables
Set directly:
```bash
export BROWSERBASE_API_KEY="your_api_key"
export BROWSERBASE_PROJECT_ID="your_project_id"
```
## Creating a Function Project
### 1. Initialize with Official CLI
```bash
pnpm dlx @browserbasehq/sdk-functions init my-function
cd my-function
```
This creates:
```
my-function/
├── package.json
├── index.ts # Your function code
└── .env # Add credentials here
```
### 2. Add Credentials to .env
```bash
# Copy from stored credentials
echo "BROWSERBASE_API_KEY=$BROWSERBASE_API_KEY" >> .env
echo "BROWSERBASE_PROJECT_ID=$BROWSERBASE_PROJECT_ID" >> .env
```
Or manually edit `.env`:
```
BROWSERBASE_API_KEY=your_api_key
BROWSERBASE_PROJECT_ID=your_project_id
```
### 3. Install Dependencies
```bash
pnpm install
```
## Function Structure
```typescript
import { defineFn } from "@browserbasehq/sdk-functions";
import { chromium } from "playwright-core";
defineFn("my-function", async (context) => {
const { session, params } = context;
// Connect to browser
const browser = await chromium.connectOverCDP(session.connectUrl);
const page = browser.contexts()[0]!.pages()[0]!;
// Your automation
await page.goto(params.url || "https://example.com");
const title = await page.title();
// Return JSON-serializable result
return { success: true, title };
});
```
**Key objects:**
- `context.session.connectUrl` - CDP endpoint to connect Playwright
- `context.params` - Input parameters from invocation
## Development Wor