agentleFS
domucchidomucchi/pi-setup/skills/browser-debugging/SKILL.md

browser-debugging

Skill0 starsChanged 4 months agoMITView on GitHub

Heavy browser work via playwright scripts — network mocking, tracing, auth/storage state, device emulation, multi-tab, downloads. Load when the browser_* tools are not enough.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. LeonxLJX/web-engineer-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep artifacts (traces, screenshots, storage state) in /tmp and tell the user the paths.

    line 93

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Browser debugging beyond the tools

The browser_* tools cover the interactive loop (navigate, read, click, type, screenshot, console, network log, evaluate). Everything heavier is a playwright script you write and run — the full library API with no per-tool plumbing. Prefer a script whenever the task needs interception, tracing, persistent auth, emulation, or more than one page.

Running scripts

playwright (with cached chromium) is installed in the harness, not the target project — and NODE_PATH does NOT apply to ESM import, so resolve it with createRequire pinned to the harness:

// /tmp/debug.mjs — run with plain `node /tmp/debug.mjs`
import { createRequire } from "node:module";
import { homedir } from "node:os";
const require = createRequire(`${homedir()}/.pi/agent/noop.js`);
const { chromium, devices } = require("playwright");
const { expect } = require("playwright/test"); // only when asserting

Long-running scripts (watch a flow, keep a trace open) belong in bg_start, one-shots in bash. Always await browser.close() in a finally.

Recipes

Network interception / mocking

await page.route("**/api/users", (route) =>
  route.fulfill({ json: [{ id: 1, name: "stub" }] }),
);
await page.route("**/analytics/**", (route) => route.abort());

Tracing (record, then hand the user the viewer command)

await context.tracing.start({ screenshots: true, snapshots: true });
// … drive the flow …
await context.tracing.stop({ path: "/tmp/trace.zip" });

Tell the user to open it with the harness's own playwright binary (npx from another cwd would download a mismatched copy): ~/.pi/agent/node_modules/.bin/playwright show-trace /tmp/trace.zip

Auth / storage state (log in once, reuse forever)

await context.storageState({ path: "/tmp/auth.json" }); // after login
const context2 = await browser.newContext({ storageState: "/tmp/auth.json" });

Device emulation

const context = await browser.newContext({ ...devices["iPhone 15"] });

Downloads

const [download] = await Promise.all([
  page.waitForEvent("download"),
  page.getByText("Export").click(),
]);
await download.saveAs(`/tmp/${download.suggestedFilename()}`);

Assertions (auto-retrying, via require("playwright/test"))

await expect(page.getByRole("alert")).toHaveText(/saved/i);

Notes

  • Scripts get their own browser — they do NOT share the browser_* session's page, console, or network log. Do a whole scenario in one place: quick inspection → tools; scripted scenario → script.
  • headless: false opens a visible window — useful when the user should watch the flow live.
  • Keep artifacts (traces, screenshots, storage state) in /tmp and tell the user the paths.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.