← Back to Skills Marketplace
peytoncasper

Functions

by peytoncasper · GitHub ↗ · v1.0.0
cross-platform ⚠ suspicious
1528
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install functions
Description
Guide Claude through deploying serverless browser automation using the official bb CLI
README (SKILL.md)

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:

export BROWSERBASE_API_KEY="your_api_key"
export BROWSERBASE_PROJECT_ID="your_project_id"

Creating a Function Project

1. Initialize with Official CLI

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

# 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

pnpm install

Function Structure

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

pnpm bb dev index.ts

Server runs at http://127.0.0.1:14113

2. Test Locally

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

Publish to Browserbase

pnpm bb 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.

Invoking Deployed Functions

Via curl

# Start invocation
curl -X POST "https://api.browserbase.com/v1/functions/FUNCTION_ID/invoke" \
  -H "Content-Type: application/json" \
  -H "x-bb-api-key: $BROWSERBASE_API_KEY" \
  -d '{"params": {"url": "https://example.com"}}'

# Response: {"id": "INVOCATION_ID"}

# Poll for result
curl "https://api.browserbase.com/v1/functions/invocations/INVOCATION_ID" \
  -H "x-bb-api-key: $BROWSERBASE_API_KEY"

Via Code

async function invokeFunction(functionId: string, params: object) {
  // Start invocation
  const invokeRes = await fetch(
    `https://api.browserbase.com/v1/functions/${functionId}/invoke`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'x-bb-api-key': process.env.BROWSERBASE_API_KEY!,
      },
      body: JSON.stringify({ params }),
    }
  );
  const { id: invocationId } = await invokeRes.json();

  // Poll until complete
  while (true) {
    await new Promise(r => setTimeout(r, 5000));
    
    const statusRes = await fetch(
      `https://api.browserbase.com/v1/functions/invocations/${invocationId}`,
      { headers: { 'x-bb-api-key': process.env.BROWSERBASE_API_KEY! } }
    );
    const result = await statusRes.json();
    
    if (result.status === 'COMPLETED') return result.results;
    if (result.status === 'FAILED') throw new Error(result.error);
  }
}

Common Patterns

Parameterized Scraping

defineFn("scrape", async ({ session, params }) => {
  const browser = await chromium.connectOverCDP(session.connectUrl);
  const page = browser.contexts()[0]!.pages()[0]!;
  
  await page.goto(params.url);
  await page.waitForSelector(params.selector);
  
  const items = await page.$$eval(params.selector, els => 
    els.map(el => el.textContent?.trim())
  );
  
  return { url: params.url, items };
});

With Authentication

defineFn("authenticated-action", async ({ session, params }) => {
  const browser = await chromium.connectOverCDP(session.connectUrl);
  const page = browser.contexts()[0]!.pages()[0]!;
  
  // Login
  await page.goto("https://example.com/login");
  await page.fill('[name="email"]', params.email);
  await page.fill('[name="password"]', params.password);
  await page.click('button[type="submit"]');
  await page.waitForURL('**/dashboard');
  
  // Do authenticated work
  const data = await page.textContent('.user-data');
  return { data };
});

Error Handling

defineFn("safe-scrape", async ({ session, params }) => {
  const browser = await chromium.connectOverCDP(session.connectUrl);
  const page = browser.contexts()[0]!.pages()[0]!;
  
  try {
    await page.goto(params.url, { timeout: 30000 });
    await page.waitForSelector(params.selector, { timeout: 10000 });
    
    const data = await page.textContent(params.selector);
    return { success: true, data };
  } catch (error) {
    return { 
      success: false, 
      error: error instanceof Error ? error.message : 'Unknown error' 
    };
  }
});

CLI Reference

Command Description
pnpm dlx @browserbasehq/sdk-functions init \x3Cname> Create new project
pnpm bb dev \x3Cfile> Start local dev server
pnpm bb publish \x3Cfile> Deploy to Browserbase

Troubleshooting

"Missing API key"

# Check .env file has credentials
cat .env

# Or set for current shell
export BROWSERBASE_API_KEY="your_key"
export BROWSERBASE_PROJECT_ID="your_project"

Dev server won't start

# Make sure SDK is installed
pnpm add @browserbasehq/sdk-functions

# Or use npx
npx @browserbasehq/sdk-functions dev index.ts

Function times out

  • Max execution time is 15 minutes
  • Add specific timeouts to page operations
  • Use waitForSelector instead of sleep

Can't connect to browser

  • Check session.connectUrl is being used correctly
  • Ensure you're using chromium.connectOverCDP() not chromium.launch()
Usage Guidance
This skill's instructions look legitimate for deploying Browserbase functions, but exercise caution before using it: 1) Verify the skill's provenance — find an official homepage or repo and confirm @browserbasehq/sdk-functions and the `bb` CLI are the real packages. 2) Do not paste API keys or passwords into public chat; prefer a secrets manager or CI environment variables instead of committing a .env file. 3) Avoid passing real user credentials in function params unless you control the storage and access policies for those invocations. 4) Confirm the minimal scope/permissions of the Browserbase API key you create. 5) If you can't verify the skill's source or the npm packages it installs, treat it as higher risk and don't proceed.
Capability Analysis
Type: OpenClaw Skill Name: functions Version: 1.0.0 The skill is classified as suspicious due to its instructions for the AI agent to handle sensitive API keys and execute package manager commands. Specifically, `SKILL.md` instructs the agent to export and write `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID` to a `.env` file, implying access to these credentials. It also directs the agent to execute `pnpm dlx @browserbasehq/sdk-functions init` and `pnpm install`, which involve downloading and executing arbitrary code from external sources. While these actions are plausibly necessary for the stated purpose of deploying serverless browser automation, they represent high-risk capabilities that could be misused.
Capability Assessment
Purpose & Capability
The skill's stated purpose (deploy serverless browser automation with the official bb CLI) matches the instructions, but the registry metadata lists no required environment variables or credentials while the SKILL.md clearly requires BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID. The skill's source and homepage are unknown, which reduces provenance for a tool that requests an API key.
Instruction Scope
The SKILL.md stays within the claimed scope: it walks through initializing a function project, adding a .env with Browserbase credentials, running pnpm/`bb` dev and publish, and invoking functions. It also shows patterns for authenticated automation (filling login forms) which is consistent with browser automation but elevates risk because user account credentials may be passed into functions/params.
Install Mechanism
This is an instruction-only skill with no install spec or code files, so nothing will be written or executed by the skill itself. That lowers installer risk — the user runs the commands. The SKILL.md recommends using pnpm dlx and pnpm install which pull packages from npm; that's expected for this workflow but you should verify the packages are official.
Credentials
The SKILL.md requires BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID (and the example uses them in curl and process.env). Those credentials are proportionate to the task, but the registry metadata omits them — an inconsistency. The skill also encourages storing credentials in a .env file and passing sensitive site login credentials through function params, which can lead to accidental exposure if not handled securely.
Persistence & Privilege
The skill does not request persistent presence (always:false), does not modify other skills' configs, and declares no config paths. It does not request elevated system privileges.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install functions
  3. After installation, invoke the skill by name or use /functions
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release of the "functions" skill for Browserbase: - Provides a comprehensive guide for deploying serverless browser automation using the official bb CLI. - Includes getting started instructions, credential setup, project initialization, and .env configuration. - Details development workflow, including local dev server, testing, auto-reloading, and debugging. - Explains deployment, invocation (via curl and code), and polling for results. - Offers recipes for common patterns: parameterized scraping, authentication workflows, and error handling. - Features CLI reference and troubleshooting tips for typical setup and runtime issues.
Metadata
Slug functions
Version 1.0.0
License
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is Functions?

Guide Claude through deploying serverless browser automation using the official bb CLI. It is an AI Agent Skill for Claude Code / OpenClaw, with 1528 downloads so far.

How do I install Functions?

Run "/install functions" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Functions free?

Yes, Functions is completely free (open-source). You can download, install and use it at no cost.

Which platforms does Functions support?

Functions is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Functions?

It is built and maintained by peytoncasper (@peytoncasper); the current version is v1.0.0.

💬 Comments