Playwright CLI
Microsoft's browser automation CLI that Claude Code uses to control a real browser — navigating pages, clicking elements, filling forms, taking screenshots, and running headless or headed sessions — without loading an MCP server into context.
Key facts
- Type: Browser automation tool
- Maker: Microsoft (open-source)
- Status: Active
- Language: JavaScript/TypeScript test scripts
- Token advantage: Zero tool-definition tokens loaded at session start (vs Chrome DevTools MCP, which loads its full catalogue)
What it does
Playwright CLI is installed as a project dependency. Claude Code writes and iterates JavaScript scripts that control a browser instance. Each automation task gets its own script file (e.g., qa-test.js, school-likes.js) that improves across runs as Claude learns which selectors work for a given UI.
Key patterns demonstrated by Nate Herk [src-011]:
1. QA testing loop — Claude builds a multi-page web app, writes a Playwright test script, reads bug output, patches code, re-runs — iterating until all tests pass without human input.
2. Scraping with fallback — Claude attempted Google scraping, got blocked, autonomously switched to DuckDuckGo mid-run.
3. Authenticated community bot — logs in once via Chrome user-data profile, then all subsequent runs inherit the active session. Posts daily news roundups, likes content, replies to comments, votes on polls — fully autonomously via Claude Code scheduled tasks.
Related
- See also: Claude Code, Ais Agent Bot
- Compared against: Chrome DevTools MCP, Vercel Agent Browser, Open CLI (choice criteria: token efficiency and selector learning)
- Concepts: Browser Automation With Claude, MCP Vs Cli Token Tradeoff, Claude Code Scheduled Tasks
Source references
- [src-011] Nate Herk — Claude Code power features cluster (2026-04-20 to 2026-04-27)
Keep reading from this thread
From 500 indexed pages and articles.
- Wiki concept Browser Automation with Claude Code The pattern of connecting a browser automation CLI (Playwright) to Claude Code so it can control a real browser — navigating Related by playwright
- Wiki concept MCP vs CLI Token Trade-off The architectural decision between using an MCP server (which loads all tool definitions into context) versus a direct CLI or API Related by playwright
- Wiki concept Self-Checking Todo Loops A Claude Code execution pattern where the agent maintains an explicit todo list, runs verification steps after each meaningful change, reads the result Related by playwright