cookie-sync
Original:🇺🇸 English
Translated
1 scripts
Sync cookies from local Chrome to a Browserbase persistent context so the browse CLI can access authenticated sites. Use when the user wants to browse as themselves, sync cookies, or log into sites via Browserbase.
14installs
Sourcebrowserbase/skills
Added on
NPX Install
npx skill4agent add browserbase/skills cookie-syncTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Cookie Sync — Local Chrome → Browserbase Context
Exports cookies from your local Chrome and saves them into a Browserbase persistent context. After syncing, use the CLI to open authenticated sessions with that context.
browseSupports 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 , enable it and restart the browser
chrome://flags/#allow-remote-debugging - Otherwise, launch with and set
--remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debugCDP_URL=ws://127.0.0.1:9222 - At least one tab open in Chrome
- Node.js 22+
- Environment variable:
BROWSERBASE_API_KEY
Setup
Install dependencies before first use:
bash
cd .claude/skills/cookie-sync && npm installUsage
Basic — sync all cookies
bash
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
bash
node .claude/skills/cookie-sync/scripts/cookie-sync.mjs --domains google.com,github.comMatches the domain and all subdomains (e.g. matches , , etc.)
google.comaccounts.google.commail.google.comRefresh cookies in an existing context
bash
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.
Advanced stealth mode
bash
node .claude/skills/cookie-sync/scripts/cookie-sync.mjs --stealthEnables Browserbase's advanced stealth mode to reduce bot detection. Recommended for sites like Google that fingerprint browsers.
Residential proxy with geolocation
bash
node .claude/skills/cookie-sync/scripts/cookie-sync.mjs --proxy "San Francisco,CA,US"Routes through a residential proxy in the specified location. Format: (state is 2-letter code). Helps match your local IP's geolocation so auth cookies aren't rejected.
"City,ST,Country"Combine flags
bash
node .claude/skills/cookie-sync/scripts/cookie-sync.mjs --domains github.com,google.com --stealth --proxy "San Francisco,CA,US"Browsing Authenticated Sites
After syncing, use the CLI with the context ID:
browsebash
browse open https://mail.google.com --context-id <ctx-id> --persistThe flag saves any new cookies or state changes back to the context, keeping the session fresh for next time.
--persistFull workflow example:
bash
# 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
browse open https://x.com/messages --context-id ctx_abc123 --persist
browse snapshot
browse screenshot
browse stopReusing 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: Use — no local Chrome needed
browse open <url> --context-id <ctx-id> --persist - Re-sync as needed: When cookies expire, run cookie-sync again with to refresh
--context <ctx-id>
Troubleshooting
- "No DevToolsActivePort found" → Enable if your browser build exposes it, or launch with
chrome://flags/#allow-remote-debuggingand set--remote-debugging-port=9222CDP_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 to refresh
--context <id> - Auth rejected by site → Try adding and/or
--stealthwith a location near you--proxy