DEV Community

Cover image for Stop AI Agents From Hijacking Your Chrome Window: Fork Live Sessions into Headless Playwright MCP
Wasabi hu
Wasabi hu

Posted on

Stop AI Agents From Hijacking Your Chrome Window: Fork Live Sessions into Headless Playwright MCP

Whenever I ask an AI coding agent (Claude Code, Cursor, or Google Antigravity) to check an authenticated web page — a GitHub PR, a Linear sprint board, a Notion doc, or an internal dashboard — browser automation usually leaves me with two frustrating options:

  1. Launch a fresh headless browser -> hit login walls, SSO, and 2FA every single session.
  2. Attach directly to my live Chrome window -> the agent steals window focus, switches tabs while I'm reading or coding, and gets access to every other open tab in my main browser.

To fix this cleanly, I built sessfork — a pure Python, zero-runtime-dependency CLI that decouples your foreground UI viewport from your browser auth state in a single command.


How sessfork Works Under the Hood

Instead of taking over your main browser window, sessfork snapshots only the auth state you explicitly ask for and hands it to a silent background headless Playwright MCP server (sessfork-browser):

  1. Lock-free snapshots of live Chrome: Reads Chromium's SQLite Cookies database and LevelDB Local Storage/leveldb without locking or closing your running browser.
  2. Cookies + SPA/JWT LocalStorage support: Decrypts cookies in memory via native OS APIs (zero third-party Python packages) and performs LevelDB MVCC sequence reconciliation so modern SPA bearer tokens stored in localStorage carry over cleanly.
  3. Domain-scoped isolation (0600): Strictly filters by an explicit domain allowlist (e.g., sessfork github.com linear.app) and atomically writes a standard Playwright storageState JSON file with 0600 permissions.
  4. Zero-restart hot reload: Automatically wires sessfork-browser (@playwright/mcp --headless) into Claude Code, Cursor, and Antigravity. When you fork a new domain later, your agent hot-reloads the updated state into memory without restarting MCP.

10-Second Quickstart

Try it immediately with uvx (no global install needed):

uvx --from git+https://github.com/wasabihu/sessfork sessfork github.com
Enter fullscreen mode Exit fullscreen mode

Or run the one-click setup script to auto-detect your installed AI editors, wire the background sessfork-browser MCP server, and install the global Agent SKILL.md:

curl -fsSL https://raw.githubusercontent.com/wasabihu/sessfork/main/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Once configured, you don't even have to remember CLI flags — just talk to your agent:

"Use sessfork to fork my github.com login session into sessfork-browser, then silently check my unread notifications and review the failing PR checks without touching my active Chrome window."


How Is This Different From Dedicated AI Browsers (like ego-lite)?

A few people asked how sessfork compares to dedicated AI browsers such as ego-lite. Both solve the "don't disturb me while the agent browses" problem, but they take very different paths:

  • Keep your native browser: Dedicated AI browsers ship a separate Chromium desktop app and ask you to migrate or run a second daily browser. sessfork is a tiny stdlib-only CLI — you stay in your existing Chrome, Arc, Brave, or Edge.
  • Least-privilege domain allowlist: Many developers don't want to import their entire Chrome profile (banking, primary email, corporate SSO, extensions, and every open tab) into an AI browser. sessfork forks only the 1–2 domains you explicitly name as a one-way snapshot.
  • Standard Playwright ecosystem: Because sessfork produces standard Playwright storageState, it works out of the box with official @playwright/mcp as well as your own Playwright scripts and headless automation pipelines.

If you want a visual cursor showing every click or routinely deal with heavy headed anti-bot checks, a dedicated AI browser is great. If you want to keep your native browser untouched and expose only specific domains to a silent headless agent, sessfork is much lighter and cleaner.


Security Guardrails

  • No silent all-domain dumps: You explicitly pass the domains to fork.
  • Keychain stays in charge: On macOS, Keychain prompts for "Chrome Safe Storage" when decrypting cookies (or pass --no-cookies for pure localStorage JWT apps to skip Keychain entirely).
  • Easy cleanup: Run sessfork --clear <domain> or sessfork --clear at any time to wipe cached session snapshots.

Check out the repo and the interactive architecture walkthrough if you'd like to give it a spin — feedback and edge-case reports are always welcome!

Top comments (0)