Skip to content

Commit 5d651c0

Browse files
shrey150claude
andcommitted
Add --connect flag docs to browser skill
Documents the new `browse --connect <session-id>` flag that attaches to an existing Browserbase session instead of creating a new one. Updates SKILL.md, REFERENCE.md, and EXAMPLES.md for the browser skill. Sister PR: browserbase/stagehand#1889 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1f532a1 commit 5d651c0

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

skills/browser/EXAMPLES.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,22 @@ browse stop
130130

131131
**Key pattern**: Use `--context-id <id> --persist` on the first session to save auth state. On subsequent sessions, use `--context-id <id>` (with or without `--persist`) to resume where you left off. Omit `--persist` if you don't want changes from that session saved back.
132132

133+
## Example 6: Attach to an Existing Browserbase Session
134+
135+
**User request**: "Connect to this running Browserbase session and check its state"
136+
137+
Use `--connect` to attach the CLI to a Browserbase session that was created outside the CLI (via the API, dashboard, or another tool). The CLI connects without creating a new session, and `browse stop` disconnects without killing it.
138+
139+
```bash
140+
# Attach to the existing session
141+
browse --connect bb_sess_abc123 open https://app.example.com/dashboard
142+
browse snapshot # inspect the page
143+
browse get text ".status" # extract data
144+
browse stop # disconnect — session stays alive on Browserbase
145+
```
146+
147+
**Key pattern**: `--connect` is for sessions you don't own — the CLI is a guest. `browse stop` only disconnects, it does not terminate the remote session. Cannot be combined with `--context-id`.
148+
133149
## Tips
134150

135151
- **Snapshot first**: Always run `browse snapshot` before interacting — it gives you the accessibility tree with element refs

skills/browser/REFERENCE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,18 @@ Load a Browserbase context to persist browser state (cookies, localStorage, sess
411411
412412
Save browser state changes back to the Browserbase context when the session ends. Must be used with `--context-id`.
413413
414+
#### `--connect <session-id>`
415+
416+
Attach to an existing Browserbase session by ID instead of creating a new one. **Remote mode only** — errors in local mode. The session stays alive after `browse stop` (uses `keepAlive: true`), so you can reconnect later or hand it off to another tool.
417+
418+
```bash
419+
browse --connect bb_sess_abc123 open https://example.com
420+
```
421+
422+
- Mutually exclusive with `--context-id` (the session already exists and has its own state).
423+
- If the daemon is running with a different session ID, it automatically restarts.
424+
- `browse stop` disconnects the CLI but does **not** terminate the Browserbase session.
425+
414426
### Environment Variables
415427
416428
| Variable | Required | Description |

skills/browser/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ All commands work identically in both modes. The daemon auto-starts on first com
5656
browse open <url> # Go to URL (aliases: goto)
5757
browse open <url> --context-id <id> # Load Browserbase context (remote only)
5858
browse open <url> --context-id <id> --persist # Load context + save changes back
59+
browse --connect <session-id> open <url> # Attach to existing Browserbase session (remote only)
5960
browse reload # Reload current page
6061
browse back # Go back in history
6162
browse forward # Go forward in history

0 commit comments

Comments
 (0)