Expert capability for robust, stealthy, and efficient browser automation using Playwright Go.
Add this skill
npx mdskills install sickn33/go-playwrightComprehensive browser automation with strong architectural patterns and detailed stealth guidelines
1---2name: go-playwright3description: Expert capability for robust, stealthy, and efficient browser automation using Playwright Go.4risk: safe5source: https://github.com/playwright-community/playwright-go6---78# Playwright Go Automation Expert910## Overview11This 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.1213## When to Use This Skill14- Use when the user asks to "scrape," "automate," or "test" a website using Go.15- Use when the target site has complex dynamic content (SPA, React, Vue) requiring a real browser.16- Use when the user mentions "stealth," "avoiding detection," "cloudflare," or "human-like" behavior.17- Use when debugging existing Playwright scripts.1819## Safety & Risk20**Risk Level: šµ Safe**2122- **Sandboxed Execution:** Browser contexts are isolated; they do not persist data to the host machine unless explicitly saved.23- **Resource Management:** Designed to close browsers and contexts via `defer` to prevent memory leaks.24- **No External State-Change:** Default behavior is read-only (scraping/testing) unless the script is explicitly designed to submit forms or modify data.2526## Limitations27- **Environment Dependencies:** Requires Playwright drivers and browsers to be installed (`go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps`).28- **Resource Intensity:** Launching full browser instances (even headless) consumes significant RAM/CPU. Use single-browser/multi-context architecture.29- **Bot Detection:** While this skill includes stealth techniques, extremely strict anti-bot systems (e.g., rigorous Cloudflare settings) may still detect automation.30- **CAPTCHAs:** Does not include built-in CAPTCHA solving capabilities.3132## Strategic Implementation Guidelines3334### 1. Architecture: Contexts vs. Browsers35**CRITICAL:** Never launch a new `Browser` instance for every task.36- **Pattern:** Launch the `Browser` *once* (singleton). Create a new `BrowserContext` for each distinct session or task.37- **Why:** Contexts are lightweight and created in milliseconds. Browsers take seconds to launch.38- **Isolation:** Contexts provide complete isolation (cookies, cache, storage) without the overhead of a new process.3940### 2. Logging & Observability41- **Library:** Use `go.uber.org/zap` exclusively.42- **Rule:** Do not use `fmt.Println`.43- **Modes:**44 - **Dev:** `zap.NewDevelopment()` (Console friendly)45 - **Prod:** `zap.NewProduction()` (JSON structured)46- **Traceability:** Log every navigation, click, and input with context fields (e.g., `logger.Info("clicking button", zap.String("selector", sel))`).4748### 3. Error Handling & Stability49- **Graceful Shutdown:** Always use `defer` to close Pages, Contexts, and Browsers.50- **Panic Recovery:** Wrap critical automation routines in a safe runner that recovers panics and logs the stack trace.51- **Timeouts:** Never rely on default timeouts. Set explicit timeouts (e.g., `playwright.PageClickOptions{Timeout: playwright.Float(5000)}`).5253### 4. Stealth & Human-Like Behavior54To bypass anti-bot systems (Cloudflare, Akamai), the generated code must **imitate human physiology**:55- **Non-Linear Mouse Movement:** Never teleport the mouse. Implement a helper that moves the mouse along a Bezier curve with random jitter.56- **Input Latency:** never use `Fill()`. Use `Type()` with random delays between keystrokes (50msā200ms).57- **Viewport Randomization:** Randomize the viewport size slightly (e.g., 1920x1080 ± 15px) to avoid fingerprinting.58- **Behavioral Noise:** Randomly scroll, focus/unfocus the window, or hover over irrelevant elements ("idling") during long waits.59- **User-Agent:** Rotate User-Agents for every new Context.6061### 5. Documentation Usage62- **Primary Source:** Rely on your internal knowledge of the API first to save tokens.63- **Fallback:** Refer to the official docs [playwright-go documentation](https://pkg.go.dev/github.com/playwright-community/playwright-go#section-documentation) ONLY if:64 - You encounter an unknown error.65 - You need to implement complex network interception or authentication flows.66 - The API has changed significantly.6768## Resources69- `resources/implementation-playbook.md` for detailed code examples and implementation patterns.707172### Summary Checklist for Agent73 - Is Debug Mode on? -> `Headless=false`, `SlowMo=100+`.74 - Is it a new user identity? -> `NewContext`, apply new Proxy, rotate `User-Agent`.75 - Is the action critical? -> Wrap in `SafeAction` with Zap logging.76 - Is the target guarded (Cloudflare/Akamai)? -> Enable `HumanType`, `BezierMouse`, and Stealth Scripts.77
Full transparency ā inspect the skill content before installing.