attaching-to-browserlisted
Install: claude install-skill cskwork/attach-to-browser-skill
# Attaching to a Browser
Use this skill when browser automation must run inside the user's real, already-logged-in
browser session — reusing their cookies, SSO, and 2FA — rather than a fresh automated browser.
The tool is **Playwright CLI** (`playwright-cli`), a token-efficient CLI for coding agents.
Its `attach` command connects to a browser the user already controls.
## Install
```bash
npm install -g @playwright/cli@latest
```
The binary is `playwright-cli` (invoke it directly, not via `npx`).
## Choose an attach method
| Method | Command | When to use |
|---|---|---|
| Channel | `playwright-cli attach --cdp=chrome -s=<name>` | Default. The user's normally-launched Chrome/Edge with remote debugging enabled. |
| CDP endpoint | `playwright-cli attach --cdp=http://localhost:9222 -s=<name>` | Browser started with `--remote-debugging-port=9222`. |
| Server endpoint | `playwright-cli attach --endpoint=ws://localhost:3000 -s=<name>` | Connect to a running Playwright server. |
| Extension | `playwright-cli attach --extension -s=<name>` | Playwright browser extension installed. Best for SSO/2FA; reuses the live profile. |
Channel values for `--cdp=<channel>` / `--extension=<channel>`: `chrome`, `chrome-beta`,
`chrome-dev`, `chrome-canary`, `msedge`, `msedge-beta`, `msedge-dev`, `msedge-canary`.
Prefer **channel attach** unless the user's setup requires another method.
## Browser setup (channel / CDP method)
In the target Chrome or Edge:
1. Open `chrome://inspect/#remote-