# Your own browser

> sc-browse attaches the session to the Chrome you already run, drives it through the mcpr CLI, reviews screenshots with gaze, and reads PDFs text-first.
>
> Your agent can use pages that need a real browser.

This feature is the `sc-browse` plugin. It is a default plugin: sc expects it in every workspace, and `sc doctor` flags a manifest that leaves it out. It needs no other plugin.

Claude Code uses it when the task calls for it, so you do not have to call it by name.

What you get in every workspace:

- The agent reads your app as rendered in Chrome, not an empty shell.
- It uses the Chrome you are signed in to, so your logins work.
- Screenshots go to gaze, which reads images, and you get a written answer.

sc-browse lets the agent drive the Chrome you already have open through the `mcpr` CLI, review screenshots with `gaze`, and read PDFs. Turn on remote debugging once at `chrome://inspect/#remote-debugging`.

## Using it

Ask in plain words. The agent decides when a page needs a real browser.

> Check that the signup form shows an error for a duplicate email.

The agent lists your Chrome tabs, reads the page, fills the form and checks the console, then reports what it found.

> Look at example.com/dashboard and tell me what is broken in the layout.

It saves a screenshot to disk and has `gaze` answer your question about it. The report gives the file path.

> List every required header in section 4 of ~/Downloads/spec.pdf.

It extracts the text with `pdftotext`. For a scanned PDF it renders the pages in Chrome and reads them with `gaze`.

> Open localhost:3000, log in with the test account, add two items to the cart and tell me what the console shows at checkout.

Subagents can browse too, so a subagent that needs a rendered page opens one itself.

**How it works**

Every browser action is a Bash call to `mcpr`, which keeps one chrome-devtools session alive in a background daemon. The agent reads the page's accessibility tree, and takes screenshots only for visual review by `gaze`.

### When a browser, and when a plain fetch

Most sites render on the client, so `curl`, WebFetch and a search crawl get an empty HTML shell; a browser runs the JavaScript. For search and static pages a plain fetch is the cheaper tool. The rule is published as [when-to-use](/prompts#p-sc-browse-when-to-use). It also tells the agent never to launch a browser of its own, such as headless Chrome, `--screenshot`, puppeteer or playwright. Page loads, screenshots and viewport or theme checks go through `mcpr chrome`: `emulate` sets the viewport and colour scheme on one tab, and `new_page` with `isolatedContext` gives a clean slate.

A fresh headless browser has no cookies and no logins, so it cannot reach pages behind your login. Attaching to your own Chrome gives the agent your real session.

### One Chrome session, owned by mcpr

`mcpr` turns an MCP server into shell commands and keeps that server alive in a background daemon. sc-browse expects an mcpr alias named `chrome` that runs `chrome-devtools-mcp --autoConnect`, which attaches to your running Chrome and never launches one.

Connecting to Chrome's remote debugging port raises an accept dialog. The first `mcpr chrome` call starts the daemon and you accept the dialog then. Later calls reuse that connection, so the dialog appears once per daemon lifetime. This is why the plugin ships no `.mcp.json`: a chrome-devtools MCP server declared there would open a second session and a second round of dialogs.

The tool list comes from chrome-devtools itself, so the skills tell the agent to discover it rather than guess:

```sh
mcpr chrome -h
mcpr chrome <tool> -h
```

Every page-scoped tool needs a numeric `pageId`, taken from `list_pages` or from the `[selected]` line `new_page` prints. Always pass the JSON argument, `'{}'` when a tool takes none; without one, mcpr reads stdin when it is piped, as it is in an agent's shell.

```sh
mcpr chrome list_pages '{}'
mcpr chrome navigate_page '{"pageId":3,"url":"https://example.com"}'
mcpr chrome take_snapshot '{"pageId":3}'
```

If a call fails validation on a field `-h` did not list, mcpr's schema cache predates a chrome-devtools upgrade. Run `mcpr chrome refresh` once. If a `pageId` stops resolving, run `list_pages` again.

`mcpr` exits `0` on success, `1` when Chrome is unreachable or the JSON argument is bad, `2` on an unknown tool or flag, and `3` when the tool ran but reported an error. The skills branch on those codes. On an unreachable Chrome, the agent reports once and stops instead of retrying in a loop.

### Structure first, vision second

`take_snapshot` returns the accessibility tree with a `uid` for each element, and clicks and form fills target those uids. Text and structure come off the snapshot, which costs no image tokens and gives the same answer twice. The agent takes a screenshot only for the visual pass: layout, spacing, regressions.

The navigate skill also sets working rules for the agent:

- Snapshot before interacting, and re-snapshot after any DOM change, because uids go stale.
- Prefer one `fill_form` call over many single fills.
- Use `evaluate_script` only when no uid-based tool does the job.
- Never run web searches there; a browser is the wrong tool for search.
- Never quote or save `Authorization` or `Cookie` header values or API keys seen in console or network output. Note where they are, not what they say.
- Run a dev server under test in `tmux`, never in a blocking shell.

If the project has `browsing/` memory, under `claude-data/browsing/` or the project's memory namespace, the skill reads it first. Its files are `key-pages.md`, `nav-map.md`, `auth.md`, `selectors.md` and `known-issues.md`. It writes new selectors, nav maps and known issues back there.

### Screenshots go to disk, then to gaze

The screenshot skill passes chrome-devtools' `filePath` argument, so Chrome writes the PNG straight to `$CLAUDE_PROJECT_DIR/claude-data/screenshots/`. The path is always absolute, because a relative one resolves against the daemon's directory. Then the agent runs `gaze` on that file. `gaze` has no presets: you put the question in `-p`, and a specific, single-focus question works best.

```sh
gaze analyze <shot.png> -p "is the visual hierarchy clear? what competes for attention?"
gaze analyze <before.png> <after.png> -p "what changed between these? group as intended, regression, ambiguous"
gaze analyze <shot.png> --json -p "extract the component tree as JSON"
```

Give `gaze` image paths or `--stdin`, not both. It converts format and size itself. It runs a different vision model from the session's, with one generic design-minded system prompt, so the answer is a second opinion on what the image is and does. It uses DeepSeek by default and Gemini when selected with `--provider` or `defaults.provider` in its config.

`gaze` exits `0` on success and `2` on bad arguments. Exit `3` means auth or config: the agent has you run `gaze config init` and set the key. Exit `4` is transient (a 429, a timeout, or model resolution offline), so the agent backs off and retries. Exit `5` means no model was found; pin a literal `model` in the config.

If a screenshot fails with `Access denied: … not within any of the configured workspace roots`, the `chrome` alias has no write root covering that path. See the alias under Configuration. The agent reports it once and does not retry.

### PDFs, text first

With `pdftotext` (poppler) on the host, the skill streams the text with `pdftotext -layout`, which keeps columns. For a URL it downloads the file into `claude-data/pdf/` first. If the output is empty or garbage, the PDF is image-only and the skill falls through to the render path.

The render path opens the PDF in its own Chrome tab, screenshots each page into `claude-data/pdf-pages/`, advances with `press_key` `PageDown`, and has `gaze` transcribe each page with a plain `-p` prompt. The answer cites page numbers, and says so when it came from vision and may have OCR-style errors.

### The image hint and the prerequisite check

A `PreToolUse` hook on Read watches for paths ending in `.png`, `.jpg`, `.jpeg`, `.webp`, `.heic` or `.heif`. It allows the read and injects a hint with the `gaze analyze` command to run instead. It does not block: reading the image directly is fine too. Every other Read passes untouched, and if the hook itself errors it lets the call through. The hint applies to every raster image in the session, not only browser screenshots.

The plugin's prompt adds the rule for consuming an image directly: do it in a `fork` subagent, so the pixels stay out of the main window and only a text summary comes back. One small image and one quick question is fine to Read directly.

A `SessionStart` hook (on startup, resume, clear and compact) checks `mcpr`, the `chrome` alias (`persistent = true` and a `--workspace`), `chrome-devtools-mcp` or `npx`, and `gaze` with `gaze config check`. For anything missing it injects a short warning with the fix. It never blocks the session.

**What it needs**

Since sc 0.2.2, `sc system` installs `mcpr` and `gaze` into `~/.superclaude/bin`, which every session gets first on its PATH. When you have no `~/.config/mcpr/config.toml`, it writes one with the `chrome` alias; an existing file is never touched. You bring Chrome, Node and a `gaze` key. No other plugin is involved.

| Needs | Required | What for |
|---|---|---|
| Chrome 144+ with remote debugging on | yes | the browser the plugin attaches to |
| `mcpr` with a `chrome` alias | yes, installed by `sc system` | one persistent chrome-devtools session as shell commands |
| Node with `npx`, or `chrome-devtools-mcp` installed | yes | runs `chrome-devtools-mcp`, the MCP server behind the alias |
| `gaze`, with a key in `~/.config/gaze/config.toml` | for screenshots and scanned PDFs | the vision review (`gaze` is installed by `sc system`; the key is yours) |
| `python3` | yes | the `SessionStart` and `PreToolUse` hooks |
| `pdftotext` (poppler) | no | the fast text path for PDFs; without it every PDF takes the render path |
| `tmux` | no | running a dev server under test without blocking the shell |

Set the `gaze` key with `gaze config init`, then add `api_key` under `[providers.deepseek]` (the default) or `[providers.gemini]` in `~/.config/gaze/config.toml`. That file is the only place `gaze` reads the key; an exported environment variable is ignored. `gaze config check` exits `0` when a key is set for the default provider.

**Configuration**

The plugin has no settings of its own. The setup is the mcpr alias in `~/.config/mcpr/config.toml`, which `sc system` writes when the file is missing:

```toml
[servers.chrome]
type = "stdio"
command = "npx"
args = ["-y", "chrome-devtools-mcp@latest", "--autoConnect", "--workspace", "${HOME}"]
persistent = true
```

- Keep `persistent = true`. Without it the daemon does not hold the connection, and Chrome asks you to accept on every call.
- Keep `--autoConnect`: it attaches to the Chrome you are running. The skills never launch Chrome and never use `--browserUrl`, because a Chrome started fresh has none of your logged-in sessions.
- Keep `--workspace`, a write root. mcpr negotiates no MCP roots, so without it chrome-devtools-mcp refuses every screenshot `filePath` outside its own temp directory.
- With `chrome-devtools-mcp` installed, `command = "chrome-devtools-mcp"` and `args = ["--autoConnect", "--workspace", "${HOME}"]` work the same.

After you edit the file, stop the daemon so the next call restarts it. Chrome asks you to accept again. Check on it with:

```sh
mcpr daemon status chrome
mcpr daemon stop chrome
```

sc expects sc-browse in every workspace, so a manifest should name it. If yours does not, add it:

```toml
plugins = ["$SC_PLUGINS/sc-browse"]
```

`plugin.toml` publishes two sections, `sc-browse:when-to-use` and `sc-browse:image-processing`. Both render in the main agent's prompt of every workspace that loads the plugin, after the workspace's own sections; subagents get neither. Name one in `system_prompt` only to pin where it renders. To see the assembled prompt, run:

```sh
sc <project> <agent> --prompt
```

See [superclaude.toml](/docs/superclaude-toml) for the full `system_prompt` grammar.
