Cookie Sync
BrowserbaseOfficialPublished by Browserbase
- Skill
- Tool integration
- Automation and integrations
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
Cookie Sync enables users to export authentication cookies from a local Chromium-based browser into a Browserbase persistent context. This allows developers to perform automated browsing tasks in the cloud while maintaining the authenticated state of their local browser sessions. It supports domain-specific filtering, context refreshing, and integration with Browserbase features like verified browser mode and residential proxies to help manage site access.
What it does
- Exports cookies from a local Chrome or Chromium instance to a Browserbase persistent context
- Allows filtering of synced cookies by specific domains and subdomains
- Refreshes cookies within an existing Browserbase context to extend session validity
- Supports integration with Browserbase Identity and residential proxies for improved site access
- Facilitates authenticated browsing sessions in the cloud using the browse CLI
When to use it
- When you need to access authenticated websites via Browserbase using your local credentials
- When you want to maintain persistent sessions for scheduled or recurring cloud-based tasks
- When you need to bypass site-specific restrictions by matching your local IP geolocation
- When you need to refresh expired cookies in an existing cloud context
Advantages
- Enables seamless transition from local browser authentication to cloud-based automation
- Supports persistent contexts that survive across multiple sessions
- Provides granular control over which cookies are synced to the cloud
- Helps mitigate authentication rejection through proxy and verified browser options
Usage examples
- “Sync my GitHub cookies to a new Browserbase context.”
- The tool extracts GitHub-related cookies from the local browser and returns a new context ID for use with the browse CLI.
- “Refresh the cookies in my existing context ctx_abc123.”
- The tool re-injects current local cookies into the specified context, updating it for continued use.
- “Sync cookies for twitter.com using a San Francisco residential proxy.”
- The tool syncs the specified cookies and configures the context to route traffic through a San Francisco-based residential proxy.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/browserbase/cookie-sync/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip cookie-sync.zip -d .agents/skills
Documentation by Browserbase
Cookie Sync — Local Chrome → Browserbase Context
Exports cookies from your local Chrome and saves them into a Browserbase persistent context. After syncing, use the browse CLI to open authenticated sessions with that context.
Supports domain filtering (only sync cookies you need) and context reuse (refresh cookies without creating a new context).
Prerequisites
Chrome (or Chromium, Brave, Edge) with remote debugging enabled
If your browser build exposes
chrome://flags/#allow-remote-debugging, enable it and restart the browserOtherwise, launch with
--remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debugand setCDP_URL=ws://127.0.0.1:9222At least one tab open in Chrome
Node.js 22+
Environment variable:
BROWSERBASE_API_KEY
Setup
Install dependencies before first use:
cd .claude/skills/cookie-sync && npm installUsage
Basic — sync all cookies
node .claude/skills/cookie-sync/scripts/cookie-sync.mjsCreates a persistent context with all your Chrome cookies. Outputs a context ID.
Filter by domain — only sync specific sites
node .claude/skills/cookie-sync/scripts/cookie-sync.mjs --domains google.com,github.comMatches the domain and all subdomains (e.g. google.com matches accounts.google.com, mail.google.com, etc.)
Refresh cookies in an existing context
node .claude/skills/cookie-sync/scripts/cookie-sync.mjs --context ctx_abc123Re-injects fresh cookies into a previously created context. Use this when cookies have expired.
Verified browser mode
node .claude/skills/cookie-sync/scripts/cookie-sync.mjs --verifiedEnables Browserbase Identity with a Verified browser to improve access on protected sites. Recommended for sites like Google that fingerprint browsers.
Residential proxy with geolocation
node .claude/skills/cookie-sync/scripts/cookie-sync.mjs --proxy "San Francisco,CA,US"Routes through a residential proxy in the specified location. Format: "City,ST,Country" (state is 2-letter code). Helps match your local IP's geolocation so auth cookies aren't rejected.
Combine flags
node .claude/skills/cookie-sync/scripts/cookie-sync.mjs --domains github.com,google.com --verified --proxy "San Francisco,CA,US"Browsing Authenticated Sites
After syncing, use the browse CLI with the context ID:
SESSION_JSON="$(browse cloud sessions create --context-id <ctx-id> --persist --keep-alive)"
SESSION_ID="$(echo "$SESSION_JSON" | jq -r .id)"
CONNECT_URL="$(echo "$SESSION_JSON" | jq -r .connectUrl)"
browse open https://mail.google.com --cdp "$CONNECT_URL"The --persist flag on browse cloud sessions create saves any new cookies or state changes back to the context when the cloud session is released, keeping the session fresh for next time.
Full workflow example:
# Step 1: Sync cookies for Twitter
node .claude/skills/cookie-sync/scripts/cookie-sync.mjs --domains x.com,twitter.com
# Output: Context ID: ctx_abc123
# Step 2: Browse authenticated Twitter
SESSION_JSON="$(browse cloud sessions create --context-id ctx_abc123 --persist --keep-alive)"
SESSION_ID="$(echo "$SESSION_JSON" | jq -r .id)"
CONNECT_URL="$(echo "$SESSION_JSON" | jq -r .connectUrl)"
browse open https://x.com/messages --cdp "$CONNECT_URL"
browse snapshot
browse screenshot
browse stop
browse cloud sessions update "$SESSION_ID" --status REQUEST_RELEASEReusing Contexts for Scheduled Jobs
Contexts persist across sessions, making them ideal for scheduled/recurring tasks:
Once (laptop open): Run cookie-sync → get a context ID
Scheduled jobs: Create a Browserbase session with
browse cloud sessions create --context-id <ctx-id> --persist --keep-alive, then attach withbrowse open <url> --cdp <connectUrl>— no local Chrome neededRe-sync as needed: When cookies expire, run cookie-sync again with
--context <ctx-id>to refresh
Troubleshooting
"No DevToolsActivePort found" → Enable
chrome://flags/#allow-remote-debuggingif your browser build exposes it, or launch with--remote-debugging-port=9222and setCDP_URL=ws://127.0.0.1:9222"No open page targets found" → Open at least one tab in Chrome
"WebSocket error" → Chrome may be hung; force quit and reopen it
Cookies expired in context → Re-run cookie-sync with
--context <id>to refreshAuth rejected by site → Try adding
--verifiedand/or--proxywith a location near you
Files
- ATTRIBUTION.mdAdded by AutoGineer866 B
- EXAMPLES.md3.5 KiB
- LICENSE.txt1.0 KiB
- REFERENCE.md5.1 KiB
- SKILL.md4.9 KiB
- package-lock.json147.1 KiB
- package.json191 B
- scripts/cookie-sync.mjsScript11.2 KiB
REFERENCE.md
Cookie Sync Reference
Table of Contents
Architecture
Environment Variables
How It Works
Browserbase Context Integration
Browser Compatibility
Security Considerations
Architecture
Cookie sync is a Node.js script that uses:
Stagehand (
@browserbasehq/stagehand) for CDP connections to both local Chrome and the cloud browser, including cookie get/set operationsBrowserbase SDK (
@browserbasehq/sdk) for API calls (context creation)
Local Chrome (Stagehand) → cookie-sync.mjs → Stagehand (Browserbase) → Cloud Browser
↓ ↓ ↓
context.cookies() init() creates session context.addCookies()Environment Variables
| Variable | Required | Description |
|---|---|---|
BROWSERBASE_API_KEY | Yes | API key from https://browserbase.com/settings |
BROWSERBASE_CONTEXT_ID | No | Reuse an existing context instead of creating a new one |
CDP_URL | No | Direct WebSocket URL to Chrome (e.g. ws://127.0.0.1:9222). Use when Chrome is launched with --remote-debugging-port and no DevToolsActivePort file exists |
CDP_PORT_FILE | No | Custom path to DevToolsActivePort file |
CDP_HOST | No | Custom host for local Chrome connection (default: 127.0.0.1) |
How It Works
Step 1: Connect to Local Chrome
The script finds Chrome's DevTools WebSocket URL in one of two ways:
If
CDP_URLis set, it resolves the browser WebSocket endpoint from that debugging endpoint (or uses the full browser WebSocket URL directly)Otherwise, it reads the
DevToolsActivePortfile created by browsers that expose remote debugging through their normal profile
Step 2: Export Cookies
Calls context.cookies() via Stagehand's Understudy layer (which uses Storage.getCookies over CDP). This returns all cookies from all domains stored in the browser — not just the active tab.
Step 3: Create Context and Session
Creates a Browserbase Context via the SDK (persistent state container) and a Stagehand session attached to that context with persist: true. This means:
Cookies injected during this session are saved to the context
Future sessions using the same context ID start with those cookies
The session uses
keepAlive: trueso it stays open until explicitly closed
Step 4: Inject Cookies
Calls context.addCookies() via Stagehand's Understudy layer (which uses Storage.setCookies over CDP) to inject all exported cookies into the cloud browser.
Browserbase Context Integration
Contexts persist browser state (cookies, localStorage, IndexedDB) across sessions.
First sync (creates context)
node cookie-sync.mjs
# Output includes: Context ID: ctx_abc123Subsequent sessions (reuses context)
BROWSERBASE_CONTEXT_ID=ctx_abc123 node cookie-sync.mjsContext lifecycle
Contexts don't expire on Browserbase's end
Cookies within the context expire based on the website's cookie policies
Use one context per user/identity to avoid session conflicts
Avoid running multiple sessions with the same context simultaneously
Browser Compatibility
Supported Browsers
| Browser | macOS | Linux | Windows |
|---|---|---|---|
| Google Chrome | Yes | Yes | Yes |
| Chrome Beta | Yes | Yes | — |
| Chrome for Testing | Yes | — | — |
| Chromium | Yes | Yes | — |
| Brave | Yes | Yes | Yes |
| Microsoft Edge | Yes | Yes | Yes |
| Vivaldi | — | Yes | — |
Enabling Remote Debugging
Chrome 146+ (recommended):
Navigate to
chrome://flags/#allow-remote-debuggingSet to "Enabled"
Restart Chrome
Any Chrome version (requires --user-data-dir and CDP_URL):
# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
export CDP_URL=ws://127.0.0.1:9222
# Linux
google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug
export CDP_URL=ws://127.0.0.1:9222
# Windows
chrome.exe --remote-debugging-port=9222 --user-data-dir=%TEMP%\chrome-debug
set CDP_URL=ws://127.0.0.1:9222Note: --user-data-dir is required because Chrome won't open the debugging port with an existing profile. This means the debug instance starts with a fresh profile — your real cookies are not available. The chrome://flags method (Chrome 146+) does not have this limitation.
Security Considerations
Cookies are sensitive credentials. The script transfers your authenticated sessions to a cloud browser. Only use with your own Browserbase account.
Cookies are transmitted over secure WebSocket (
wss://) to Browserbase.The script does not log, store, or transmit cookies anywhere other than the target Browserbase session.
Sessions created with
keepAlive: truepersist until explicitly closed — remember to close sessions when done.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Declares allowed tools, Needs an API key, Needs Node.js
The author says: Requires Node.js 22+, a local Chromium-based browser (Chrome, Brave, Edge) with remote debugging enabled, and BROWSERBASE_API_KEY. Run `npm install` in the skill directory before first use.
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Browserbase
- Publisher
- Browserbase (Official)
- Source
- browserbase/skills · skills/cookie-sync · commit 6811ca3
- Licence
- MIT License (redistribution allowed)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Browserbase or Browserbase.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download cookie-sync.zip