1---
2name: clawbrowser
3description: Use when the agent needs to drive a browser through the Microsoft Playwright CLI (`playwright-cli`) for navigation, form interactions, screenshots, recordings, data extraction, session management, or debugging without loading a full MCP browser. It trains the agent on the CLI commands, snapshots, and session/config habits that make Playwright CLI reliable for scripted browsing.
4allowed-tools: Bash(playwright-cli:*)
5metadata:
6 source: https://skillmd.com/skills/modbender/clawbrowser
7---
8
9# Clawbrowser – browser control via Playwright CLI
10[](https://clawaudit.duckdns.org/audit/f4d4fb45-ed25-4659-8235-2459d0dc8189)
11[](https://clawaudit.duckdns.org/audit/a55cb413-b111-4f1a-9f39-a5c857090ebf)
12
13## Setup & orientation
141. Install the CLI and verify availability:
15 ```bash
16 npm install -g @playwright/cli@latest
17 playwright-cli --help
18 ```
19 The CLI is headless by default; add `--headed` to `open` or set `browser.launchOptions.headless` to `false` in `playwright-cli.json` when you need to see the UI.
202. The CLI reads `playwright-cli.json` by default or whatever file you pass with `--config`. Use the config to tune browser name, launch/context options, viewport, timeouts, output directories, and recording settings without changing every command.
213. Keep `playwright-cli --help` terminal-accessible; the script self-documents the latest commands and options so you can refresh your memory before trying a new action.
22
23## Core interaction loop
241. Start with `playwright-cli open <url>` to load the page (add `--session=name` if you want isolation up front).
252. Run `playwright-cli snapshot` to generate element refs (`e1`, `e2`, …) before any interaction. Always re-snapshot after DOM changes or navigation to avoid stale refs.
263. Use refs for actions:
27 - `click`, `dblclick`, `hover`, `drag`, `check`, `uncheck`, `select`, `fill`, `type`, `upload`, `eval`
28 - Append `[button]`, `[value]`, or JS snippets as needed (e.g., `playwright-cli click e4 right`).
294. Capture output evidence with `screenshot [ref]`, `pdf`, `console [level]`, or `network` to prove the flow or inspect errors.
305. Example flow:
31 ```bash
32 playwright-cli open https://example.com/login
33 playwright-cli snapshot
34 playwright-cli fill e1 "user@example.com"
35 playwright-cli fill e2 "supersecret"
36 playwright-cli click e3
37 playwright-cli snapshot
38 playwright-cli screenshot
39 ```
40
41## Sessions & persistence
42- Use `--session=<name>` to keep cookies, storage, and tabs isolated per workflow. Sessions behave like persistent profiles: they remember auth state, history, and tabs between commands.
43- Export `PLAYWRIGHT_CLI_SESSION=mysession` if you are running many commands in the same session — the CLI will default to that session without needing `--session` each time.
44- Manage sessions explicitly:
45 ```bash
46 playwright-cli session-list
47 playwright-cli session-stop <name>
48 playwright-cli session-stop-all
49 playwright-cli session-restart <name>
50 playwright-cli session-delete <name>
51 ```
52- Use `playwright-cli --isolated open ...` for ephemeral contexts that do not persist to disk.
53- Whenever you change browser settings for a session (launch args, headless toggle, browser selection), rerun `playwright-cli config` for that session and then `session-restart` to apply the new config.
54
55## Tabs, navigation, and devtools
56- Tab helpers: `tab-list`, `tab-new [url]`, `tab-close <index>`, `tab-select <index>`.
57- Navigation shortcuts: `go-back`, `go-forward`, `reload`.
58- Keyboard and mouse control: `press <key>`, `keydown`, `keyup`, `mousemove <x> <y>`, `mousedown [button]`, `mouseup [button]`, `mousewheel <dx> <dy>`.
59- Devtools-style introspection:
60 ```bash
61 playwright-cli console [level]
62 playwright-cli network
63 playwright-cli run-code "async page => await page.context().grantPermissions(['clipboard-read'])"
64 ```
65 Use these to check console logs, inspect network requests, or inject helper scripts.
66
67## Recording, tracing, and exports
68- Record traces and videos around delicate interactions so you can replay what the agent did later:
69 ```bash
70 playwright-cli tracing-start
71 # perform steps
72 playwright-cli tracing-stop
73 playwright-cli video-start
74 # perform steps
75 playwright-cli video-stop video.webm
76 ```
77- Save evidence to disk with `screenshot`, `pdf`, or `snapshot` (which dumps element refs). Recorded files honor the `outputDir` from your config.
78
79## Config, state, and housekeeping
80- Use `playwright-cli config` to tweak runtime flags without reinstalling. Examples:
81 ```bash
82 playwright-cli config --headed --browser=firefox
83 playwright-cli --session=auth config --config=playwright-cli.json
84 ```
85 Change `browser`, `contextOptions`, `launchOptions`, or recording settings in the config and restart the session to apply them.
86- Running `playwright-cli install` refreshes browser binaries if the environment is new or you receive errors about missing binaries.
87- Clean up sessions when finished to avoid stale state:
88 ```bash
89 playwright-cli session-stop <name>
90 playwright-cli session-delete <name>
91 ```
92
93## Troubleshooting & reminders
94- If a command fails, rerun `playwright-cli snapshot` to confirm refs are still valid. Snapshots provide the current DOM context for `click`/`type` operations.
95- `playwright-cli --help` always shows the latest command set, so consult it before trying a rarely used flag.
96- When the agent needs to replicate a recorded manual flow, capture a screenshot, note the session name, and mention which refs and tabs were in use.
97- If targeting a visible browser is required (e.g., manual inspection), reconfigure with `--headed`, or run `playwright-cli open --headed <url>` for that session only.