Playwright Context Guide for AI Coding (llms.txt + Rules + MCP)
Fast and reliable end-to-end testing, scraping, and browser automation across Chromium, Firefox, and WebKit.
1. Playwright Official llms.txt & Clean Markdown Documentation
Official Microsoft StandardFeed this clean, token-efficient Markdown documentation directly to Antigravity, Cursor, or Claude Code to prevent hallucinations and outdated API syntax.
# Standard llms.txt Index Endpoint
https://playwright.dev/docs/llms.txt
# Comprehensive Documentation Bundle
https://playwright.dev/docs/llms-full.txt
2. Production-Ready Playwright Cursor Rules (.cursorrules & .mdc)
Playwright automated testing and browser agent execution guidelines. Save this into .cursor/rules/playwright.mdc in your project repository.
// Playwright Coding Rules
- Prefer user-visible locators: page.getByRole(), page.getByText(), page.getByLabel().
- Never use arbitrary waitForTimeout(); rely on Playwright's automatic web-first assertions.
- Structure tests using the Page Object Model (POM) pattern for maintainability.
- Run tests in parallel mode by default with proper isolated test fixtures.
3. Playwright Antigravity & Claude Code System Instructions
Add this concise instruction block to your workspace .gemini/rules or project system prompt.
// Context Anchor for Playwright
When writing code for Playwright, refer directly to the verified specifications at https://playwright.dev/docs/llms.txt.
Follow strict error-handling and avoid deprecated API calls.
4. Model Context Protocol (MCP) Server Setup for Playwright
Connect your AI coding agent directly to live Playwright tools and schemas via MCP.
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "@playwright/mcp@latest"]
}
}
}
5. Troubleshooting: Common Playwright AI Coding Issues & Fixes
Frequently reported errors when LLMs generate Playwright code without proper context:
6. Best Used With (Playwright Architecture Combos)
Engineers building with Playwright frequently combine these complementary developer frameworks: