Skip to main content
skill CX Codex

functions — Claude Code skill: what it does, how to install

Deploys serverless browser automation as cloud functions using Browserbase. It handles scheduled cron runs and webhook-triggered browser tasks.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add browserbase/skills --skill functions -a claude-code
Open on GitHub

What functions does

This skill manages headless browser scripts deployed as Browserbase cloud functions. It handles project scaffolding via browse functions init and deployment with browse functions publish.

Functions rely on @browserbasehq/sdk-functions and connect to remote browsers through Playwright's chromium.connectOverCDP. The entry point receives execution parameters and returns JSON results. The dev server browse functions dev reloads on file changes. Testing payloads locally stays quick.

Execution requires Node.js 18+ and the globally installed browse CLI. You also need pnpm or npm and a valid BROWSERBASE_API_KEY. Missing the CLI or key causes immediate terminal errors.

What it helps with

  • deploy Playwright automation scripts as serverless cloud functions
  • trigger browser automation runs on a cron schedule or via webhooks
  • spin up a local dev server to test function payloads before deployment
  • scaffold a new Browserbase function project with TypeScript and environment variables

Example prompts for the agent

  • Initialize a new Browserbase function project and start the local dev server
  • Write a Playwright cloud function that connects over CDP and extracts page titles
  • Deploy my finished browser function using browse functions publish

How to install functions

1Skills CLI (Vercel)

npx skills add browserbase/skills --skill functions -a claude-code

2Manually: put the files in place

~/.claude/skills/functions/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/functions/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about functions

How to install functions in Claude Code?

Run npx skills add browserbase/skills --skill functions -a claude-code in your terminal to install the skill.

What does the functions skill do?

It assists with scaffolding, testing locally, and publishing serverless browser automation tasks to Browserbase using the browse CLI.

What prerequisites are required for functions?

You need Node.js 18+, npm or pnpm, the globally installed browse CLI, and an exported BROWSERBASE_API_KEY environment variable.

Source text

SKILL.md · MIT
---
name: functions
description: "Deploy serverless browser automation as cloud functions using Browserbase. Use when the user wants to deploy browser automation to run on a schedule or cron, create a webhook endpoint for browser tasks, run automation in the cloud instead of locally, or asks about Browserbase Functions."
compatibility: "Requires the browse CLI (`npm install -g browse`), Node.js 18+ with pnpm or npm, and BROWSERBASE_API_KEY."
license: MIT
allowed-tools: Bash Read Write Edit
---

# Browserbase Functions

Deploy serverless browser automation using the official `browse` CLI.

## Prerequisites

Get an API key from: https://browserbase.com/settings

```bash
export BROWSERBASE_API_KEY="your_api_key"
```

## Creating a Function Project

### 1. Initialize

```bash
browse 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
echo "BROWSERBASE_API_KEY=$BROWSERBASE_API_KEY" >> .env
```

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

### 1. Start Dev Server

```bash
browse functions dev index.ts
```

Server runs at `http://127.0.0.1:14113`

### 2. Test Locally

```bash
curl -X POST http://127.0.0.1:14113/v1/functions/my-function/invoke \
  -H "Content-Type: application/json" \
  -d '{"params": {"url": "https://news.ycombinator.com"}}'
```

### 3. Iterate

The dev server auto-reloads on file changes. Use `console.log()` for debugging - output appears in the terminal.

## Deploying

```bash
browse functions publish index.ts
```

Output:
```
Function published successfully
Build ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Function ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```

**Save the Function ID** - you need it to invoke.

## Quick Reference

| Command | Description |
|---------|-------------|
| `browse functions init <name>` | Create new project |
| `browse functions dev <file>` | Start local dev server |
| `browse functions publish <file>` | Deploy to Browserbase |

For invocation examples, common patterns, and troubleshooting, see [REFERENCE.md](REFERENCE.md).

© browserbase · MIT · browserbase/skills

Similar skills

All skills for Browser and scraping →

From the same set16

browser-trace Attaches a second CDP client to a browser session that is already running, records the whole DevTools stream to disk, and splits it so you can search a failed run. CX Codex +1 3,000installs fetch Retrieves HTML or JSON from static web pages via Browserbase Fetch API without starting a browser session. Useful for fast scraping and header inspection. CX Codex +1 3,000installs autobrowse A skill that iterates on a browsing task, reads the trace and rewrites its own navigation instructions until the task passes reliably. CX Codex +1 2,800installs search The skill runs web searches through Browserbase's Search API and returns links with titles, authors and publish dates, without opening a browser session. CX Codex +1 2,800installs cookie-sync Syncs cookies from local Chrome into a Browserbase persistent context. This lets the browse CLI run cloud sessions on authenticated websites. CX Codex +1 2,600installs company-research Discovers target B2B companies via Browserbase Search API, evaluates their ICP fit, and outputs a scored research report and CSV. CX Codex +1 2,300installs event-prospecting Takes a conference speakers page URL, extracts people, filters companies by ICP, and outputs an HTML report with person cards explaining why the AE should reach out. CX Codex +1 2,100installs browser-to-api Reads a browser-trace capture and turns it into an OpenAPI 3.1 spec, a fetch client and a coverage report. Useful when the site you are integrating with has no published API docs. CX Codex +1 1,900installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor