Chris EichlerAI-first Product
& Marketing

Claude Code + Playwright


Step 1: The setup is one prompt

Playwright is an open source tool that remote-controls real browsers. Claude Code can install and operate it for you. You need two commands:

pip install playwright
playwright install chromium

From there, tell Claude Code in plain language what you want to automate. It writes the script, opens the browser, and hands you the result. My first run went through without a single error.

Step 2: Your first screenshot

Start small. A good first job: "Open my website and take a screenshot."

Sounds trivial, but it is the smoke test for the whole setup. If this works, you have proven that the install is fine, the browser starts, and files arrive. From here you iterate your way to real workflows in minutes.

One detail I use daily: pass a viewport. For narrow image slots I capture pages at 760 pixels wide instead of 1440. Less zoom crop, more readable content.

Step 3: Let it build and test

The real leverage is not the single screenshot. It is the loop: Claude builds something, tests it in a real browser, and fixes what breaks.

My example: the renderer that builds my Instagram slides from HTML. Claude Code wrote it, along with 16 Playwright tests. The tests open real browsers, measure every slide (1080 by 1350 pixels, no overflow), and fail hard when something is off. The review surfaced two real bugs. Claude fixed both on its own. I did not touch a single line.

The underlying point: a test that opens a real browser checks real behavior. No mocks, no assumptions.

Step 4: Screenshots as part of your pipeline

Once the basics work, the browser becomes part of your pipeline. In my renderer, the config holds nothing but a URL. During rendering, Playwright opens the page, takes the shot, and places it into the slide.

The website image in my current carousel was created exactly like that: pulled live from e3xler.com at render time, no manual work. No screen photos, no fake mockups.

Why Playwright instead of MCP?

Browser MCPs exist, and for interactive click sessions they are strong. For pipelines I still went with the script, for one reason: tokens.

An MCP server loads its tool descriptions into the context window, and they ride along on every turn. A Playwright script has none of that overhead. It runs headless in the background, and the result is a file instead of a long chat transcript. For repeatable jobs (rendering, testing, screenshotting) that is the leaner architecture.

Common mistakes

  • Starting too big. "Automate my marketing" fails. "Screenshot this page" works and grows.
  • Underestimating login walls. Instagram and friends like to block anonymous browsers. Anything behind a login or captcha stays manual for me, and that is fine.
  • Shipping results unchecked. Nothing goes out without my review. Claude proposes, I decide. Posting runs through the API, not the browser.
  • Vague instructions. One task, one prompt, one measurable result. Anything else produces loops.

Next steps

  1. Run the two commands above
  2. Have Claude Code screenshot a page
  3. Define your first real job: test a form, monitor a page, pull an image for your content

Ideas on AI-first Product Management & Marketing, straight to your inbox.

No spam, unsubscribe at any time

Chris Eichler