Streams full accessibility trees and console output into context
Uses structured snapshots—no screenshots needed for interaction
Works great for sandboxed environments (Claude Desktop, chat interfaces)
But… there's a catch
The MCP Token Tax
~114K
Tokens per task (MCP)
26
Tool schemas in context
1000s
Tokens per navigation
Every browser_navigate returns the full accessibility tree
All 26 tool schemas loaded at startup—always consuming context
Long sessions → context degradation → confused reasoning
"MCP sends the whole library. What if we just sent the page number?"
The Solution: Playwright CLI
A fundamentally different architecture.
CLI-first, disk-based architecture
Instead of streaming data into the model—save it to disk
Return only file paths and minimal confirmations
50+ commands available without context overhead
Installed as a Skill—no schema bloat
~27K
Tokens per task (CLI)
4x
Fewer tokens than MCP
The agent gets a toolbelt, not a library.
How Playwright CLI Works
# 1. Open a browser
playwright-cli open https://example.com --headed
# 2. Take a snapshot (saved to disk!)
playwright-cli snapshot
# → .playwright-cli/page-2026-02-12.yml
# 3. Interact using compact element references
playwright-cli fill e8 "Write tests"
playwright-cli press Enter
playwright-cli check e21
# 4. Verify with a screenshot
playwright-cli screenshot
# → .playwright-cli/screenshot-2026-02-12.png
Element references like e8, e21 are compact identifiers—no verbose CSS selectors needed!
The Snapshot System
The secret sauce behind token efficiency.
How it works
playwright-cli snapshot captures page state
Saves a YAML file to .playwright-cli/
Assigns compact refs: e8, e21, e255
Agent reads the file only when needed
Key properties
Deterministic—same page = same refs
Compact—refs, not full selectors
Expiring—page changes = new snapshot
Disk-based—not in context window
↓
State lives on disk. The context stays clean.
CLI + Skills = Perfect Match
# Install skills for your coding agent
playwright-cli install --skills
# This creates:
# .claude/skills/playwright-cli/SKILL.md
What happens
Agent reads SKILL.md to learn commands
Uses Bash tool to execute CLI commands
Reads snapshot files from disk as needed
No MCP server running, no tool proliferation
What doesn't happen
No 26 tool schemas loaded at startup
No accessibility trees in context
No context window bloat over time
No MCP configuration required
Head-to-Head: CLI vs MCP
Aspect
Playwright CLI
Playwright MCP
Token Usage
~27K per task
~114K per task
Data Delivery
Disk (file paths)
Into LLM context
Commands Available
50+
26 tools
Long Sessions
Sustainable
Context degrades
Best For
Coding agents (shell)
Sandboxed envs
Determinism
High
Variable
Setup
npm install -g
MCP config in IDE
Use Case: Automated E2E Testing
An agent explores, tests, and verifies—all in one session.
playwright-cli open https://demo.playwright.dev/todomvc --headed
playwright-cli snapshot
playwright-cli fill e8 "Write tests"
playwright-cli press Enter
playwright-cli check e21
playwright-cli screenshot
What the agent can do in one session:Explore the app → Identify bugs → Write test code → Run the tests → Verify fixes—all without context overflow.
Use Case: UI Review in the Agent Loop
Low token cost makes iterative visual review practical.
%%{init: {'theme': 'dark'}}%%
flowchart TD
A["1. Agent edits React component"] --> B["2. Starts dev server"]
B --> C["3. Opens browser via CLI"]
C --> D["4. Takes screenshot"]
D --> E{"5. Looks correct?"}
E -- No --> A
E -- Yes --> F["6. Commits changes"]
Why this works with CLI
Each loop iteration costs minimal tokens
Agent can iterate 5-10 times without context pressure
Screenshots saved to disk for comparison
Snapshots let agent verify structure + visuals
With MCP, each iteration floods context. With CLI, iterations are nearly free.
Use Case: Multi-Session Testing
Test cross-role interactions with named sessions.
# Launch parallel sessions for different roles
playwright-cli -s=admin open https://app.com/admin
playwright-cli -s=user open https://app.com/dashboard
# Admin creates a resource
playwright-cli -s=admin snapshot
playwright-cli -s=admin click e15
# User verifies it appears
playwright-cli -s=user snapshot
playwright-cli -s=user click e8
Real-world scenario: Test that when an admin publishes a post, a regular user can see it—using two independent browser sessions controlled by the same agent.