Sign In
P

Playwright CLI

@microsoft
Visit Skill
Share:

Microsoft's playwright-cli skill: an AI agent drives a real browser with short shell commands to test pages, mock requests and write Playwright tests.

Security Reviewed

Instruction-only skill for Microsoft's playwright-cli; it can open any site, run page JavaScript and save your browser session to disk, but needs no API key.

Install Playwright CLI in Google Antigravity

Antigravity loads skills from .agents/skills/ in your project or ~/.gemini/config/skills/ for all projects (official docs). Full guide

EasiestOption 1: paste this to your Antigravity agent
Install the "Playwright CLI" skill for Google Antigravity.
Follow the steps at https://www.antigravityskills.org/install/playwright-cli.md (source: https://github.com/microsoft/playwright-cli/tree/main/skills/playwright-cli).
Before running anything, show me what you will download and whether it includes scripts, and wait for my OK.
Install it into this project (.agents/skills/) unless I say global. When done, check that Antigravity lists it as an installed skill.

The agent reads the install file, shows you what it will download and waits for your OK.

Option 2: install it yourself
  1. 1. Install the CLI
    npm install -g @playwright/cli@latest && playwright-cli --help

    README, Installation. Node.js 18 or newer.

  2. 2. Install the skill into this workspace with the CLI
    playwright-cli install --skills=agents

    Run from your project root. Writes the skill bundled with your CLI version to .agents/skills/playwright-cli/, Antigravity's workspace folder. The README only shows --skills (which writes .claude/skills/); the =agents form and its target come from the CLI's skillCheck.js at b1a5903 (unchanged since b85c7a7). Static review: we did not run it.

  3. 3. Or copy the folder from GitHub (project)
    git clone --depth 1 https://github.com/microsoft/playwright-cli /tmp/playwright-cli && mkdir -p .agents/skills && cp -r /tmp/playwright-cli/skills/playwright-cli .agents/skills/

    Use this instead of the previous step if you prefer a plain copy. Antigravity reads workspace skills from <project>/.agents/skills/<folder>/.

  4. 4. Or install globally (all projects)
    mkdir -p ~/.gemini/config/skills && cp -r /tmp/playwright-cli/skills/playwright-cli ~/.gemini/config/skills/

    After the clone above. Global skills folder from Antigravity's docs (antigravity.google/docs/skills).

  5. 5. Check that Antigravity sees it

    Antigravity 2.0 app: start a new conversation and ask "What skills do you have?" (the app has no /skills command; typing / and the skill name also finds it, sometimes only after your first message). Antigravity CLI: run /skills; in a session that was already open, run /skills reload first. playwright-cli should be listed.

The playwright-cli README does not mention Antigravity. If you copy from GitHub, the CLI may later print a notice that the skill at .agents/skills/playwright-cli does not match the tool version; run playwright-cli install --skills=agents to replace it with the bundled copy.

Using Claude Code, Cursor or Codex? See other assistants below.

What is Playwright CLI?

playwright-cli is Microsoft's command-line front end to Playwright, and its repository ships an agent skill that teaches coding agents to drive a real browser through short shell commands: open a page, read a compact snapshot with element refs such as e15, click, fill, take screenshots, mock requests, record video or traces, and turn a session into Playwright tests. It is for developers who want an agent to test or inspect web pages; the README prefers this CLI-plus-skill route over Playwright MCP because it avoids loading large tool schemas and accessibility trees into the model's context. What we counted at commit b85c7a7 (2026-10-19, HEAD on 2026-10-23; the skills folder, package.json and README are identical to b85c7a7 of 2026-09-28): the skill folder has 11 files, SKILL.md (489 lines, 15,428 bytes) plus 10 reference guides, 2,233 lines and 68,749 bytes in total; SKILL.md shows 88 distinct playwright-cli commands in 11 command groups. The npm package @playwright/cli is version 0.1.22, needs Node.js 18 or newer, and depends on playwright and playwright-core 1.64.0 alpha builds.

How to use Playwright CLI?

Install the CLI with npm install -g @playwright/cli@latest, then install the skill from the CLI (playwright-cli install --skills for .claude/skills/, or --skills=agents for .agents/skills/) or copy the folder from GitHub. Then ask for browser work in plain words. The agent opens a browser (headless by default, --headed to watch), reads the snapshot printed after each command, acts on element refs, and saves screenshots, PDFs, traces or videos when asked. Named sessions (-s=<name>) keep several browsers apart; playwright-cli list and close-all clean up.

Key features of Playwright CLI

  • ✓88 commands in SKILL.md across 11 groups: core, navigation, keyboard, mouse, save as, tabs, storage, emulation, network, DevTools and WebMCP
  • ✓Compact snapshots with element refs (e15) instead of full accessibility trees
  • ✓Cookies, localStorage, sessionStorage and saved storage state (state-save / state-load)
  • ✓Request mocking (route, unroute), console and network inspection, tracing and video recording with chapters
  • ✓Chrome, Firefox, WebKit or Edge, device emulation (--mobile, --device), or attach to a running Chrome/Edge via CDP or the Playwright extension
  • ✓10 reference guides, including test generation, request mocking, storage state, tracing, video recording and PR attachments

When to use Playwright CLI

  1. 1Having an agent test a web app flow and screenshot each result
  2. 2Generating Playwright test code from recorded actions
  3. 3Mocking an API response while checking a UI
  4. 4Saving a logged-in state once and reusing it across runs

Installation & Setup Guide

Agent Rules / Prompt Setup

Follow these steps (taken from the project's own docs) to configure Playwright CLI in your development environment.

Step 1: Install the CLIAny
npm install -g @playwright/cli@latest

Documented in the README; check with playwright-cli --help.

Step 2: Claude Code: install the skillClaude Code
playwright-cli install --skills

The README says Claude Code, GitHub Copilot and others use the locally installed skills. Per the CLI's skillCheck.js this writes .claude/skills/playwright-cli/ in the current folder.

Step 3: Cursor: not documentedCursor

The README gives no Cursor install, so we do not list one.

Usage Example & Verification

Prompt / Request Example
1) README example (Demo): "Use playwright skills to test https://demo.playwright.dev/todomvc/. Take screenshots for all successful and failing scenarios."
-> What happens: the agent runs playwright-cli open, types todo items and presses Enter, checks the snapshot after each step, and saves a screenshot per scenario. The browser is headless unless you ask for --headed.

2) README example (Skills-less operation): "Test the 'add todo' flow on https://demo.playwright.dev/todomvc using playwright-cli. Check playwright-cli --help for available commands."
-> What happens: the same task without the skill installed; the README says the agent learns the commands from --help. Useful to compare how much the skill helps.

3) Our example: "Log in to my staging site once, save the session to auth.json, then check the settings page with it."
-> What happens: open with --headed so you can log in, state-save auth.json, later state-load auth.json and goto the settings page. references/storage-state.md says never to commit such files: they hold your cookies and tokens.
Installation Confirmation Method

In Antigravity: Antigravity 2.0 app: start a new conversation and ask "What skills do you have?" (the app has no /skills command; typing / and the skill name also finds it, sometimes only after your first message). Antigravity CLI: run /skills; in a session that was already open, run /skills reload first. playwright-cli should be listed. Then ask "use playwright-cli to open https://demo.playwright.dev/todomvc/ and add a todo called Test"; the agent should run playwright-cli commands and report the snapshot.

Security Review

Static review
Reviewed Date
2026-10-23
Audited Ref / Commit
b1a5903c5b633b8c9f843ad7b629c2a78437040c
Reviewer
antigravityskills.org (static code review)

Instruction-only skill for Microsoft's playwright-cli; it can open any site, run page JavaScript and save your browser session to disk, but needs no API key.

Full review: scope, findings, risks
Audit Scope:Static review of microsoft/playwright-cli at commit b1a5903 (2026-10-19, HEAD on 2026-10-23; diff against b85c7a7 touches only playwright-cli.js, tests and two CI files): skills/playwright-cli/SKILL.md and all 10 references/ files (running-code.md, storage-state.md and session-management.md read in detail), README.md, package.json, playwright-cli.js, skillCheck.js, scripts/update.js, LICENSE. The playwright-core package the CLI loads was not reviewed.
Key Findings:Instruction-only skill (11 Markdown files, no scripts) with allowed-tools limited to Bash(playwright-cli:*), Bash(npx playwright:*) and Bash(npx --no-install playwright:*). The commands load arbitrary URLs, run page JavaScript, upload local files and write screenshots, PDFs, videos, traces and storage-state files. No API keys. The CLI wrapper runs npm view @playwright/cli version through a shell for an update notice (at most once a day, only on open, attach, list, install and install-browser) and compares the installed SKILL.md in .claude/skills and .agents/skills with its bundled copy.
Identified Operational Risks & Permissions:An agent browsing untrusted pages; saved storage state (cookies, tokens) on disk; --persistent profiles on disk; attach --cdp=chrome connects to your running browser with its logged-in sessions; file uploads from local paths. Static review only: we did not run the CLI.

Static review at commit b1a5903. skills/playwright-cli/SKILL.md declares allowed-tools: Bash(playwright-cli:*) Bash(npx playwright:*) Bash(npx --no-install playwright:*), and the folder has only Markdown files. Documented commands open any URL, run JavaScript in the page with eval and run-code (references/running-code.md: isolated context, no require or process, but fetch, timers and crypto are available), and upload local files. state-save writes cookies and storage to a JSON file; references/storage-state.md says never to commit it. attach --cdp=chrome or --extension=chrome connects to a browser you already use. SKILL.md tells the agent to treat WebMCP tool names, schemas and results from a page as untrusted input. playwright-cli.js, the CLI entry point, spawns npm view @playwright/cli version --json through a shell (1.5 s timeout) at most once a day, only for the open, attach, list, install and install-browser commands (skipped with NO_UPDATE_NOTIFIER or CI); at b85c7a7 it fetched https://registry.npmjs.org/@playwright/cli/latest directly instead and caches the check in Playwright's registry folder; skillCheck.js only reads SKILL.md files and prints a notice when they differ from the bundled copy. No environment variables or API keys are required; PLAYWRIGHT_CLI_SESSION optionally names a session.

Operational Notes & Known Limitations

Known Limitations

  • •Needs Node.js 18 or newer and the @playwright/cli package; the skill only teaches the commands
  • •Headless by default; a headless session closes after an hour without commands (references/session-management.md)
  • •The browser profile is in memory unless you pass --persistent or --profile; persistent profiles and state-save files keep cookies on disk
  • •run-code runs in an isolated context without require, process or Node modules, but fetch is available (references/running-code.md)
  • •On Windows, URLs with & must be escaped (^& in cmd.exe, --% in PowerShell), per SKILL.md
  • •The README names Claude Code and GitHub Copilot, not Antigravity or Cursor
  • •At b1a5903 the CLI asks npm for the latest version (it runs npm view @playwright/cli version through a shell, 1.5 s timeout) at most once a day and only on open, attach, list, install and install-browser, unless NO_UPDATE_NOTIFIER or CI is set (playwright-cli.js)

Frequently Asked Questions

Is the playwright-cli skill safe?

The skill is 11 Markdown files with no scripts. The CLI it drives opens any URL, runs JavaScript in pages (eval, run-code), can upload local files and saves cookies with state-save. WebMCP tools offered by a page are untrusted input, as SKILL.md itself says. No API key is needed.

How do I install playwright-cli in Antigravity?

npm install -g @playwright/cli@latest, then run playwright-cli install --skills=agents in your project (writes .agents/skills/playwright-cli/), or copy skills/playwright-cli from GitHub there. Then ask "What skills do you have?" (Antigravity CLI: /skills).

Is this the same as Playwright MCP?

No. The README says coding agents increasingly prefer CLI commands plus skills over MCP because they avoid loading large tool schemas and accessibility trees into context; playwright-cli prints short snapshots with element refs instead.

Should I copy the skill from GitHub or use install --skills?

install --skills copies the SKILL.md bundled in your installed playwright-core, so it matches your CLI version. The GitHub folder is regenerated from that bundle by scripts/update.js and can be ahead of or behind your CLI.

Supported Platforms

antigravityclaudecodex