---
name: playwright
description: Playwright MCP usage rules, screenshots, code sandbox, Chrome data. Auto-invoke when using Playwright MCP tools.
user-invocable: true
title: playwright
canonical_url: https://skilld.dev/gh/fubits1/svelte-skills/playwright
last_updated: 2026-10-25T14:32:29.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install fubits1/svelte-skills/playwright`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/playwright`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/fubits1/svelte-skills/playwright) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/playwright`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/playwright --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/playwright --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Playwright MCP

- **Ad-hoc screenshots (browser_take_screenshot): ALWAYS use `filename` with `/tmp/` path. NEVER relative paths. NEVER save to the project directory.** Every ad-hoc screenshot filename MUST start with `/tmp/`. Example: `/tmp/tabs-before.png`. Saving screenshots without `/tmp/` prefix pollutes the project with untracked files. This applies to screenshots YOU take for debugging/verification: NOT to automated test screenshots, which follow their own conventions (e.g. `tests/**/screenshots/`).
- **ALWAYS verify changes in the browser using Playwright MCP.** Navigate to the affected URL(s), take a screenshot, and visually confirm the page works. A DOM snapshot alone proves NOTHING: it cannot show canvas/WebGL/SVG rendering, layout, or visual state. ALWAYS take a screenshot. If you cannot visually confirm it works from the screenshot (e.g. WebGL canvas blank in headless), say so honestly, do NOT claim it's fixed.
- **ALWAYS Automate Playwright** if you need to verify the same thing more than once.
- **ALWAYS Automate Playwright** if you need to run a sequence of actions to verify.
- `run_code` sandbox: use `page.waitForTimeout(ms)`, never `setTimeout`.
- NEVER delete Chrome user data dir (`mcp-chrome-*`). It has auth cookies.
- If Playwright can't launch because Chrome is already running, kill the existing Chrome process yourself: don't ask the user.
- **CSS/layout changes: ALWAYS take before/after screenshots.** Screenshot BEFORE making changes to establish a baseline, then screenshot AFTER to compare. This catches regressions instantly.
- **CSS/layout screenshots require CRITICAL EXAMINATION.** Before taking the screenshot, write the specific visual criteria that must be true (e.g. "rows must be offset", "gap must be uniform"). After taking the screenshot, check EACH criterion individually and state pass/fail for each. Do NOT glance at the screenshot and say "looks good." If any criterion fails, STOP: do not proceed. When in doubt, take MORE screenshots at different widths, do NOT ask the user to verify for you.
- **When a visual bug is reported, INVESTIGATE before guessing fixes.** Use `browser_evaluate` to measure actual element positions, sizes, and computed styles. Compare measured values against expected values. A 5-minute investigation with JS measurements beats hours of blind CSS tweaking. NEVER change formulas or constants without first understanding WHY the current values produce wrong results.
- **Use `browser_evaluate` to MEASURE, not just screenshot.** When debugging layout issues, use JS to read actual `getBoundingClientRect()` positions, `getComputedStyle()` values, `scrollHeight`, `clientWidth` etc. Comparing measured numbers reveals the root cause instantly: screenshots only show symptoms. This is the difference between 5 minutes of investigation and hours of blind guessing.
- **PIXEL DRIFT DETECTION**: When making CSS or HTML element changes, invoke `frontend:pixel-perfect`. It has the mandatory measurement workflow: measure BEFORE with `browser_evaluate`, apply change, measure AFTER, report a diff table. Screenshots supplement measurements: they are NOT the comparison. The numbers from `getBoundingClientRect()` and `getComputedStyle()` ARE the comparison. Never claim "looks the same" from eyeballing screenshots.
- **ALWAYS CHECK CONSOLE ERRORS.** After EVERY navigation and EVERY interaction (click, select, submit), check for console errors. Use `browser_evaluate` to read errors or check the console log file from the navigation event. A page that renders but throws console errors is NOT working. Console errors are bugs until proven otherwise.
