## Summary - make `browse env local` default back to an isolated local browser - add `browse env local --auto-connect` as the explicit opt-in path for auto-discovering a debuggable local Chrome - keep explicit CDP attach via `browse env local <port|url>` and add tests to lock in the strategy behavior ## Why `browse env local` was auto-attaching to an existing local Chrome by default. That can trigger Chrome's remote debugging approval dialog unexpectedly and makes isolated local usage less predictable. ## Impact Users now get a clean local browser by default, while still having two explicit ways to reuse an existing browser when they want to: - `browse env local --auto-connect` - `browse env local <port|url>` ## Test Plan - `pnpm --filter @browserbasehq/browse-cli build` - `pnpm --filter @browserbasehq/browse-cli test` - `pnpm exec prettier --check packages/cli && cd packages/cli && pnpm run eslint && pnpm run typecheck` - e2e smoke test against a disposable Chrome CDP endpoint on `127.0.0.1:9229` using a temporary `HOME` / user-data-dir so the checks do not touch a real browsing profile - verified `browse env local` returns `localStrategy: "isolated"` - verified `browse status` in isolated mode reports `localSource: "isolated"` - verified `browse env local` and `browse status` both print the hint to use `browse env local --auto-connect` to reuse local credentials/cookies - verified `browse env local --auto-connect` returns `localStrategy: "auto"` - verified `browse env local --auto-connect` prints the hint that plain `browse env local` switches back to an isolated Chromium browser - verified `open https://example.com` succeeds after `--auto-connect` - verified `browse status` after `--auto-connect` reports `localSource: "attached-existing"` with the resolved CDP URL and the isolated-browser hint - verified `browse env local 9229` returns `localStrategy: "cdp"` - verified `browse status` after `browse env local 9229` reports `localSource: "attached-explicit"` Linear: STG-1752 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Defaulted `browse env local` to a clean, isolated browser. Added `--auto-connect` to opt into reusing a debuggable Chrome, kept explicit CDP attach via `browse env local <port|url>`, and added mode hints to guide users. Addresses Linear STG-1752 to make local usage predictable and avoid surprise debugging prompts. - **New Features** - Isolated local browser is now the default; auto-discovery only with `--auto-connect`. - Mode hints in `browse env`/`browse status` suggest when to use `--auto-connect` or switch back to isolated. - `browse env local <port|url>` remains for explicit CDP targets. - Centralized strategy resolution in `src/local-strategy.ts` with unit tests. - Clearer `browse env` usage and validation; rejects mixing `--auto-connect`, `--isolated`, or a target. `--isolated` is deprecated (accepted; hidden from help). - **Migration** - To reuse an existing Chrome: `browse env local --auto-connect`. - To attach to a specific target: `browse env local <port|url>`. - No changes if you want a clean isolated browser by default. <sup>Written for commit a132cb182c5387cd58ae31f366f93bcf1f5cceab. Summary will update on new commits. <a href="https://cubic.dev/pr/browserbase/stagehand/pull/1945">Review in cubic</a></sup> <!-- End of auto-generated description by cubic. -->
The AI Browser Automation Framework
Read the Docs
If you're looking for the Python implementation, you can find it here
What is Stagehand?
Stagehand is a browser automation framework used to control web browsers with natural language and code. By combining the power of AI with the precision of code, Stagehand makes web automation flexible, maintainable, and actually reliable.
Why Stagehand?
Most existing browser automation tools either require you to write low-level code in a framework like Selenium, Playwright, or Puppeteer, or use high-level agents that can be unpredictable in production. By letting developers choose what to write in code vs. natural language (and bridging the gap between the two) Stagehand is the natural choice for browser automations in production.
-
Choose when to write code vs. natural language: use AI when you want to navigate unfamiliar pages, and use code when you know exactly what you want to do.
-
Go from AI-driven to repeatable workflows: Stagehand lets you preview AI actions before running them, and also helps you easily cache repeatable actions to save time and tokens.
-
Write once, run forever: Stagehand's auto-caching combined with self-healing remembers previous actions, runs without LLM inference, and knows when to involve AI whenever the website changes and your automation breaks.
Getting Started
Start with Stagehand with one line of code, or check out our Quickstart Guide for more information:
npx create-browser-app
Example
Here's how to build a sample browser automation with Stagehand:
// Stagehand's CDP engine provides an optimized, low level interface to the browser built for automation
const page = stagehand.context.pages()[0];
await page.goto("https://github.com/browserbase");
// Use act() to execute individual actions
await stagehand.act("click on the stagehand repo");
// Use agent() for multi-step tasks
const agent = stagehand.agent();
await agent.execute("Get to the latest PR");
// Use extract() to get structured data from the page
const { author, title } = await stagehand.extract(
"extract the author and title of the PR",
z.object({
author: z.string().describe("The username of the PR author"),
title: z.string().describe("The title of the PR"),
}),
);
Documentation
Visit docs.stagehand.dev to view the full documentation.
Build and Run from Source
git clone https://github.com/browserbase/stagehand.git
cd stagehand
pnpm install
pnpm run build
pnpm run example # run the blank script at ./examples/example.ts
Stagehand is best when you have an API key for an LLM provider and Browserbase credentials. To add these to your project, run:
cp .env.example .env
nano .env # Edit the .env file to add API keys
Installing from a branch
You can install and build Stagehand directly from a github branch using gitpkg
In your project's package.json set:
"@browserbasehq/stagehand": "https://gitpkg.now.sh/browserbase/stagehand/packages/core?<branchName>",
Contributing
Note
We highly value contributions to Stagehand! For questions or support, please join our Discord community.
At a high level, we're focused on improving reliability, extensibility, speed, and cost in that order of priority. If you're interested in contributing, bug fixes and small improvements are the best way to get started. For more involved features, we strongly recommend reaching out to Miguel Gonzalez or Paul Klein in our Discord community before starting to ensure that your contribution aligns with our goals.
Acknowledgements
We'd like to thank the following people for their major contributions to Stagehand:
- Paul Klein
- Sean McGuire
- Miguel Gonzalez
- Sameel Arif
- Thomas Katwan
- Filip Michalsky
- Anirudh Kamath
- Jeremy Press
- Navid Pour
License
Licensed under the MIT License.
Copyright 2025 Browserbase, Inc.