The Trap of Unplanned MCP Speed
When you use the Playwright MCP server with Claude Code, you get a superpower: describe a test, get working code. The source author learned this creates a dangerous trap. Moving fast without a plan leads to selectors hardcoded across 15 files, the same login logic copy-pasted 8 times, and a single UI change breaking 40 tests overnight. The problem isn't the tool—it's the workflow.
The Fix: Plan Your Architecture First
The solution is a 30-minute planning session before you write your first prompt. This mindset shift treats MCP as a code generator that fits inside your architecture, not a replacement for architectural thinking.
Step 1: Map Your Pages
List every page in your application (Login, Dashboard, Checkout, Profile). Each page gets its own Page Object file. This is your foundation. Write this list in a CLAUDE.md file or a simple text document.
Step 2: Define Reusable Utilities
Identify actions that happen on multiple pages: login, navigation, form fills, API calls. These become shared utility modules.
Step 3: Create the Empty Folder Structure
Run these commands in your terminal to create the skeleton:
mkdir -p tests/e2e/pages tests/e2e/utils tests/e2e/fixtures tests/smoke
touch tests/e2e/pages/LoginPage.ts tests/e2e/pages/DashboardPage.ts
touch tests/e2e/utils/auth.ts tests/e2e/utils/api.ts
You now have this structure:
tests/
├── e2e/
│ ├── pages/
│ │ ├── LoginPage.ts
│ │ └── DashboardPage.ts
│ └── utils/
│ ├── auth.ts
│ └── api.ts
├── smoke/
└── fixtures/
Do not write any code yet. The empty files and folders are the plan.
How To Use MCP With Your Structure
Now, when you prompt Claude Code with the Playwright MCP server enabled, you give it specific architectural instructions. Instead of "Write a test for checkout," you prompt:
"Generate a test for the checkout flow. Use the Page Object pattern. The CheckoutPage should be created in
tests/e2e/pages/CheckoutPage.ts. The test file itself should betests/e2e/checkout.spec.ts. Use the shared login utility fromtests/e2e/utils/auth.ts."
Claude Code, with access to the Playwright MCP tools, will now generate code that fits into your predefined slots. It fills your structure instead of creating its own.
The Result: Maintainable Speed
You keep the 10x generation speed but lose the mess. A UI change requires a fix in one Page Object file, not a hunt through dozens of tests. A new team member can understand the project in minutes. The structure enforces reusability by design.
The One Rule
Never open Claude Code with the Playwright MCP server until your folder structure and page object plan are on disk. This rule forces the planning that makes MCP sustainable.






