playwright-login-sessionlisted
Install: claude install-skill baronguyen001/ai-automation-skills
# Playwright Login Session
Use this skill when a scraper or automation needs to be signed in and logging in every run is slow, brittle, or triggers bot defenses. Capture the session once (cookies + localStorage) into a `storage_state` JSON file, then load it on later headless runs so they start authenticated. The state file stays machine-local and gitignored.
## When to invoke
- User says: "reuse my logged-in session", "skip the login step each run", "save the browser cookies", "keep the scraper authenticated".
- Code in the conversation re-enters credentials with Playwright on every run.
## When NOT to invoke
- The site offers an API token or official API - use that instead of driving a browser.
- Logging in headlessly violates the site's terms, or the account is shared/sensitive enough that storing session state is unsafe.
## Concrete example
User input:
```text
My dashboard scraper logs in every time and keeps getting challenged. Reuse the session.
```
Output:
```bash
# one-time: open a real browser, log in by hand, save the session
python assets/session.py capture https://app.example.com/login # -> auth_state.json (gitignored)
# every run after: starts already signed in, headless
python assets/session.py reuse https://app.example.com/dashboard
```
## Pattern to apply
1. Capture once with a visible browser and a manual login; save with `context.storage_state(path=...)`.
2. Point `PW_STATE` at the state file and load it via `new_context(storage_state=...)` on