| name | playwright-browser |
| description | Browser automation with Playwright. Use for web testing, form filling, file uploads, screenshots. Daemon-based for persistent browser state. |
Playwright Browser Skill
Automate browsers via CLI with a daemon that maintains browser state between commands.
Quick Start (Daemon Required)
npx playwright-skill-daemon --headless false
npx playwright-skill navigate "https://example.com"
npx playwright-skill snapshot
npx playwright-skill click e2
Important: The daemon must be running before using CLI commands. If not running, you'll see a clear error message with instructions.
Core Workflow
Step 1: Start Daemon
npx playwright-skill-daemon --headless false
npx playwright-skill-daemon --headless true
Step 2: Navigate and Snapshot
npx playwright-skill navigate "https://example.com/login"
npx playwright-skill snapshot
Step 3: Interact Using Refs
npx playwright-skill fill e5 "user@example.com"
npx playwright-skill fill e8 "password"
npx playwright-skill click e12
Commands by Category
Navigation
npx playwright-skill navigate <url>
npx playwright-skill back
npx playwright-skill forward
npx playwright-skill reload
Interaction (by ref from snapshot)
npx playwright-skill click <ref>
npx playwright-skill fill <ref> <value>
npx playwright-skill type <ref> <text>
npx playwright-skill select <ref> <val>
npx playwright-skill press <key>
npx playwright-skill hover <ref>
Interaction (by CSS selector)
Use when refs aren't available (e.g., modal elements not in snapshot):
npx playwright-skill click-selector "button[type=submit]"
npx playwright-skill fill-selector "input[name=email]" "user@example.com"
npx playwright-skill upload-selector "input[type=file]" "/path/to/file.csv"
Inspection
npx playwright-skill snapshot
npx playwright-skill screenshot
npx playwright-skill query <selector>
Query Command (Read-Only DOM Inspection)
Use query when snapshot doesn't capture elements (e.g., modals rendered as portals):
npx playwright-skill query "button[type=submit]"
npx playwright-skill query ".modal" --exists
npx playwright-skill query "input[name=csrf]" --attr value
File Upload (Hidden Inputs)
Filament and other frameworks use hidden file inputs. Use upload-selector:
npx playwright-skill click e198
npx playwright-skill upload-selector "input[type=file]" "/path/to/file.csv"
npx playwright-skill click-selector "button[type=submit]:visible"
Auth State
npx playwright-skill auth-save <name>
npx playwright-skill auth-load <name>
npx playwright-skill auth-status
npx playwright-skill auth-clear
Response Format
All commands return JSON:
{
"id": "req-2025-12-22-1",
"command": "navigate",
"success": true,
"action": "Navigated to https://example.com",
"pageState": {
"url": "https://example.com",
"title": "Example",
"authStatus": "authenticated",
"hasErrors": false
},
"cacheRef": {
"id": "cache-abc123",
"available": ["snapshot", "console", "network", "html"]
}
Common Patterns
Login Flow
npx playwright-skill navigate "https://app.example.com/login"
npx playwright-skill snapshot
npx playwright-skill fill e29 "user@example.com"
npx playwright-skill fill e41 "password"
npx playwright-skill click e61
Form with File Upload (Filament/Livewire)
npx playwright-skill navigate "https://app.example.com/customers"
npx playwright-skill click e198
npx playwright-skill upload-selector "input[type=file]" "/path/to/data.csv"
npx playwright-skill query "button[type=submit]"
npx playwright-skill click-selector "button[type=submit]:visible"
When Refs Don't Work (Modals/Overlays)
Modal elements render as portals and may not appear in snapshot. Use selectors:
npx playwright-skill query ".fi-modal button"
npx playwright-skill click-selector "button:has-text('Submit')"
Troubleshooting
| Issue | Solution |
|---|
| "Daemon not running" | Start with npx playwright-skill-daemon --headless false |
| Element ref not found | Take fresh snapshot, page may have changed |
| Modal buttons not in snapshot | Use query + click-selector instead |
| File upload not working | Use upload-selector for hidden inputs |
| Livewire action not firing | Use click-selector (native Playwright click) |
Worktree Detection (Multi-Worktree Projects)
This skill supports projects with multiple git worktrees. It auto-detects which worktree you're in and uses the appropriate configuration.
Initial Setup
On first use, if configuration files don't exist, the agent will prompt you to create them:
./skill/worktrees.json - Maps worktree directories to base URLs and credentials
./skill/.secrets.json - Stores passwords (gitignored, never committed)
Both files are gitignored and project-specific. Example templates are provided:
cp ./skill/worktrees.example.json ./skill/worktrees.json
cp ./skill/secrets.example.json ./skill/.secrets.json
See worktrees.example.json and secrets.example.json for templates.
How It Works
- Detection: The skill reads your current working directory to determine which worktree you're in
- Configuration: Each worktree maps to a
baseUrl, credentials, and tenant settings in ./skill/worktrees.json
- Usage: When you run commands, use the worktree-specific base URL
Example Worktree Configuration
{
"worktrees": {
"my-app": {
"baseUrl": "https://my-app.test",
"branch": "develop",
"description": "Main development",
"auth": {
"defaultUser": "admin@example.com",
"roles": {
"admin": "admin@example.com",
"user": "user@example.com"
}
}
},
"my-app-staging": {
"baseUrl": "https://staging.my-app.test",
"branch": "main",
"description": "Staging environment"
}
}
Detecting Current Worktree
Before running tests, verify which worktree you're in:
pwd
Using Worktree-Specific URLs
Always use the correct base URL for your worktree:
npx playwright-skill navigate "https://my-app.test/dashboard"
npx playwright-skill navigate "https://staging.my-app.test/dashboard"
Credentials Configuration
Usernames are stored in ./skill/worktrees.json. Passwords are stored separately in ./skill/.secrets.json (gitignored):
{
"passwords": {
"admin@example.com": "yourPassword",
"user@example.com": "password"
}
}
Getting Credentials Programmatically
To get the correct credentials for the current worktree:
WORKTREE=$(basename $(pwd))
cat ./skill/worktrees.json | jq ".worktrees[\"$WORKTREE\"]"
cat ./skill/.secrets.json | jq '.passwords'
Multi-Tenant Panel URLs
For multi-tenant apps, panel URLs can include a tenant slug:
{
"tenant": {
"slug": "acme-corp",
"panels": {
"admin": "/admin",
"office": "/office/acme-corp",
"user": "/app/acme-corp"
}
}
}
npx playwright-skill navigate "https://my-app.test/admin"
npx playwright-skill navigate "https://my-app.test/office/acme-corp"
Architecture
┌─────────────────────────────────────────┐
│ CLI Commands │
│ npx playwright-skill <command> │
└─────────────────────────────────────────┘
│
Unix Socket (/tmp/playwright-skill.sock)
│
▼
┌─────────────────────────────────────────┐
│ Daemon │
│ - Owns browser instance │
│ - Maintains page state │
│ - 30 min idle timeout │
└─────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Chromium Browser │
│ - Visible when --headless false │
│ - User can interact directly │
└─────────────────────────────────────────┘
Reference Documentation: