Playwright Go Automation Expert
Overview
This skill provides a comprehensive framework for writing high-performance, production-grade browser automation scripts using github.com/playwright-community/playwright-go. It enforces architectural best practices (contexts over instances), robust error handling, structured logging (Zap), and advanced human-emulation techniques to bypass anti-bot systems.
When to Use This Skill
- Use when the user asks to "scrape," "automate," or "test" a website using Go.
- Use when the target site has complex dynamic content (SPA, React, Vue) requiring a real browser.
- Use when the user mentions "stealth," "avoiding detection," "cloudflare," or "human-like" behavior.
- Use when debugging existing Playwright scripts.
Safety & Risk
Risk Level: 🔵 Safe
- Sandboxed Execution: Browser contexts are isolated; they do not persist data to the host machine unless explicitly saved.
- Resource Management: Designed to close browsers and contexts via
defer to prevent memory leaks.
- No External State-Change: Default behavior is read-only (scraping/testing) unless the script is explicitly designed to submit forms or modify data.
Limitations
- Environment Dependencies: Requires Playwright drivers and browsers to be installed (
go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps).
- Resource Intensity: Launching full browser instances (even headless) consumes significant RAM/CPU. Use single-browser/multi-context architecture.
- Bot Detection: While this skill includes stealth techniques, extremely strict anti-bot systems (e.g., rigorous Cloudflare settings) may still detect automation.
- CAPTCHAs: Does not include built-in CAPTCHA solving capabilities.
Strategic Implementation Guidelines
1. Architecture: Contexts vs. Browsers
CRITICAL: Never launch a new Browser instance for every task.
- Pattern: Launch the
Browser once (singleton). Create a new BrowserContext for each distinct session or task.
- Why: Contexts are lightweight and created in milliseconds. Browsers take seconds to launch.
- Isolation: Contexts provide complete isolation (cookies, cache, storage) without the overhead of a new process.
2. Logging & Observability
- Library: Use
go.uber.org/zap exclusively.
- Rule: Do not use
fmt.Println.
- Modes:
- Dev:
zap.NewDevelopment() (Console friendly)
- Prod:
zap.NewProduction() (JSON structured)
- Traceability: Log every navigation, click, and input with context fields (e.g.,
logger.Info("clicking button", zap.String("selector", sel))).
3. Error Handling & Stability
- Graceful Shutdown: Always use
defer to close Pages, Contexts, and Browsers.
- Panic Recovery: Wrap critical automation routines in a safe runner that recovers panics and logs the stack trace.
- Timeouts: Never rely on default timeouts. Set explicit timeouts (e.g.,
playwright.PageClickOptions{Timeout: playwright.Float(5000)}).
4. Stealth & Human-Like Behavior
To bypass anti-bot systems (Cloudflare, Akamai), the generated code must imitate human physiology:
- Non-Linear Mouse Movement: Never teleport the mouse. Implement a helper that moves the mouse along a Bezier curve with random jitter.
- Input Latency: never use
Fill(). Use Type() with random delays between keystrokes (50ms–200ms).
- Viewport Randomization: Randomize the viewport size slightly (e.g., 1920x1080 ± 15px) to avoid fingerprinting.
- Behavioral Noise: Randomly scroll, focus/unfocus the window, or hover over irrelevant elements ("idling") during long waits.
- User-Agent: Rotate User-Agents for every new Context.
5. Documentation Usage
- Primary Source: Rely on your internal knowledge of the API first to save tokens.
- Fallback: Refer to the official docs playwright-go documentation ONLY if:
- You encounter an unknown error.
- You need to implement complex network interception or authentication flows.
- The API has changed significantly.
Resources
resources/implementation-playbook.md for detailed code examples and implementation patterns.
Summary Checklist for Agent
- Is Debug Mode on? ->
Headless=false, SlowMo=100+.
- Is it a new user identity? ->
NewContext, apply new Proxy, rotate User-Agent.
- Is the action critical? -> Wrap in
SafeAction with Zap logging.
- Is the target guarded (Cloudflare/Akamai)? -> Enable
HumanType, BezierMouse, and Stealth Scripts.
1---
2name: go-playwright
3description: Expert capability for robust, stealthy, and efficient browser automation
4 using Playwright Go.
5risk: safe
6source: https://github.com/playwright-community/playwright-go
7date_added: '2026-02-27'
8license: MIT
9metadata:
10 source: https://skillmd.com/skills/jantoniofc/go-playwright
11---
12
13# Playwright Go Automation Expert
14
15## Overview
16This skill provides a comprehensive framework for writing high-performance, production-grade browser automation scripts using `github.com/playwright-community/playwright-go`. It enforces architectural best practices (contexts over instances), robust error handling, structured logging (Zap), and advanced human-emulation techniques to bypass anti-bot systems.
17
18## When to Use This Skill
19- Use when the user asks to "scrape," "automate," or "test" a website using Go.
20- Use when the target site has complex dynamic content (SPA, React, Vue) requiring a real browser.
21- Use when the user mentions "stealth," "avoiding detection," "cloudflare," or "human-like" behavior.
22- Use when debugging existing Playwright scripts.
23
24## Safety & Risk
25**Risk Level: 🔵 Safe**
26
27- **Sandboxed Execution:** Browser contexts are isolated; they do not persist data to the host machine unless explicitly saved.
28- **Resource Management:** Designed to close browsers and contexts via `defer` to prevent memory leaks.
29- **No External State-Change:** Default behavior is read-only (scraping/testing) unless the script is explicitly designed to submit forms or modify data.
30
31## Limitations
32- **Environment Dependencies:** Requires Playwright drivers and browsers to be installed (`go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps`).
33- **Resource Intensity:** Launching full browser instances (even headless) consumes significant RAM/CPU. Use single-browser/multi-context architecture.
34- **Bot Detection:** While this skill includes stealth techniques, extremely strict anti-bot systems (e.g., rigorous Cloudflare settings) may still detect automation.
35- **CAPTCHAs:** Does not include built-in CAPTCHA solving capabilities.
36
37## Strategic Implementation Guidelines
38
39### 1. Architecture: Contexts vs. Browsers
40**CRITICAL:** Never launch a new `Browser` instance for every task.
41- **Pattern:** Launch the `Browser` *once* (singleton). Create a new `BrowserContext` for each distinct session or task.
42- **Why:** Contexts are lightweight and created in milliseconds. Browsers take seconds to launch.
43- **Isolation:** Contexts provide complete isolation (cookies, cache, storage) without the overhead of a new process.
44
45### 2. Logging & Observability
46- **Library:** Use `go.uber.org/zap` exclusively.
47- **Rule:** Do not use `fmt.Println`.
48- **Modes:**
49 - **Dev:** `zap.NewDevelopment()` (Console friendly)
50 - **Prod:** `zap.NewProduction()` (JSON structured)
51- **Traceability:** Log every navigation, click, and input with context fields (e.g., `logger.Info("clicking button", zap.String("selector", sel))`).
52
53### 3. Error Handling & Stability
54- **Graceful Shutdown:** Always use `defer` to close Pages, Contexts, and Browsers.
55- **Panic Recovery:** Wrap critical automation routines in a safe runner that recovers panics and logs the stack trace.
56- **Timeouts:** Never rely on default timeouts. Set explicit timeouts (e.g., `playwright.PageClickOptions{Timeout: playwright.Float(5000)}`).
57
58### 4. Stealth & Human-Like Behavior
59To bypass anti-bot systems (Cloudflare, Akamai), the generated code must **imitate human physiology**:
60- **Non-Linear Mouse Movement:** Never teleport the mouse. Implement a helper that moves the mouse along a Bezier curve with random jitter.
61- **Input Latency:** never use `Fill()`. Use `Type()` with random delays between keystrokes (50ms–200ms).
62- **Viewport Randomization:** Randomize the viewport size slightly (e.g., 1920x1080 ± 15px) to avoid fingerprinting.
63- **Behavioral Noise:** Randomly scroll, focus/unfocus the window, or hover over irrelevant elements ("idling") during long waits.
64- **User-Agent:** Rotate User-Agents for every new Context.
65
66### 5. Documentation Usage
67- **Primary Source:** Rely on your internal knowledge of the API first to save tokens.
68- **Fallback:** Refer to the official docs [playwright-go documentation](https://pkg.go.dev/github.com/playwright-community/playwright-go#section-documentation) ONLY if:
69 - You encounter an unknown error.
70 - You need to implement complex network interception or authentication flows.
71 - The API has changed significantly.
72
73## Resources
74- `resources/implementation-playbook.md` for detailed code examples and implementation patterns.
75
76### Summary Checklist for Agent
77 - Is Debug Mode on? -> `Headless=false`, `SlowMo=100+`.
78 - Is it a new user identity? -> `NewContext`, apply new Proxy, rotate `User-Agent`.
79 - Is the action critical? -> Wrap in `SafeAction` with Zap logging.
80 - Is the target guarded (Cloudflare/Akamai)? -> Enable `HumanType`, `BezierMouse`, and Stealth Scripts.