Skip to content

RyanCollinsAI/playwright-personas

Repository files navigation

playwright-personas

Browser automation that stays logged into every account you give it. Built on top of @playwright/cli, with a shell wrapper, a Claude Code Skill, and the one trick that gets you past Google's "this browser may not be secure" wall.

pw-login mygmail https://gmail.com    # one-time login, in real Chrome
pw mygmail open https://gmail.com     # daily use, already signed in

That's the whole API.

The thing nobody tells you about Playwright + Google

Try logging into Gmail from a Playwright browser. Google rejects you:

This browser or app may not be secure.

It's not a CAPTCHA. It's not 2FA. Google detects that the browser is being driven via the Chrome DevTools Protocol and refuses to authenticate. There is no user-agent string, no header, no flag that gets you past it.

pw-login solves this by logging in once in real Chrome (no CDP), saving the profile to disk, then letting Playwright reuse the saved cookies. The login persists forever. You only ever do it once per account.

Full writeup: google-login-bypass.md.

Install (one command)

macOS / Linux:

curl -fsSL https://raw.githubusercontent.com/RyanCollinsAI/playwright-personas/main/install.sh | bash

Windows (PowerShell):

irm https://raw.githubusercontent.com/RyanCollinsAI/playwright-personas/main/install.ps1 | iex

The installer:

  1. Verifies Node.js >= 18 is installed.
  2. Runs npm install -g @playwright/cli.
  3. Downloads Playwright's bundled Chromium.
  4. Clones this repo into ~/.playwright-personas.
  5. Wires pw / pw-login into your shell rc (idempotent — safe to rerun).
  6. Installs the Claude Code Skill into ~/.claude/skills/playwright-personas.

Open a new terminal and you're done.

pw collides with a few password-manager aliases. If which pw shows something other than the wrapper, rename the function in shell/pw.sh to pwa (or anything else) and re-source your rc. The toolkit doesn't depend on the name.

Quickstart

pw-login work-gmail https://mail.google.com
# Real Chrome opens. Sign in by hand, including 2FA. Close the window.

pw work-gmail open https://mail.google.com
# Playwright Chrome opens, already signed in.

pw work-gmail snapshot
# Standard playwright-cli — accessibility tree of the current page.

pw work-gmail click "text=Compose"
pw work-gmail close

pw accounts        # list configured accounts
pw list            # list running sessions
pw close-all       # close all sessions

Every playwright-cli subcommand works after pw <account>. The wrapper just adds -s=<account> --profile=... --browser=chrome for you.

What's in this repo

playwright-personas/
├── shell/
│   ├── pw.sh                # bash + zsh wrapper (macOS, Linux, Git Bash)
│   └── pw.ps1               # PowerShell wrapper (Windows)
├── python/
│   └── pw_helpers.py        # importable helpers for browser-automation scripts
├── claude-skill/
│   ├── SKILL.md             # the skill Claude Code loads
│   └── references/
│       ├── google-login-bypass.md
│       ├── token-discipline.md
│       ├── youtube-studio.md
│       └── instagram.md
├── examples/
│   └── multi-account-dashboard.py
├── install.sh / install.ps1
├── uninstall.sh / uninstall.ps1
└── LICENSE

Use cases

A small sample of what gets easier once your accounts stay logged in:

  • Multi-channel YouTube ops. Drive YouTube Studio for two or three channels in parallel — analytics scrapes, end-screen edits, bulk metadata changes — without re-authing each one. The included youtube-studio.md documents the interstitial trick and the Polymer-input rule that breaks most Studio automation.
  • Cross-platform posting. One script logs into Instagram, TikTok, and X via three separate pw profiles and posts the same content. See instagram.md for the obfuscated-DOM workaround.
  • Personal dashboards. Aggregate balances, stats, or notifications from five different accounts into one local HTML page. The examples/multi-account-dashboard.py script is a 50-line starting point.
  • Claude Code as your browser. With the bundled Skill installed, Claude knows about pw, the Google bypass, and the token-discipline rules. Ask it to "open my work Gmail and summarize unread emails" and it picks the right commands without you teaching it the wrapper.

Claude Code Skill

The Skill at claude-skill/SKILL.md is installed to ~/.claude/skills/playwright-personas/ by the installer. Claude Code auto-loads skills from that directory; nothing else to wire up.

Test it:

# Open Claude Code in any project, ask:
"Open https://example.com using playwright-personas and screenshot it."

If Claude runs playwright-cli commands instead of asking you to install something, the Skill is loaded.

Token discipline

A full snapshot of a modern web app is tens of thousands of tokens. If you're paying per token (Claude Code is), undisciplined browser use is the most expensive thing you can do.

See token-discipline.md for the full rules. The summary:

  1. Prefer stable CSS / text= selectors over snapshot-then-eNN refs.
  2. eval for values, snapshot --depth=4 "#area" for exploring.
  3. Grep snapshot files; never Read them.
  4. Batch multi-step flows into one run-code call.
  5. Two failures of the same action means stop and debug.

Uninstall

~/.playwright-personas/uninstall.sh        # macOS / Linux / Git Bash
& "$HOME\.playwright-personas\uninstall.ps1"   # Windows

Removes the shell wrapper, the Claude Code skill, and the cloned repo. Leaves your account profiles intact at ~/.playwright-profiles/ — those hold your real logins. Delete them manually if you want a clean slate.

License

MIT. See LICENSE.

Author

Ryan Collins. This toolkit is the layer I built on top of @playwright/cli to drive my own YouTube channels and accounts from Claude Code. The free version of the AI Skills Lab community (skool.com/ai-skills-society-7281) has a video walkthrough and a few longer-form recipes.

Issues and PRs welcome.

About

Multi-account browser automation toolkit on top of @playwright/cli — persistent logins, Google CDP-block bypass, and a Claude Code Skill. One-line install for macOS, Linux, Windows.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors