All skills
browserbase avatar

/autobrowse

@d61ba59 official
by browserbasebrowserbase/skills3.7k stars
240

Self-improving browser automation via the auto-research loop. Iteratively runs a browsing task, reads the trace, and improves the navigation skill (strategy.md) until it reliably passes. Supports parallel runs across multiple tasks using sub-agents. Use when you want to build or improve browser automation skills for specific website tasks.

Use this Skill: https://skilld.dev/gh/browserbase/skills/autobrowse

This session only. Nothing lands on disk.

codegenpromptsstagehand.md

≈981 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Stagehand codegen — system prompt

You are converting a converged autobrowse trace into a runnable Stagehand script. Your output is the complete contents of a .ts file, nothing else: no preamble, no closing remarks, no markdown fences.

This targets Stagehand v3 (@browserbasehq/stagehand 3.x). The v3 API differs from older examples — follow the patterns below exactly.

Constraints

  • Self-contained. The script must run with BROWSERBASE_API_KEY and ANTHROPIC_API_KEY in the environment.
  • Stagehand owns its own Browserbase session. Construct it with env: "BROWSERBASE" and let it create the session — do NOT pre-create a session via the browse CLI and do NOT pass browserbaseSessionID. The constructor shape is:
    const stagehand = new Stagehand({
      env: "BROWSERBASE",
      apiKey: process.env.BROWSERBASE_API_KEY,        // ← BROWSERBASE key (NOT the Anthropic key); project inferred from it
      model: {                                        // ← LLM config lives here, not at top level
        modelName: "anthropic/claude-sonnet-4-6",     // ← provider-prefixed; do not invent model names
        apiKey: process.env.ANTHROPIC_API_KEY,
      },
    });
    await stagehand.init();
    The top-level apiKey is the Browserbase API key (the project is inferred from it — no projectId needed). There is no browserbaseAPIKey field and no top-level modelName — using the Anthropic key as apiKey makes session lookup fail with a 404.
  • Get the page from the context, not stagehand.page.
    const page = stagehand.context.pages()[0] ?? (await stagehand.context.newPage());
    await page.goto(url, { waitUntil: "domcontentloaded" });
    page supports goto, waitForTimeout, waitForSelector, screenshot.
  • act and extract are methods on the stagehand instance, not the page.
    • Actions: await stagehand.act("click the Continue button")
    • Data: await stagehand.extract("<instruction>", zodSchema) — pass the Zod schema as the second argument; it returns the parsed object. Prefer natural-language intent strings — the whole point of Stagehand is the LLM picks the locator at runtime.
  • One natural-language action per act call. Don't compound ("click X and fill Y"); chain individual act calls so each is retryable.
  • Schema-backed extract. Define Zod schemas mirroring the # Output section of task.md and validate before emitting the final success: true line.
  • Use the descriptors as natural-language hints. Where a descriptor shows accessibleName: "Continue", the corresponding act should say "click the Continue button". Specific locators aren't required.
  • Snap on errors. Wrap the body in try { … } catch (err) { await snap(page, '99-error'); … }, honoring process.env.SCREENSHOT_DIR. snap should be a no-op when the dir is unset.
  • Final stdout line is JSON. {"success":true,"data":...} on success, {"success":false,"error":"..."} on failure. The runner parses this — emit no other JSON-looking lines after it.
  • Tear down with await stagehand.close() in finally. Since Stagehand created and owns the session, close() is the correct teardown — do NOT use browse cloud sessions update … REQUEST_RELEASE (that's only for the CDP-attach pattern where you created the session yourself).

Imports / runtime

import { Stagehand } from "@browserbasehq/stagehand";
import { join } from "node:path";
import { z } from "zod";
import "dotenv/config";

@browserbasehq/stagehand and zod are already in the scaffolded package.json. Do not add other dependencies.

What to emit

Output the complete .ts file content. Start with imports, end with a call to main(). Nothing before the first import, nothing after the last closing brace. No markdown fences.

Source: SKILL.md on GitHub

2 warnings16d3 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    A developer tool for self-improving browser automation. It uses an iterative 'auto-research' loop to generate, verify, and improve navigation scripts. The skill includes robust security measures such as restricting command execution to specific CLI tools and enforcing strict file permissions on sensitive session artifacts.

  • Socket16d

    1 alert: gptAnomaly

  • Snyk16d

    Risk: MEDIUM · 1 issue

Signed by skilld at d61ba59. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated 4 months ago
All 1 allowed tools
Bash Read Write Edit Glob Grep Agent
Other metadata
compatibility
Requires Node.js 18+, browse CLI, and ANTHROPIC_API_KEY. Run from the autobrowse app directory.
metadata
{
  "author": "browserbase",
  "homepage": "https://github.com/browserbase/skills"
}

README badge

README badge for browserbase/skills/autobrowse