playwright-cli

A command set for driving a real Chromium browser with Playwright, a tool for automating web pages.

In plain words
What is it for?
Use it to scrape pages, take screenshots or PDFs, fill in forms, click through user interfaces, and run end-to-end tests.
Why use it?
It removes the need to set up a separate tool server for browser automation.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/fwornle/coding/playwright-cli
Clone the repo
git clone --depth 1 https://github.com/fwornle/coding

Made for: Claude Code.

Per session 145 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,881 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00145 $0.01881
Opus 5 $0.00072 $0.00941
Sonnet 5 $0.00029 $0.00376
Haiku 4.5 $0.00015 $0.00188

Measured yesterday against content hash de51fc2d37df, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

playwright-cli scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

| Dashboard not responding | Check `curl -s http://localhost:3032` first, rebuild if needed |
.claude/commands/playwright-cli.md · 238 lines

How it starts

The opening of the file, as written. The whole thing — 238 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Playwright CLI Skill

Drive a real Chromium browser from the bash_tool using Playwright (Node.js). No MCP server needed.


1. Environment Setup

Always run this check first. It's fast and idempotent.

# Check Node + npx availability
node --version && npx --version

# Check if playwright is available; install if not
if ! npx playwright --version 2>/dev/null; then
  echo "Installing Playwright..."
  npm install -D playwright 2>&1 | tail -5
  npx playwright install chromium 2>&1 | tail -10
fi

If npm install fails due to network restrictions, inform the user that Playwright must be pre-installed in their environment.

Working directory: Write scripts to /tmp/pw-scripts/ and run from there. For E2E test specs, use the project's tests/e2e/ directory structure.


2. Script Patterns

Write a Node.js script, save it, run it with node. Always use these boilerplate patterns:

Boilerplate (all scripts)

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({ headless: true });
  const context = await browser.newContext();
  const page = await context.newPage();

  try {
    // --- your task here ---
  } catch (err) {
    console.error('Error:', err.message);
    process.exit(1);
  } finally {
    await browser.close();
  }
})();

Screenshot

await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.screenshot({ path: '/tmp/pw-scripts/screenshot.png', fullPage: true });
console.log('Screenshot saved.');

PDF

await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.pdf({ path: '/tmp/pw-scripts/output.pdf', format: 'A4' });
console.log('PDF saved.');

Web Scraping

await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });

// Wait for a key element if needed
await page.waitForSelector('.content', { timeout: 10000 });

const data = await page.evaluate(() => {
  // Run in browser context — return serialisable data
  return Array.from(document.querySelectorAll('h2')).map(el => el.textContent.trim());
});

console.log(JSON.stringify(data, null, 2));

Read the full file on GitHub · 238 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 238 lines · 145 tokens per session scan A de51fc2d37df

Subscribe to this mod's changes

playwright-cli is a command published in the GitHub repository fwornle/coding (2 stars, last pushed yesterday), licensed MIT. It adds 145 tokens to every session and 1,881 once invoked, about $0.0007 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.