npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

patchwright-cli

v1.59.3

Published

Patchwright CLI - Playwright CLI powered by Patchright

Readme

patchwright-cli

A fork of Microsoft's official playwright-cli with the Playwright core replaced by Patchright — an undetected version of Playwright. All CLI features and skills remain the same, but the underlying browser automation engine uses Patchright to avoid bot detection.

Playwright CLI with SKILLS

Playwright CLI vs Playwright MCP

This package provides CLI interface into Playwright. If you are using coding agents, that is the best fit.

  • CLI: Modern coding agents increasingly favor CLI–based workflows exposed as SKILLs over MCP because CLI invocations are more token-efficient: they avoid loading large tool schemas and verbose accessibility trees into the model context, allowing agents to act through concise, purpose-built commands. This makes CLI + SKILLs better suited for high-throughput coding agents that must balance browser automation with large codebases, tests, and reasoning within limited context windows.

  • MCP: MCP remains relevant for specialized agentic loops that benefit from persistent state, rich introspection, and iterative reasoning over page structure, such as exploratory automation, self-healing tests, or long-running autonomous workflows where maintaining continuous browser context outweighs token cost concerns. Learn more about Playwright MCP.

Key Features

  • Token-efficient. Does not force page data into LLM.

Requirements

  • Node.js 18 or newer
  • Claude Code, GitHub Copilot, or any other coding agent.

Getting Started

Installation

npm install -g patchwright-cli@latest
patchwright-cli --help

Installing skills

Claude Code, GitHub Copilot and others will use the locally installed skills.

patchwright-cli install --skills

Skills-less operation

Point your agent at the CLI and let it cook. It'll read the skill off patchwright-cli --help on its own:

Test the "add todo" flow on https://demo.playwright.dev/todomvc using patchwright-cli.
Check patchwright-cli --help for available commands.

Demo

> Use playwright skills to test https://demo.playwright.dev/todomvc/.
  Take screenshots for all successful and failing scenarios.

Your agent will be running commands, but it does not mean you can't play with it manually:

patchwright-cli open https://demo.playwright.dev/todomvc/ --headed
patchwright-cli type "Buy groceries"
patchwright-cli press Enter
patchwright-cli type "Water flowers"
patchwright-cli press Enter
patchwright-cli check e21
patchwright-cli check e35
patchwright-cli screenshot

Headed operation

Playwright CLI is headless by default. If you'd like to see the browser, pass --headed to open:

patchwright-cli open https://playwright.dev --headed

Sessions

Playwright CLI keeps the browser profile in memory by default. Your cookies and storage state are preserved between CLI calls within the session, but lost when the browser closes. Use --persistent to save the profile to disk for persistence across browser restarts.

You can use different instances of the browser for different projects with sessions. Pass -s= to the invocation to talk to a specific browser.

patchwright-cli open https://playwright.dev
patchwright-cli -s=example open https://example.com --persistent
patchwright-cli list

You can run your coding agent with the PLAYWRIGHT_CLI_SESSION environment variable:

PLAYWRIGHT_CLI_SESSION=todo-app claude .

Or instruct it to prepend -s= to the calls.

Manage your sessions as follows:

patchwright-cli list                     # list all sessions
patchwright-cli close-all                # close all browsers
patchwright-cli kill-all                 # forcefully kill all browser processes

Monitoring

Use patchwright-cli show to open a visual dashboard that lets you see and control all running browser sessions. This is useful when your coding agents are running browser automation in the background and you want to observe their progress or step in to help.

patchwright-cli show

The dashboard opens a window with two views:

  • Session grid — shows all active sessions grouped by workspace, each with a live screencast preview, session name, current URL, and page title. Click any session to zoom in.
  • Session detail — shows a live view of the selected session with a tab bar, navigation controls (back, forward, reload, address bar), and full remote control. Click into the viewport to take over mouse and keyboard input; press Escape to release.

From the grid you can also close running sessions or delete data for inactive ones.

Commands

Core

patchwright-cli open [url]               # open browser, optionally navigate to url
patchwright-cli goto <url>               # navigate to a url
patchwright-cli close                    # close the page
patchwright-cli type <text>              # type text into editable element
patchwright-cli click <ref> [button]     # perform click on a web page
patchwright-cli dblclick <ref> [button]  # perform double click on a web page
patchwright-cli fill <ref> <text>        # fill text into editable element
patchwright-cli fill <ref> <text> --submit # fill and press Enter
patchwright-cli drag <startRef> <endRef> # perform drag and drop between two elements
patchwright-cli hover <ref>              # hover over element on page
patchwright-cli select <ref> <val>       # select an option in a dropdown
patchwright-cli upload <file>            # upload one or multiple files
patchwright-cli check <ref>              # check a checkbox or radio button
patchwright-cli uncheck <ref>            # uncheck a checkbox or radio button
patchwright-cli snapshot                 # capture page snapshot to obtain element ref
patchwright-cli snapshot --filename=f    # save snapshot to specific file
patchwright-cli snapshot <ref>           # snapshot a specific element
patchwright-cli snapshot --depth=N       # limit snapshot depth for efficiency
patchwright-cli eval <func> [ref]        # evaluate javascript expression on page or element
patchwright-cli dialog-accept [prompt]   # accept a dialog
patchwright-cli dialog-dismiss           # dismiss a dialog
patchwright-cli resize <w> <h>           # resize the browser window

Navigation

patchwright-cli go-back                  # go back to the previous page
patchwright-cli go-forward               # go forward to the next page
patchwright-cli reload                   # reload the current page

Keyboard

patchwright-cli press <key>              # press a key on the keyboard, `a`, `arrowleft`
patchwright-cli keydown <key>            # press a key down on the keyboard
patchwright-cli keyup <key>              # press a key up on the keyboard

Mouse

patchwright-cli mousemove <x> <y>        # move mouse to a given position
patchwright-cli mousedown [button]       # press mouse down
patchwright-cli mouseup [button]         # press mouse up
patchwright-cli mousewheel <dx> <dy>     # scroll mouse wheel

Save as

patchwright-cli screenshot [ref]         # screenshot of the current page or element
patchwright-cli screenshot --filename=f  # save screenshot with specific filename
patchwright-cli pdf                      # save page as pdf
patchwright-cli pdf --filename=page.pdf  # save pdf with specific filename

Tabs

patchwright-cli tab-list                 # list all tabs
patchwright-cli tab-new [url]            # create a new tab
patchwright-cli tab-close [index]        # close a browser tab
patchwright-cli tab-select <index>       # select a browser tab

Storage

patchwright-cli state-save [filename]    # save storage state
patchwright-cli state-load <filename>    # load storage state

# Cookies
patchwright-cli cookie-list [--domain]   # list cookies
patchwright-cli cookie-get <name>        # get a cookie
patchwright-cli cookie-set <name> <val>  # set a cookie
patchwright-cli cookie-delete <name>     # delete a cookie
patchwright-cli cookie-clear             # clear all cookies

# LocalStorage
patchwright-cli localstorage-list        # list localStorage entries
patchwright-cli localstorage-get <key>   # get localStorage value
patchwright-cli localstorage-set <k> <v> # set localStorage value
patchwright-cli localstorage-delete <k>  # delete localStorage entry
patchwright-cli localstorage-clear       # clear all localStorage

# SessionStorage
patchwright-cli sessionstorage-list      # list sessionStorage entries
patchwright-cli sessionstorage-get <k>   # get sessionStorage value
patchwright-cli sessionstorage-set <k> <v> # set sessionStorage value
patchwright-cli sessionstorage-delete <k>  # delete sessionStorage entry
patchwright-cli sessionstorage-clear     # clear all sessionStorage

Network

patchwright-cli route <pattern> [opts]   # mock network requests
patchwright-cli route-list               # list active routes
patchwright-cli unroute [pattern]        # remove route(s)

DevTools

patchwright-cli console [min-level]      # list console messages
patchwright-cli network                  # list all network requests since loading the page
patchwright-cli run-code <code>          # run playwright code snippet
patchwright-cli run-code --filename=f    # run playwright code from a file
patchwright-cli tracing-start            # start trace recording
patchwright-cli tracing-stop             # stop trace recording
patchwright-cli video-start [filename]   # start video recording
patchwright-cli video-chapter <title>    # add a chapter marker to the video
patchwright-cli video-stop               # stop video recording

Open parameters

patchwright-cli open --browser=chrome    # use specific browser
patchwright-cli open --extension         # connect via browser extension
patchwright-cli open --persistent        # use persistent profile
patchwright-cli open --profile=<path>    # use custom profile directory
patchwright-cli open --config=file.json  # use config file
patchwright-cli close                    # close the browser
patchwright-cli delete-data              # delete user data for default session

Snapshots

After each command, patchwright-cli provides a snapshot of the current browser state.

> patchwright-cli goto https://example.com
### Page
- Page URL: https://example.com/
- Page Title: Example Domain
### Snapshot
[Snapshot](.patchwright-cli/page-2026-02-14T19-22-42-679Z.yml)

You can also take a snapshot on demand using patchwright-cli snapshot command. All the options below can be combined as needed.

# default - save to a file with timestamp-based name
patchwright-cli snapshot

# save to file, use when snapshot is a part of the workflow result
patchwright-cli snapshot --filename=after-click.yaml

# snapshot an element instead of the whole page
patchwright-cli snapshot "#main"

# limit snapshot depth for efficiency, take a partial snapshot afterwards
patchwright-cli snapshot --depth=4
patchwright-cli snapshot e34

Targeting elements

By default, use refs from the snapshot to interact with page elements.

# get snapshot with refs
patchwright-cli snapshot

# interact using a ref
patchwright-cli click e15

You can also use css selectors or Playwright locators.

# css selector
patchwright-cli click "#main > button.submit"

# role locator
patchwright-cli click "getByRole('button', { name: 'Submit' })"

# test id
patchwright-cli click "getByTestId('submit-button')"

Sessions

patchwright-cli -s=name <cmd>            # run command in named session
patchwright-cli -s=name close            # stop a named browser
patchwright-cli -s=name delete-data      # delete user data for named browser
patchwright-cli list                     # list all sessions
patchwright-cli close-all                # close all browsers
patchwright-cli kill-all                 # forcefully kill all browser processes

Local installation

If global patchwright-cli command is not available, try a local version via npx patchwright-cli:

npx --no-install patchwright-cli --version

When local version is available, use npx patchwright-cli in all commands. Otherwise, install patchwright-cli as a global command:

npm install -g patchwright-cli@latest

Configuration file

The Playwright CLI can be configured using a JSON configuration file. You can specify the configuration file using the --config command line option:

patchwright-cli --config path/to/config.json open example.com

Playwright CLI will load config from .playwright/cli.config.json by default so that you did not need to specify it every time.

{
  /**
   * The browser to use.
   */
  browser?: {
    /**
     * The type of browser to use.
     */
    browserName?: 'chromium' | 'firefox' | 'webkit';

    /**
     * Keep the browser profile in memory, do not save it to disk.
     */
    isolated?: boolean;

    /**
     * Path to a user data directory for browser profile persistence.
     * Temporary directory is created by default.
     */
    userDataDir?: string;

    /**
     * Launch options passed to
     * @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context
     *
     * This is useful for settings options like `channel`, `headless`, `executablePath`, etc.
     */
    launchOptions?: playwright.LaunchOptions;

    /**
     * Context options for the browser context.
     *
     * This is useful for settings options like `viewport`.
     */
    contextOptions?: playwright.BrowserContextOptions;

    /**
     * Chrome DevTools Protocol endpoint to connect to an existing browser instance in case of Chromium family browsers.
     */
    cdpEndpoint?: string;

    /**
     * CDP headers to send with the connect request.
     */
    cdpHeaders?: Record<string, string>;

    /**
     * Timeout in milliseconds for connecting to CDP endpoint. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
     */
    cdpTimeout?: number;

    /**
     * Remote endpoint to connect to an existing Playwright server.
     */
    remoteEndpoint?: string;

    /**
     * Paths to TypeScript files to add as initialization scripts for Playwright page.
     */
    initPage?: string[];

    /**
     * Paths to JavaScript files to add as initialization scripts.
     * The scripts will be evaluated in every page before any of the page's scripts.
     */
    initScript?: string[];
  },

  /**
   * If specified, saves the Playwright video of the session into the output directory.
   */
  saveVideo?: {
    width: number;
    height: number;
  };

  /**
   * The directory to save output files.
   */
  outputDir?: string;

  /**
   * Whether to save snapshots, console messages, network logs and other session logs to a file or to the standard output. Defaults to "stdout".
   */
  outputMode?: 'file' | 'stdout';

  console?: {
    /**
     * The level of console messages to return. Each level includes the messages of more severe levels. Defaults to "info".
     */
    level?: 'error' | 'warning' | 'info' | 'debug';
  },

  network?: {
    /**
     * List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
     */
    allowedOrigins?: string[];

    /**
     * List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
     */
    blockedOrigins?: string[];
  };

  /**
   * Specify the attribute to use for test ids, defaults to "data-testid".
   */
  testIdAttribute?: string;

  timeouts?: {
    /*
     * Configures default action timeout: https://playwright.dev/docs/api/class-page#page-set-default-timeout. Defaults to 5000ms.
     */
    action?: number;

    /*
     * Configures default navigation timeout: https://playwright.dev/docs/api/class-page#page-set-default-navigation-timeout. Defaults to 60000ms.
     */
    navigation?: number;
  };

  /**
   * Whether to allow file uploads from anywhere on the file system.
   * By default (false), file uploads are restricted to paths within the MCP roots only.
   */
  allowUnrestrictedFileAccess?: boolean;

  /**
   * Specify the language to use for code generation.
   */
  codegen?: 'typescript' | 'none';
}

| Environment | |-------------| | PLAYWRIGHT_MCP_ALLOWED_HOSTS comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '*' to disable the host check. | | PLAYWRIGHT_MCP_ALLOWED_ORIGINS semicolon-separated list of TRUSTED origins to allow the browser to request. Default is to allow all. Important: does not serve as a security boundary and does not affect redirects. | | PLAYWRIGHT_MCP_ALLOW_UNRESTRICTED_FILE_ACCESS allow access to files outside of the workspace roots. Also allows unrestricted access to file:// URLs. By default access to file system is restricted to workspace root directories (or cwd if no roots are configured) only, and navigation to file:// URLs is blocked. | | PLAYWRIGHT_MCP_BLOCKED_ORIGINS semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed. Important: does not serve as a security boundary and does not affect redirects. | | PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS block service workers | | PLAYWRIGHT_MCP_BROWSER browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge. | | PLAYWRIGHT_MCP_CAPS comma-separated list of additional capabilities to enable, possible values: vision, pdf. | | PLAYWRIGHT_MCP_CDP_ENDPOINT CDP endpoint to connect to. | | PLAYWRIGHT_MCP_CDP_HEADERS CDP headers to send with the connect request, multiple can be specified. | | PLAYWRIGHT_MCP_CDP_TIMEOUT timeout for the CDP connection. | | PLAYWRIGHT_MCP_CONFIG path to the configuration file. | | PLAYWRIGHT_MCP_CONSOLE_LEVEL level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels. | | PLAYWRIGHT_MCP_DEVICE device to emulate, for example: "iPhone 15" | | PLAYWRIGHT_MCP_EXECUTABLE_PATH path to the browser executable. | | PLAYWRIGHT_MCP_EXTENSION Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed. | | PLAYWRIGHT_MCP_GRANT_PERMISSIONS List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write". | | PLAYWRIGHT_MCP_HEADLESS whether to run browser in headless mode, headless by default. | | PLAYWRIGHT_MCP_IGNORE_HTTPS_ERRORS ignore https errors | | PLAYWRIGHT_MCP_INIT_PAGE path to TypeScript file to evaluate on Playwright page object | | PLAYWRIGHT_MCP_INIT_SCRIPT path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times. | | PLAYWRIGHT_MCP_ISOLATED keep the browser profile in memory, do not save it to disk. | | PLAYWRIGHT_MCP_SANDBOX whether to enable the browser sandbox. | | PLAYWRIGHT_MCP_OUTPUT_DIR path to the directory for output files. | | PLAYWRIGHT_MCP_PROXY_BYPASS comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com" | | PLAYWRIGHT_MCP_PROXY_SERVER specify proxy server, for example "http://myproxy:3128" or "socks5://myproxy:8080" | | PLAYWRIGHT_MCP_SAVE_TRACE Whether to save the Playwright Trace of the session into the output directory. | | PLAYWRIGHT_MCP_SAVE_VIDEO Whether to save the video of the session into the output directory. For example "--save-video=800x600" | | PLAYWRIGHT_MCP_SECRETS_FILE path to a file containing secrets in the dotenv format | | PLAYWRIGHT_MCP_STORAGE_STATE path to the storage state file for isolated sessions. | | PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE specify the attribute to use for test ids, defaults to "data-testid" | | PLAYWRIGHT_MCP_TIMEOUT_ACTION specify action timeout in milliseconds, defaults to 5000ms | | PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION specify navigation timeout in milliseconds, defaults to 60000ms | | PLAYWRIGHT_MCP_USER_AGENT specify user agent string | | PLAYWRIGHT_MCP_USER_DATA_DIR path to the user data directory. If not specified, a temporary directory will be created. | | PLAYWRIGHT_MCP_VIEWPORT_SIZE specify browser viewport size in pixels, for example "1280x720" |

Specific tasks

The installed skill includes detailed reference guides for common tasks:

  • Running and Debugging Playwright tests — run, debug and manage Playwright test suites
  • Request mocking — intercept and mock network requests
  • Running Playwright code — execute arbitrary Playwright scripts
  • Browser session management — manage multiple browser sessions
  • Storage state (cookies, localStorage) — persist and restore browser state
  • Test generation — generate Playwright tests from interactions
  • Tracing — record and inspect execution traces
  • Video recording — capture browser session videos
  • Inspecting element attributes — get element id, class, or any attribute not visible in the snapshot