An Instructional Guide to "Bug-Free" Coding with Playwright, WSL, and Context Engineering
Part 1: Environment Prerequisites
Before diving into the specific tools, you need a solid foundation. This entire system runs inside WSL.
- Install WSL (Windows Subsystem for Linux): If you haven't already, install WSL and a Linux distribution like Ubuntu. You can typically do this with a single command in a Windows PowerShell or Command Prompt with administrator rights.
wsl --install -d Ubuntu
The video mentions using `wsl -d ubuntu` inside a terminal. Ensure your default terminal is set up to interact with WSL seamlessly. - Install Docker Desktop: The AI will use Docker to run the project in a containerized environment. This is crucial for consistent testing. Download and install Docker Desktop for Windows, and make sure to enable WSL 2 integration in the Docker settings.
- Install Node.js: Playwright and the Claude Code CLI are built on Node.js. Install the latest LTS version within your WSL/Ubuntu environment.
- Install Visual Studio Code: The recommended editor is VS Code with the WSL extension, allowing you to edit files in WSL directly from Windows.
- Install Chromium for Playwright on WSL: This is a critical step that is often missed. Playwright needs a browser to test against. Since you're in a headless Linux environment, you must install it manually.
Run these commands in your WSL terminal:
sudo apt-get update sudo apt-get install -y chromium-browser
As the transcript mentions, Playwright might not work out-of-the-box. If you encounter errors, you may need to install additional dependencies. A common set of commands to install everything Playwright needs is:
You may have to "feed Claude code the errors and you have to actually fix it yourselves." This is part of the process.npx playwright install --with-deps
Part 2: Setting Up Claude Code and the Playwright MCP
With the environment ready, you can now install the core AI tools.
1. Install and Configure Claude Code CLI
Claude Code is the command-line AI assistant that will be orchestrating the process.
npm install -g @anthropic-ai/claude-code
The "Dangerously Skip Permissions" Flag
For the AI to work autonomously without asking for your permission for every file change, you must use the --dangerously-skip-permissions
flag. The first time you use it, you have to agree to the terms. This is a one-time setup.
claude --dangerously-skip-permissions
Follow the on-screen prompts to log in and accept the conditions. After doing this once, the AI can run non-interactively.
2. Install the Playwright MCP Server
An MCP (Model Context Protocol) server acts as a bridge, giving Claude Code new abilitiesβin this case, the ability to control a web browser via Playwright.
You'll add the official Microsoft Playwright MCP server. The command follows the pattern claude mcp add [name] -- [command-to-run-server]
.
claude mcp add playwright-mcp -- npx -y @microsoft/playwright-mcp-server@latest
Alternative: AI-Assisted MCP Installation
The video describes a unique method for generating this command if you don't know it. You can provide documentation and your request to an AI. Try it below:
Step 1: Get the MCP documentation context.
Let's imagine you've copied the contents of the Claude Code MCP installation guide. For this example, we'll use a summary.
Step 2: Formulate the prompt.
Step 3: Generate the command (simulation).
Part 3: The Context Engineering Workflow
Context Engineering is the practice of providing the AI with a highly detailed and structured plan, enabling it to execute complex tasks.
A Note on Repositories
The video mentions a specific Git repository that evolved from others: Raasmus' repo > Cole's repo > the video creator's repo. While the exact final repo isn't public, you can start with the one it was based on:
- Cole's Repo: coleam00/context-engineering-intro
- This was inspired by Rasmus' Repo: Wirasm/PRPs-agentic-eng
Cloning one of these will give you a great starting point.
Step-by-Step Project Initialization
- Create a Project Directory
mkdir video_example_context_engineering cd video_example_context_engineering
- Clone the Context Engineering Template
git clone https://github.com/coleam00/context-engineering-intro.git .
Using `.` at the end clones the contents into the current directory. The video mentions the Playwright MCP might already be included in the repo, likely in a `.mcp.json` file. - Open in VS Code
code .
- Create the `initial.md` File: This is the heart of your instruction to the AI. Create a new file named
initial.md
. - Populate `initial.md` with your Prompt: This is the most important step of "Context Engineering." You must provide a detailed plan. The video references a prompt from a private community, but the core idea is to be extremely specific.
Here is a simplified example based on the video's context:
# Task: Create a SaaS MVP for Customer Management ## Core Features: 1. A web interface with a sidebar and a main content area. 2. The ability to view a list of customers. 3. The ability to add a new customer through a form. 4. The ability to see customer details. ## Technical Stack & Rules: - Use React for the frontend. - Use Node.js and Express for the backend. - Run the entire application using Docker. - **Crucially, use the Playwright MCP for end-to-end testing. After every code change, run tests to verify functionality. If a test fails, read the browser console logs and screenshots provided by Playwright to identify the bug. Then, fix the