Playwriter

From akillness/jeo-skills · View interactive version

Playwriter is an AI agent skill from the GitHub repository akillness/jeo-skills. Reuse a running Chrome session for browser automation via Playwriter CLI + MCP. Use when the task depends on the browser the user already has open — existing logins, cookies, extensions, passkey-friendly flows, or live-tab continuity. Route repeatable fresh-browser or CI-style checks to `browser-har

How to use this skill

Skill file

playwriter

Playwriter is the running-browser browser-automation skill. It connects an agent to Chrome/Chromium that is already part of the user’s real workflow instead of spawning a clean disposable browser. That makes it useful for authenticated flows, extension-dependent pages, and long-lived tab context — but less reproducible than a fresh-session browser tool.

When to use this skill

Use playwriter when the task needs one or more of these:

Do not use playwriter by default for:

Quick routing rule

| If the job needs... | Use |

|---|---|

| The browser the user already has open | playwriter |

| Existing logins / cookies / extensions | playwriter |

| A clean, reproducible, disposable session | browser-harness |

| Headless verification / screenshot diffs / isolated checks | browser-harness |

| Hosted or cloud browser infrastructure | a provider-specific or cloud-browser skill |

Instructions

Step 1: Pick the right browser runtime

Use playwriter only when running-browser reuse is the requirement. If the task is really about a clean disposable browser or CI-style reproducibility, route to browser-harness instead.

Step 2: Follow the core workflow

Always follow the same loop:

  1. Prepare the running-browser bridge
  2. Create or select a session
  3. Observe first with snapshot({ page })
  4. Act once
  5. Observe again before the next action

Step 1: Install the extension and CLI

# install the CLI
npm install -g playwriter
# or use it without global install
npx playwriter@latest --help

Install the Playwriter Chrome extension, then click the extension icon on the tab you want to control. The tab should show the connected/green state before you assume automation is available.

Step 2: Start browser support and create a session

Use the upstream browser/session flow, not a vague “extension auto-starts everything” assumption:

# start the managed browser/runtime if needed
playwriter browser start

# create a stateful sandbox session
playwriter session new

# inspect current sessions
playwriter session list

Notes:

Step 3: Observe → act → observe

# navigate
playwriter -s 1 -e 'await page.goto("https://example.com")'

# observe current page state
playwriter -s 1 -e 'console.log(await snapshot({ page }))'

# act using a fresh aria-ref from the snapshot
playwriter -s 1 -e 'await page.locator("aria-ref=e5").click()'

# observe again after the action
playwriter -s 1 -e 'console.log(await snapshot({ page }))'

Rules:

High-value command patterns

Navigation and state

playwriter browser start
playwriter session new
playwriter session list
playwriter session reset 1
playwriter session delete 1

Execute Playwright code in a session

# basic navigation
playwriter -s 1 -e 'await page.goto("https://github.com")'

# fill + submit
playwriter -s 1 -e 'await page.fill("#search", "playwriter"); await page.keyboard.press("Enter")'

# save reusable state between calls
playwriter -s 1 -e 'state.lastUrl = page.url(); state.heading = await page.textContent("h1")'
playwriter -s 1 -e 'console.log(state.lastUrl, state.heading)'

Multiline code safely

playwriter -s 1 -e "$(cat <<'EOF'
const title = await page.title();
state.title = title;
console.log(await snapshot({ page }));
EOF
)"

Use heredocs when the JavaScript would become fragile with quoting.

MCP integration

Use Playwriter when a model client needs browser tooling for the running browser, not when it simply needs any browser tool.

Example MCP config

{
  "mcpServers": {
    "playwriter": {
      "command": "npx",
      "args": ["-y", "playwriter@latest"]
    }
  }
}

Common uses:

Safety and expectations

Troubleshooting

| Issue | What to check |

|---|---|

| Nothing responds | Confirm the extension is installed and enabled on the target tab |

| Wrong tab/page state | Re-run snapshot({ page }) and confirm you are on the expected tab before clicking |

| Stale / broken session | playwriter session reset <id> |

| Quoting breaks JavaScript | Use a heredoc for -e input |

| Need repeatable isolated automation | Route to browser-harness instead |

| Browser state is too messy / human interference | Start a fresh session or use a fresh-session browser tool |

Examples

Example 1: Logged-in SaaS workflow

Example 2: Clean browser verification

Example 3: MCP browser bridge

Best practices

  1. Choose playwriter because the browser state matters, not because the word “browser” appears.
  2. Start with snapshot({ page }) before any action that could hit the wrong tab or stale UI state.
  3. Re-snapshot after each meaningful action; live browser state drifts faster than isolated automation state.
  4. Use heredocs for non-trivial JavaScript to avoid shell-quoting bugs.
  5. Treat manual login / MFA / CAPTCHA handoff as normal in this lane.
  6. Report why a running browser was necessary and when a fresh-session tool would have been safer.

References

Deep-dive docs in this skill:

Primary sources:

Output expectations

When using this skill, report:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.