Skip to content

What Is Playwright CLI? Letting an Agent Use the Browser, Setup, MCP Differences and Security

You install Playwright CLI with two commands (`npm install -g @playwright/cli@latest`, `playwright-cli install --skills`); your coding agent then drives the browser from the command line: it opens pages, clicks, fills forms, and takes screenshots and PDFs. It is Microsoft's open-source tool under the Apache-2.0 license; the README's first line says "Playwright CLI with SKILLS". It needs Node.js 18+, with no account and no fee. The README describes the CLI as token-efficient compared with Playwright MCP but gives no measurements. The profile lives only in memory by default; if you connect to a running Chrome with the `attach` command, the sessions open there become available to the agent.

What it does
Lets a coding agent use the browser from the command line
Type
Command-line tool + skill (npm package)
Where
Claude Code, GitHub Copilot and other coding agents
Requirement
Node.js 18+
Risk
Runs code on the page; can connect to an open Chrome
Turkish
Not stated in the official sources
Price
Free (Apache-2.0); no account or key

What does Playwright CLI do?

While testing a web app, your coding agent drives the browser with commands: it opens a page with open, gets a short summary of the page state with snapshot, interacts with commands such as click, fill and type, and produces output with screenshot and pdf. After every command a summary of the page state is written to a file; the agent reads this summary instead of loading a long page tree into the model.

Other jobs: recording a flow you do by hand and turning it into Playwright test code, generating an element's locator, mocking network requests, managing cookies and storage, recording traces and video, and connecting to a running browser. For the full command list, run playwright-cli --help.

Who it's for: people building web apps who want the agent to test the interface it builds. The README recommends Playwright MCP for autonomous loops that need persistent state and rich inspection, and recommends the CLI for coding agents.

How do you install Playwright CLI?

You need Node.js 18 or later and a coding agent such as Claude Code or GitHub Copilot. The commands are taken verbatim from the README.

1. Install the tool› npm install -g @playwright/cli@latest
2. Check that it's installed› playwright-cli --help
3. Install the skills (the agent learns the commands)› playwright-cli install --skills

If you don't want to install the skills, it's enough to tell the agent: "Check playwright-cli --help for available commands." The agent learns the commands from the help output. To try it out, the README gives this command:

First try (visible window)› playwright-cli open https://demo.playwright.dev/todomvc/ --headed

The README doesn't list which agent folders the skill install writes to; check your agent's skills folder after installing. "VS Code" on the atlas card isn't in the README; the names VS Code, Cursor, Codex and Kiro appear only in a pull request (PR #465); check the README to see whether the released version includes them.

If Playwright is installed locally and there's no global command, the README says to use npx playwright cli for every command.

How do you use Playwright CLI?

The real user is the agent: you tell it what to test, and the agent runs the commands.

Test a flow"Use playwright-cli to open http://localhost:3000, fill in the signup form with an invalid email, verify that the error message appears and take a screenshot."
Turn it into a test"Use playwright-cli to record the login flow and turn it into a Playwright test."
Close the sessions› playwright-cli close-all

To see the window, use open ... --headed; to watch all sessions in a visual dashboard and step in, use playwright-cli show. A headless session closes on its own after an hour without commands (change it with --idle-timeout=<ms>; 0 never closes).

Which agents does Playwright CLI work with?

Claude CodeYesThe README names it in the requirements and says it will use local skills.
GitHub CopilotYesNamed in the same sentence; it doesn't say which surface (VS Code, CLI).
Other coding agentsPartlyUse without skills: point the agent to the CLI and have it read the --help output.
VS Code, Cursor, Codex, KiroUnclearNot in the README; mentioned only in a pull request description.

What does Playwright CLI access, and what are the risks?

Reads

The accessibility snapshot of opened pages, console messages, network requests, cookies, localStorage and sessionStorage.

Does

Clicks, types, fills forms and uploads files on the page; runs code on the page with eval and run-code; writes cookies and storage; modifies network requests; saves snapshots, screenshots, PDFs, traces and video to disk (the .playwright-cli folder).

Deletion

There are commands to clear cookies, localStorage and sessionStorage, plus delete-data, which deletes browser data. The README has no command that deletes user files.

Profile

The profile lives only in memory by default: cookies and storage stay within the session and are gone when the browser closes. --persistent writes the profile to disk.

If you connect to a running Chrome or Edge with attach --cdp=... or attach --extension=chrome, the sessions open in that browser become available to the agent; this isn't the default but a deliberate command. The README also states plainly that allowed and blocked origin lists are not a security boundary and don't affect redirects. The state-save and cookie commands can write login credentials to disk. The names and results of experimental WebMCP tools registered by the page are treated as untrusted input.

Telemetry: the README doesn't mention data collection. However, according to the source code, unless the CI or NO_UPDATE_NOTIFIER environment variable is set, it sends a version check to the npm registry (registry.npmjs.org) once a day. This behavior is the subject of an open issue (#478). Because page content goes to the agent, it also goes to the agent's provider. There are no entries in GitHub Security Advisories or an OSV scan; this does not mean "safe".

Is Playwright CLI free?

Yes. It's open source under the Apache-2.0 license; it asks for no account, API key or fee. Your coding agent's own subscription or API cost is separate. The README shows the version in the 0.1.x series and makes no stability commitment; a new release comes out roughly every two weeks.

Allowed
  • Apache-2.0: free to use, modify and use in commercial work
Not allowed
  • The README has no concept of organization or admin permission

Source: README, package.json and the npm registry. This is not legal advice.

Common problems and fixes

What happensWhat to do
The headless browser closes after an hourBy design. Restart with open or use open --idle-timeout=<ms> (0 never closes).
Cookies and login details are gone on the second launchThe profile is in memory by default; use open --persistent or state-save and state-load.
A long session name gives "listen EINVAL" on macOSFixed via issue #474; update the version.
On a corporate network the tool sends requests to registry.npmjs.orgVersion check. It's skipped if NO_UPDATE_NOTIFIER or CI is set. Reported by users Issue #478 is open.
Forgotten headless Chromes pile up in the backgroundplaywright-cli close-all, or kill-all if it hangs. The one-hour idle shutdown reduces this problem (issue #460).

How do you uninstall Playwright CLI?

  1. Close open sessions: playwright-cli close-all (kill-all if it hangs).
  2. Delete profile data: playwright-cli delete-data (for a named session, -s=name delete-data).
  3. Remove the tool: npm uninstall -g @playwright/cli (npm's general command; the README doesn't cover it).

Installed skill files stay in the agent's skills folder; the README describes no removal command, so delete them by hand.

Frequently asked questions

What is the difference between Playwright CLI and Playwright MCP?

The README's own comparison: the CLI is recommended for coding agents because the commands are short and don't load large tool schemas into the model. MCP is considered useful for persistent state, rich inspection and long autonomous loops. The README gives no measurements for the token savings.

Is it free?

Yes. It's open source under the Apache-2.0 license; it asks for no account or key. The agent's own subscription or API cost is separate.

Can the agent get into the accounts in my open Chrome?

Yes, if it connects to a running Chrome or Edge with the attach command; the sessions open in that browser become available to the agent. This isn't the default but a deliberate command. detach ends the connection and the browser stays open.

Does the allowed origins setting protect me?

The README warns plainly: allowed and blocked origin lists are not a security boundary and don't affect redirects.

Can I see the browser window?

It's invisible (headless) by default. open ... --headed opens a window; the show command displays all sessions in a visual dashboard.

Is the release stable?

The version number is 0.1.x; the latest release is 0.1.22 (September 28, 2026), and a new release comes out roughly every two weeks. The README makes no stability commitment.

Related guides

Sources

Not clear in the official sources: Which agent folders the install --skills command writes to · how the browser is downloaded · measurements behind the "token-efficient" claim · support for VS Code, Cursor, Codex and Kiro · a step for removing skills · Turkish support. Each is covered in the relevant section.