[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6R292FYCD26EM6XV5PFC2NJ":3,"skill-same:01M6R292FYCD26EM6XV5PFC2NJ":110},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":26,"publishedAt":45,"linkOnly":46,"markdownContent":47,"markdownBody":48,"frontMatter":49,"refName":51,"commitSha":52,"skillDirectory":53,"forksCount":54,"repositoryHtmlUrl":55,"repositoryHomepageUrl":6,"ownerHtmlUrl":56,"ownerBlogUrl":6,"ownerDescription":57,"updatedAt":58,"install":59,"resources":71},"01M6R292FYCD26EM6XV5PFC2NJ","patchwright-cli",null,"Anti-detection browser automation via Patchright. Use instead of playwright-cli when the target site has bot detection (Cloudflare, DataDome, etc.).","hoveychen\u002Fpatchwright-cli","hoveychen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1111905?v=4","01M6R28JE5CD882YZEX5E8R0ZP","Harry C","01M6R28JJK9PFTDR4SMPVTYVQ1",4,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],"cli","patchwright cli","browser automation","automation","playwright","browser","npm","cloudflare","detection","Bash","site","use","npx","anti-detection","via","playwright-cli","when","bot","2026-11-10 10:12:30",false,"---\nname: patchwright-cli\ndescription: Anti-detection browser automation via Patchright. Use instead of playwright-cli when the target site has bot detection (Cloudflare, DataDome, etc.).\nallowed-tools: Bash(patchwright-cli:*) Bash(npx:*) Bash(npm:*)\n---\n\n# Browser Automation with patchwright-cli\n\n## Browser lifecycle — read this before anything else\n\n`patchwright-cli open` does not just run a command. It spawns a **detached background daemon** that owns a full Chrome process tree (~200-650 MB), and that daemon **outlives your shell, your task, and your session**. It has no parent-process watchdog: nothing about *your* lifecycle reclaims it — not finishing the task, not closing the terminal, not the agent session ending. The one automatic backstop is an idle timeout (30 minutes by default, `PATCHWRIGHT_IDLE_TIMEOUT`), after which the browser closes itself. Treat that as damage control, not cleanup: half an hour × several forgotten sessions is still gigabytes, and a wedged daemon can outlive its own timer. (A daemon that *dies* is covered separately: each session runs a watchdog process that closes the abandoned browser within seconds. That protects against crashes, not against you forgetting.) Close explicitly.\n\nLeaked daemons are the single most common failure mode of this tool. They accumulate silently at ~200 MB each until the machine starts swapping.\n\nSo, two rules:\n\n**Start every browser task by taking stock.** This costs one command and, unlike a trailing `close`, it does not depend on your task finishing cleanly:\n\n```bash\npatchwright-cli list --all  # every daemon on the machine; anything unfamiliar is a leak\npatchwright-cli close-all   # clean slate for THIS workspace\n```\n\n`--all` is not optional here. `list` and `close-all` are both scoped to the current workspace, and each git worktree counts as its own workspace — so a bare `list` run from one worktree reports \"(no browsers)\" while daemons leaked from another worktree are still holding hundreds of MB. Use `list --all` to see the truth, and `pgrep -fl cli-daemon` to cross-check. To sweep every workspace at once there is only `kill-all`, which SIGKILLs everything; it works, but it skips cleanup, leaving ~80 MB temp profiles behind in `$TMPDIR\u002Fplaywright_chromiumdev_profile-*` for you to delete manually. Prefer per-workspace `close-all` where you can.\n\n**Reuse the default session.** Do not invent a new `-s=\u003Cname>` per task — every distinct name is a separate daemon and a separate Chrome tree. Omit `-s` entirely unless you genuinely need two browsers alive *at the same time*.\n\nThen close when done (`patchwright-cli close`). But treat that as best-effort: an exploratory task that changes direction, errors out, or gets interrupted will never reach it. The opening `close-all` is what actually bounds the damage.\n\n## When to use patchwright-cli vs playwright-cli\n\nBoth tools share the same CLI interface and commands. The difference is the underlying browser engine:\n\n- **playwright-cli** uses stock Playwright\u002FChromium — suitable for most automation and testing tasks.\n- **patchwright-cli** uses [Patchright](https:\u002F\u002Fgithub.com\u002Fnickstuaw\u002Fpatchright-core), a patched version of Playwright that bypasses common bot detection systems (Cloudflare Turnstile, DataDome, PerimeterX, etc.).\n\n**Use patchwright-cli when:**\n- The target site blocks automated browsers or shows CAPTCHAs\n- You encounter \"Access Denied\", \"Please verify you are human\", or similar bot-detection pages\n- You need to interact with sites protected by WAF\u002Fanti-bot services\n\n**Use playwright-cli when:**\n- The target site has no bot detection\n- You are running Playwright tests or test generation\n- You want the standard, unpatched browser behavior\n\nIf both skills are installed, prefer playwright-cli by default and switch to patchwright-cli only when bot detection is encountered.\n\n## Anti-detection best practices\n\nWhen targeting sites with bot detection, **always use `--headed` mode** (and optionally `--browser=chrome`). The default headless mode exposes `HeadlessChrome` in the User-Agent and lacks real screen\u002Fwindow metrics, which most anti-bot systems trivially detect.\n\n```bash\n# Recommended for bot-protected sites\npatchwright-cli open --headed https:\u002F\u002Fprotected-site.com\n# ... do the work ...\npatchwright-cli close\n\n# Best stealth: headed + system Chrome (real UA, real screen metrics)\npatchwright-cli open --headed --browser=chrome https:\u002F\u002Fprotected-site.com\n# ... do the work ...\npatchwright-cli close\n```\n\nHeadless mode is fine for sites without bot detection or for quick scripting tasks. Note that `--headed` and `--browser=chrome` produce the heaviest daemons — a leaked headed Chrome costs several hundred MB, so the cleanup rules above matter most here.\n\n## Quick start\n\n```bash\n# open new browser (use --headed for bot-protected sites)\npatchwright-cli open --headed\n# navigate to a page\npatchwright-cli goto https:\u002F\u002Fplaywright.dev\n# interact with the page using refs from the snapshot\npatchwright-cli click e15\npatchwright-cli type \"page.click\"\npatchwright-cli press Enter\n# take a screenshot (rarely used, as snapshot is more common)\npatchwright-cli screenshot\n# close the browser\npatchwright-cli close\n```\n\n## Commands\n\n### Core\n\n```bash\npatchwright-cli open\n# open and navigate right away\npatchwright-cli open https:\u002F\u002Fexample.com\u002F\npatchwright-cli goto https:\u002F\u002Fplaywright.dev\npatchwright-cli type \"search query\"\npatchwright-cli click e3\npatchwright-cli dblclick e7\n# --submit presses Enter after filling the element\npatchwright-cli fill e5 \"user@example.com\"  --submit\npatchwright-cli drag e2 e8\npatchwright-cli hover e4\npatchwright-cli select e9 \"option-value\"\npatchwright-cli upload .\u002Fdocument.pdf\npatchwright-cli check e12\npatchwright-cli uncheck e12\npatchwright-cli snapshot\npatchwright-cli eval \"document.title\"\npatchwright-cli eval \"el => el.textContent\" e5\n# get element id, class, or any attribute not visible in the snapshot\npatchwright-cli eval \"el => el.id\" e5\npatchwright-cli eval \"el => el.getAttribute('data-testid')\" e5\npatchwright-cli dialog-accept\npatchwright-cli dialog-accept \"confirmation text\"\npatchwright-cli dialog-dismiss\npatchwright-cli resize 1920 1080\npatchwright-cli close\n```\n\n### Navigation\n\n```bash\npatchwright-cli go-back\npatchwright-cli go-forward\npatchwright-cli reload\n```\n\n### Keyboard\n\n```bash\npatchwright-cli press Enter\npatchwright-cli press ArrowDown\npatchwright-cli keydown Shift\npatchwright-cli keyup Shift\n```\n\n### Mouse\n\n```bash\npatchwright-cli mousemove 150 300\npatchwright-cli mousedown\npatchwright-cli mousedown right\npatchwright-cli mouseup\npatchwright-cli mouseup right\npatchwright-cli mousewheel 0 100\n```\n\n### Save as\n\n```bash\npatchwright-cli screenshot\npatchwright-cli screenshot e5\npatchwright-cli screenshot --filename=page.png\npatchwright-cli pdf --filename=page.pdf\n```\n\n### Tabs\n\n```bash\npatchwright-cli tab-list\npatchwright-cli tab-new\npatchwright-cli tab-new https:\u002F\u002Fexample.com\u002Fpage\npatchwright-cli tab-close\npatchwright-cli tab-close 2\npatchwright-cli tab-select 0\n```\n\n### Storage\n\n```bash\npatchwright-cli state-save\npatchwright-cli state-save auth.json\npatchwright-cli state-load auth.json\n\n# Cookies\npatchwright-cli cookie-list\npatchwright-cli cookie-list --domain=example.com\npatchwright-cli cookie-get session_id\npatchwright-cli cookie-set session_id abc123\npatchwright-cli cookie-set session_id abc123 --domain=example.com --httpOnly --secure\npatchwright-cli cookie-delete session_id\npatchwright-cli cookie-clear\n\n# LocalStorage\npatchwright-cli localstorage-list\npatchwright-cli localstorage-get theme\npatchwright-cli localstorage-set theme dark\npatchwright-cli localstorage-delete theme\npatchwright-cli localstorage-clear\n\n# SessionStorage\npatchwright-cli sessionstorage-list\npatchwright-cli sessionstorage-get step\npatchwright-cli sessionstorage-set step 3\npatchwright-cli sessionstorage-delete step\npatchwright-cli sessionstorage-clear\n```\n\n### Network\n\n```bash\npatchwright-cli route \"**\u002F*.jpg\" --status=404\npatchwright-cli route \"https:\u002F\u002Fapi.example.com\u002F**\" --body='{\"mock\": true}'\npatchwright-cli route-list\npatchwright-cli unroute \"**\u002F*.jpg\"\npatchwright-cli unroute\n```\n\n### DevTools\n\n```bash\npatchwright-cli console\npatchwright-cli console warning\npatchwright-cli network\npatchwright-cli run-code \"async page => await page.context().grantPermissions(['geolocation'])\"\npatchwright-cli run-code --filename=script.js\npatchwright-cli tracing-start\npatchwright-cli tracing-stop\npatchwright-cli video-start video.webm\npatchwright-cli video-chapter \"Chapter Title\" --description=\"Details\" --duration=2000\npatchwright-cli video-stop\n```\n\n## Open parameters\n```bash\n# Use headed mode (recommended for bot-protected sites)\npatchwright-cli open --headed\npatchwright-cli open --headed --browser=chrome\n\n# Use specific browser when creating session\npatchwright-cli open --browser=chrome\npatchwright-cli open --browser=firefox\npatchwright-cli open --browser=webkit\npatchwright-cli open --browser=msedge\n# Connect to browser via extension\npatchwright-cli open --extension\n\n# Use persistent profile (by default profile is in-memory)\npatchwright-cli open --persistent\n# Use persistent profile with custom directory\npatchwright-cli open --profile=\u002Fpath\u002Fto\u002Fprofile\n\n# Start with config file\npatchwright-cli open --config=my-config.json\n\n# Close the browser\npatchwright-cli close\n# Delete user data for the default session\npatchwright-cli delete-data\n```\n\n## Snapshots\n\nAfter each command, patchwright-cli provides a snapshot of the current browser state.\n\n```bash\n> patchwright-cli goto https:\u002F\u002Fexample.com\n### Page\n- Page URL: https:\u002F\u002Fexample.com\u002F\n- Page Title: Example Domain\n### Snapshot\n[Snapshot](.patchwright-cli\u002Fpage-2026-02-14T19-22-42-679Z.yml)\n```\n\nYou can also take a snapshot on demand using `patchwright-cli snapshot` command. All the options below can be combined as needed.\n\n```bash\n# default - save to a file with timestamp-based name\npatchwright-cli snapshot\n\n# save to file, use when snapshot is a part of the workflow result\npatchwright-cli snapshot --filename=after-click.yaml\n\n# snapshot an element instead of the whole page\npatchwright-cli snapshot \"#main\"\n\n# limit snapshot depth for efficiency, take a partial snapshot afterwards\npatchwright-cli snapshot --depth=4\npatchwright-cli snapshot e34\n```\n\n## Targeting elements\n\nBy default, use refs from the snapshot to interact with page elements.\n\n```bash\n# get snapshot with refs\npatchwright-cli snapshot\n\n# interact using a ref\npatchwright-cli click e15\n```\n\nYou can also use css selectors or Playwright locators.\n\n```bash\n# css selector\npatchwright-cli click \"#main > button.submit\"\n\n# role locator\npatchwright-cli click \"getByRole('button', { name: 'Submit' })\"\n\n# test id\npatchwright-cli click \"getByTestId('submit-button')\"\n```\n\n## Browser Sessions\n\n`-s=\u003Cname>` exists for **concurrency** — running two browsers at the same time with separate cookies and storage. It is not a label for what a task is about. Each name is a separate daemon that must be closed separately, so if you do not need two browsers alive simultaneously, omit `-s` and use the default session.\n\n```bash\n# create new browser session named \"mysession\" with persistent profile\npatchwright-cli -s=mysession open example.com --persistent\n# same with manually specified profile directory (use when requested explicitly)\npatchwright-cli -s=mysession open example.com --profile=\u002Fpath\u002Fto\u002Fprofile\npatchwright-cli -s=mysession click e6\npatchwright-cli -s=mysession close  # stop a named browser — required, nothing does it for you\npatchwright-cli -s=mysession delete-data  # delete user data for persistent session\n```\n\nCleanup commands. Mind the scope column — `list` and `close-all` only see the current workspace, and every git worktree is a separate workspace:\n\n```bash\npatchwright-cli list        # THIS workspace only — usually misleading\npatchwright-cli list --all  # every workspace on the machine — use this one\npatchwright-cli close-all   # THIS workspace; graceful, cleans up temp profiles\npatchwright-cli kill-all    # ALL workspaces; SIGKILL, leaves temp profiles behind\n```\n\n## Installation\n\nIf global `patchwright-cli` command is not available, try a local version via `npx patchwright-cli`:\n\n```bash\nnpx --no-install patchwright-cli --version\n```\n\nWhen local version is available, use `npx patchwright-cli` in all commands. Otherwise, install `patchwright-cli` as a global command:\n\n```bash\nnpm install -g patchwright-cli@latest\n```\n\n## Example: Form submission\n\n```bash\npatchwright-cli open https:\u002F\u002Fexample.com\u002Fform\npatchwright-cli snapshot\n\npatchwright-cli fill e1 \"user@example.com\"\npatchwright-cli fill e2 \"password123\"\npatchwright-cli click e3\npatchwright-cli snapshot\npatchwright-cli close\n```\n\n## Example: Multi-tab workflow\n\n```bash\npatchwright-cli open https:\u002F\u002Fexample.com\npatchwright-cli tab-new https:\u002F\u002Fexample.com\u002Fother\npatchwright-cli tab-list\npatchwright-cli tab-select 0\npatchwright-cli snapshot\npatchwright-cli close\n```\n\n## Example: Debugging with DevTools\n\n```bash\npatchwright-cli open https:\u002F\u002Fexample.com\npatchwright-cli click e4\npatchwright-cli fill e7 \"test\"\npatchwright-cli console\npatchwright-cli network\npatchwright-cli close\n```\n\n```bash\npatchwright-cli open https:\u002F\u002Fexample.com\npatchwright-cli tracing-start\npatchwright-cli click e4\npatchwright-cli fill e7 \"test\"\npatchwright-cli tracing-stop\npatchwright-cli close\n```\n\n## Specific tasks\n\n* **Running and Debugging Playwright tests** [references\u002Fplaywright-tests.md](references\u002Fplaywright-tests.md)\n* **Request mocking** [references\u002Frequest-mocking.md](references\u002Frequest-mocking.md)\n* **Running Playwright code** [references\u002Frunning-code.md](references\u002Frunning-code.md)\n* **Browser session management** [references\u002Fsession-management.md](references\u002Fsession-management.md)\n* **Storage state (cookies, localStorage)** [references\u002Fstorage-state.md](references\u002Fstorage-state.md)\n* **Test generation** [references\u002Ftest-generation.md](references\u002Ftest-generation.md)\n* **Tracing** [references\u002Ftracing.md](references\u002Ftracing.md)\n* **Video recording** [references\u002Fvideo-recording.md](references\u002Fvideo-recording.md)\n* **Inspecting element attributes** [references\u002Felement-attributes.md](references\u002Felement-attributes.md)\n","# Browser Automation with patchwright-cli\n\n## Browser lifecycle — read this before anything else\n\n`patchwright-cli open` does not just run a command. It spawns a **detached background daemon** that owns a full Chrome process tree (~200-650 MB), and that daemon **outlives your shell, your task, and your session**. It has no parent-process watchdog: nothing about *your* lifecycle reclaims it — not finishing the task, not closing the terminal, not the agent session ending. The one automatic backstop is an idle timeout (30 minutes by default, `PATCHWRIGHT_IDLE_TIMEOUT`), after which the browser closes itself. Treat that as damage control, not cleanup: half an hour × several forgotten sessions is still gigabytes, and a wedged daemon can outlive its own timer. (A daemon that *dies* is covered separately: each session runs a watchdog process that closes the abandoned browser within seconds. That protects against crashes, not against you forgetting.) Close explicitly.\n\nLeaked daemons are the single most common failure mode of this tool. They accumulate silently at ~200 MB each until the machine starts swapping.\n\nSo, two rules:\n\n**Start every browser task by taking stock.** This costs one command and, unlike a trailing `close`, it does not depend on your task finishing cleanly:\n\n```bash\npatchwright-cli list --all  # every daemon on the machine; anything unfamiliar is a leak\npatchwright-cli close-all   # clean slate for THIS workspace\n```\n\n`--all` is not optional here. `list` and `close-all` are both scoped to the current workspace, and each git worktree counts as its own workspace — so a bare `list` run from one worktree reports \"(no browsers)\" while daemons leaked from another worktree are still holding hundreds of MB. Use `list --all` to see the truth, and `pgrep -fl cli-daemon` to cross-check. To sweep every workspace at once there is only `kill-all`, which SIGKILLs everything; it works, but it skips cleanup, leaving ~80 MB temp profiles behind in `$TMPDIR\u002Fplaywright_chromiumdev_profile-*` for you to delete manually. Prefer per-workspace `close-all` where you can.\n\n**Reuse the default session.** Do not invent a new `-s=\u003Cname>` per task — every distinct name is a separate daemon and a separate Chrome tree. Omit `-s` entirely unless you genuinely need two browsers alive *at the same time*.\n\nThen close when done (`patchwright-cli close`). But treat that as best-effort: an exploratory task that changes direction, errors out, or gets interrupted will never reach it. The opening `close-all` is what actually bounds the damage.\n\n## When to use patchwright-cli vs playwright-cli\n\nBoth tools share the same CLI interface and commands. The difference is the underlying browser engine:\n\n- **playwright-cli** uses stock Playwright\u002FChromium — suitable for most automation and testing tasks.\n- **patchwright-cli** uses [Patchright](https:\u002F\u002Fgithub.com\u002Fnickstuaw\u002Fpatchright-core), a patched version of Playwright that bypasses common bot detection systems (Cloudflare Turnstile, DataDome, PerimeterX, etc.).\n\n**Use patchwright-cli when:**\n- The target site blocks automated browsers or shows CAPTCHAs\n- You encounter \"Access Denied\", \"Please verify you are human\", or similar bot-detection pages\n- You need to interact with sites protected by WAF\u002Fanti-bot services\n\n**Use playwright-cli when:**\n- The target site has no bot detection\n- You are running Playwright tests or test generation\n- You want the standard, unpatched browser behavior\n\nIf both skills are installed, prefer playwright-cli by default and switch to patchwright-cli only when bot detection is encountered.\n\n## Anti-detection best practices\n\nWhen targeting sites with bot detection, **always use `--headed` mode** (and optionally `--browser=chrome`). The default headless mode exposes `HeadlessChrome` in the User-Agent and lacks real screen\u002Fwindow metrics, which most anti-bot systems trivially detect.\n\n```bash\n# Recommended for bot-protected sites\npatchwright-cli open --headed https:\u002F\u002Fprotected-site.com\n# ... do the work ...\npatchwright-cli close\n\n# Best stealth: headed + system Chrome (real UA, real screen metrics)\npatchwright-cli open --headed --browser=chrome https:\u002F\u002Fprotected-site.com\n# ... do the work ...\npatchwright-cli close\n```\n\nHeadless mode is fine for sites without bot detection or for quick scripting tasks. Note that `--headed` and `--browser=chrome` produce the heaviest daemons — a leaked headed Chrome costs several hundred MB, so the cleanup rules above matter most here.\n\n## Quick start\n\n```bash\n# open new browser (use --headed for bot-protected sites)\npatchwright-cli open --headed\n# navigate to a page\npatchwright-cli goto https:\u002F\u002Fplaywright.dev\n# interact with the page using refs from the snapshot\npatchwright-cli click e15\npatchwright-cli type \"page.click\"\npatchwright-cli press Enter\n# take a screenshot (rarely used, as snapshot is more common)\npatchwright-cli screenshot\n# close the browser\npatchwright-cli close\n```\n\n## Commands\n\n### Core\n\n```bash\npatchwright-cli open\n# open and navigate right away\npatchwright-cli open https:\u002F\u002Fexample.com\u002F\npatchwright-cli goto https:\u002F\u002Fplaywright.dev\npatchwright-cli type \"search query\"\npatchwright-cli click e3\npatchwright-cli dblclick e7\n# --submit presses Enter after filling the element\npatchwright-cli fill e5 \"user@example.com\"  --submit\npatchwright-cli drag e2 e8\npatchwright-cli hover e4\npatchwright-cli select e9 \"option-value\"\npatchwright-cli upload .\u002Fdocument.pdf\npatchwright-cli check e12\npatchwright-cli uncheck e12\npatchwright-cli snapshot\npatchwright-cli eval \"document.title\"\npatchwright-cli eval \"el => el.textContent\" e5\n# get element id, class, or any attribute not visible in the snapshot\npatchwright-cli eval \"el => el.id\" e5\npatchwright-cli eval \"el => el.getAttribute('data-testid')\" e5\npatchwright-cli dialog-accept\npatchwright-cli dialog-accept \"confirmation text\"\npatchwright-cli dialog-dismiss\npatchwright-cli resize 1920 1080\npatchwright-cli close\n```\n\n### Navigation\n\n```bash\npatchwright-cli go-back\npatchwright-cli go-forward\npatchwright-cli reload\n```\n\n### Keyboard\n\n```bash\npatchwright-cli press Enter\npatchwright-cli press ArrowDown\npatchwright-cli keydown Shift\npatchwright-cli keyup Shift\n```\n\n### Mouse\n\n```bash\npatchwright-cli mousemove 150 300\npatchwright-cli mousedown\npatchwright-cli mousedown right\npatchwright-cli mouseup\npatchwright-cli mouseup right\npatchwright-cli mousewheel 0 100\n```\n\n### Save as\n\n```bash\npatchwright-cli screenshot\npatchwright-cli screenshot e5\npatchwright-cli screenshot --filename=page.png\npatchwright-cli pdf --filename=page.pdf\n```\n\n### Tabs\n\n```bash\npatchwright-cli tab-list\npatchwright-cli tab-new\npatchwright-cli tab-new https:\u002F\u002Fexample.com\u002Fpage\npatchwright-cli tab-close\npatchwright-cli tab-close 2\npatchwright-cli tab-select 0\n```\n\n### Storage\n\n```bash\npatchwright-cli state-save\npatchwright-cli state-save auth.json\npatchwright-cli state-load auth.json\n\n# Cookies\npatchwright-cli cookie-list\npatchwright-cli cookie-list --domain=example.com\npatchwright-cli cookie-get session_id\npatchwright-cli cookie-set session_id abc123\npatchwright-cli cookie-set session_id abc123 --domain=example.com --httpOnly --secure\npatchwright-cli cookie-delete session_id\npatchwright-cli cookie-clear\n\n# LocalStorage\npatchwright-cli localstorage-list\npatchwright-cli localstorage-get theme\npatchwright-cli localstorage-set theme dark\npatchwright-cli localstorage-delete theme\npatchwright-cli localstorage-clear\n\n# SessionStorage\npatchwright-cli sessionstorage-list\npatchwright-cli sessionstorage-get step\npatchwright-cli sessionstorage-set step 3\npatchwright-cli sessionstorage-delete step\npatchwright-cli sessionstorage-clear\n```\n\n### Network\n\n```bash\npatchwright-cli route \"**\u002F*.jpg\" --status=404\npatchwright-cli route \"https:\u002F\u002Fapi.example.com\u002F**\" --body='{\"mock\": true}'\npatchwright-cli route-list\npatchwright-cli unroute \"**\u002F*.jpg\"\npatchwright-cli unroute\n```\n\n### DevTools\n\n```bash\npatchwright-cli console\npatchwright-cli console warning\npatchwright-cli network\npatchwright-cli run-code \"async page => await page.context().grantPermissions(['geolocation'])\"\npatchwright-cli run-code --filename=script.js\npatchwright-cli tracing-start\npatchwright-cli tracing-stop\npatchwright-cli video-start video.webm\npatchwright-cli video-chapter \"Chapter Title\" --description=\"Details\" --duration=2000\npatchwright-cli video-stop\n```\n\n## Open parameters\n```bash\n# Use headed mode (recommended for bot-protected sites)\npatchwright-cli open --headed\npatchwright-cli open --headed --browser=chrome\n\n# Use specific browser when creating session\npatchwright-cli open --browser=chrome\npatchwright-cli open --browser=firefox\npatchwright-cli open --browser=webkit\npatchwright-cli open --browser=msedge\n# Connect to browser via extension\npatchwright-cli open --extension\n\n# Use persistent profile (by default profile is in-memory)\npatchwright-cli open --persistent\n# Use persistent profile with custom directory\npatchwright-cli open --profile=\u002Fpath\u002Fto\u002Fprofile\n\n# Start with config file\npatchwright-cli open --config=my-config.json\n\n# Close the browser\npatchwright-cli close\n# Delete user data for the default session\npatchwright-cli delete-data\n```\n\n## Snapshots\n\nAfter each command, patchwright-cli provides a snapshot of the current browser state.\n\n```bash\n> patchwright-cli goto https:\u002F\u002Fexample.com\n### Page\n- Page URL: https:\u002F\u002Fexample.com\u002F\n- Page Title: Example Domain\n### Snapshot\n[Snapshot](.patchwright-cli\u002Fpage-2026-02-14T19-22-42-679Z.yml)\n```\n\nYou can also take a snapshot on demand using `patchwright-cli snapshot` command. All the options below can be combined as needed.\n\n```bash\n# default - save to a file with timestamp-based name\npatchwright-cli snapshot\n\n# save to file, use when snapshot is a part of the workflow result\npatchwright-cli snapshot --filename=after-click.yaml\n\n# snapshot an element instead of the whole page\npatchwright-cli snapshot \"#main\"\n\n# limit snapshot depth for efficiency, take a partial snapshot afterwards\npatchwright-cli snapshot --depth=4\npatchwright-cli snapshot e34\n```\n\n## Targeting elements\n\nBy default, use refs from the snapshot to interact with page elements.\n\n```bash\n# get snapshot with refs\npatchwright-cli snapshot\n\n# interact using a ref\npatchwright-cli click e15\n```\n\nYou can also use css selectors or Playwright locators.\n\n```bash\n# css selector\npatchwright-cli click \"#main > button.submit\"\n\n# role locator\npatchwright-cli click \"getByRole('button', { name: 'Submit' })\"\n\n# test id\npatchwright-cli click \"getByTestId('submit-button')\"\n```\n\n## Browser Sessions\n\n`-s=\u003Cname>` exists for **concurrency** — running two browsers at the same time with separate cookies and storage. It is not a label for what a task is about. Each name is a separate daemon that must be closed separately, so if you do not need two browsers alive simultaneously, omit `-s` and use the default session.\n\n```bash\n# create new browser session named \"mysession\" with persistent profile\npatchwright-cli -s=mysession open example.com --persistent\n# same with manually specified profile directory (use when requested explicitly)\npatchwright-cli -s=mysession open example.com --profile=\u002Fpath\u002Fto\u002Fprofile\npatchwright-cli -s=mysession click e6\npatchwright-cli -s=mysession close  # stop a named browser — required, nothing does it for you\npatchwright-cli -s=mysession delete-data  # delete user data for persistent session\n```\n\nCleanup commands. Mind the scope column — `list` and `close-all` only see the current workspace, and every git worktree is a separate workspace:\n\n```bash\npatchwright-cli list        # THIS workspace only — usually misleading\npatchwright-cli list --all  # every workspace on the machine — use this one\npatchwright-cli close-all   # THIS workspace; graceful, cleans up temp profiles\npatchwright-cli kill-all    # ALL workspaces; SIGKILL, leaves temp profiles behind\n```\n\n## Installation\n\nIf global `patchwright-cli` command is not available, try a local version via `npx patchwright-cli`:\n\n```bash\nnpx --no-install patchwright-cli --version\n```\n\nWhen local version is available, use `npx patchwright-cli` in all commands. Otherwise, install `patchwright-cli` as a global command:\n\n```bash\nnpm install -g patchwright-cli@latest\n```\n\n## Example: Form submission\n\n```bash\npatchwright-cli open https:\u002F\u002Fexample.com\u002Fform\npatchwright-cli snapshot\n\npatchwright-cli fill e1 \"user@example.com\"\npatchwright-cli fill e2 \"password123\"\npatchwright-cli click e3\npatchwright-cli snapshot\npatchwright-cli close\n```\n\n## Example: Multi-tab workflow\n\n```bash\npatchwright-cli open https:\u002F\u002Fexample.com\npatchwright-cli tab-new https:\u002F\u002Fexample.com\u002Fother\npatchwright-cli tab-list\npatchwright-cli tab-select 0\npatchwright-cli snapshot\npatchwright-cli close\n```\n\n## Example: Debugging with DevTools\n\n```bash\npatchwright-cli open https:\u002F\u002Fexample.com\npatchwright-cli click e4\npatchwright-cli fill e7 \"test\"\npatchwright-cli console\npatchwright-cli network\npatchwright-cli close\n```\n\n```bash\npatchwright-cli open https:\u002F\u002Fexample.com\npatchwright-cli tracing-start\npatchwright-cli click e4\npatchwright-cli fill e7 \"test\"\npatchwright-cli tracing-stop\npatchwright-cli close\n```\n\n## Specific tasks\n\n* **Running and Debugging Playwright tests** [references\u002Fplaywright-tests.md](references\u002Fplaywright-tests.md)\n* **Request mocking** [references\u002Frequest-mocking.md](references\u002Frequest-mocking.md)\n* **Running Playwright code** [references\u002Frunning-code.md](references\u002Frunning-code.md)\n* **Browser session management** [references\u002Fsession-management.md](references\u002Fsession-management.md)\n* **Storage state (cookies, localStorage)** [references\u002Fstorage-state.md](references\u002Fstorage-state.md)\n* **Test generation** [references\u002Ftest-generation.md](references\u002Ftest-generation.md)\n* **Tracing** [references\u002Ftracing.md](references\u002Ftracing.md)\n* **Video recording** [references\u002Fvideo-recording.md](references\u002Fvideo-recording.md)\n* **Inspecting element attributes** [references\u002Felement-attributes.md](references\u002Felement-attributes.md)\n",{"name":5,"description":7,"allowed-tools":50},"Bash(patchwright-cli:*) Bash(npx:*) Bash(npm:*)","main","74aa8d67e70626171b2946ee3f9b56766786577e","skills\u002Fpatchwright-cli",0,"https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli","https:\u002F\u002Fgithub.com\u002Fhoveychen","Ex-Googler, AI startup","2026-09-09 05:27:41",{"source":8,"skillName":5,"commands":60,"prompt":69,"zipAvailable":70},[61,63,66],{"tool":39,"command":62},"npx skills add hoveychen\u002Fpatchwright-cli --skill patchwright-cli",{"tool":64,"command":65},"bunx","bunx skills add hoveychen\u002Fpatchwright-cli --skill patchwright-cli",{"tool":67,"command":68},"pnpm","pnpm dlx skills add hoveychen\u002Fpatchwright-cli --skill patchwright-cli","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002FSKILL.md",true,[72,78,82,86,90,94,98,102,106],{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Felement-attributes.md","REFERENCE","参考文档",671,"https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002Freferences\u002Felement-attributes.md",{"path":79,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Fplaywright-tests.md",1638,"https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002Freferences\u002Fplaywright-tests.md",{"path":83,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Frequest-mocking.md",2193,"https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002Freferences\u002Frequest-mocking.md",{"path":87,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Frunning-code.md",5426,"https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002Freferences\u002Frunning-code.md",{"path":91,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002Fsession-management.md",7401,"https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002Freferences\u002Fsession-management.md",{"path":95,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":96,"sourceHtmlUrl":97},"references\u002Fstorage-state.md",5239,"https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002Freferences\u002Fstorage-state.md",{"path":99,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":100,"sourceHtmlUrl":101},"references\u002Ftest-generation.md",2421,"https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002Freferences\u002Ftest-generation.md",{"path":103,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":104,"sourceHtmlUrl":105},"references\u002Ftracing.md",3463,"https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002Freferences\u002Ftracing.md",{"path":107,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":108,"sourceHtmlUrl":109},"references\u002Fvideo-recording.md",5393,"https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002Fskills\u002Fpatchwright-cli\u002Freferences\u002Fvideo-recording.md",[111],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":45},"01M6R28N7G5VMPJGWBZ4AGE6Z9","dev","Development workflows for the patchwright-cli repository. Use when the user asks about rolling dependencies, releasing, or other repo maintenance tasks.","https:\u002F\u002Fgithub.com\u002Fhoveychen\u002Fpatchwright-cli\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdev\u002FSKILL.md",[],[113,27,118,119,120,121,122,123,38,124,125,126,127,128,43],"workflows","tasks","development","repository","repo","user","maintenance","dependencies","development workflows","about","for"]