agentleFS
syntropic137syntropic137/harness-app-template/.claude/skills/chrome-devtools-deep/SKILL.md

chrome-devtools-deep

Skill0 starsChanged 6 months agoMITView on GitHub

Reach for raw Chrome DevTools Protocol when Playwright's high-level API isn't enough: performance traces, source-mapped console stacks, heap snapshots, deep network introspection. Stay inside Playwright via `newCDPSession` rather than running raw websocat.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this only when playwright-debug can't get you what you need.

    line 10

≈ “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

Chrome DevTools Protocol — escape hatch

When to use this skill

Use this only when playwright-debug can't get you what you need. Specific cases:

  • Performance profiles (Tracing.start/stop)
  • Source-mapped stack traces with original filenames
  • Heap snapshots / memory leak diagnosis
  • Filtering network responses by body content
  • Throttling network or CPU
  • Reading shadow DOM beyond Playwright's accessor

Get a CDP session via Playwright

Stay in one tool. Don't shell out to websocat.

import { chromium } from 'playwright';
const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();
const cdp = await context.newCDPSession(page);

await cdp.send('Network.enable');
await cdp.send('Page.enable');
// ... your CDP commands ...

Recipe: performance trace of a user flow

const cdp = await context.newCDPSession(page);
await cdp.send('Tracing.start', {
  categories: 'devtools.timeline,disabled-by-default-devtools.timeline',
  transferMode: 'ReturnAsStream',
});
// ... do the flow ...
const { stream } = await cdp.send('Tracing.end');
// Then collect via IO.read until eof

Save the resulting trace JSON; open it in chrome://tracing or feed sections to the agent.

Recipe: source-mapped console stack traces

const cdp = await context.newCDPSession(page);
await cdp.send('Runtime.enable');
cdp.on('Runtime.exceptionThrown', e => {
  console.log(JSON.stringify(e.exceptionDetails, null, 2));
});

The exceptionDetails.stackTrace.callFrames[].url and lineNumber will be source-map-resolved if the page ships maps.

Recipe: get network response body by URL pattern

const cdp = await context.newCDPSession(page);
await cdp.send('Network.enable');
const interesting = new Map();
cdp.on('Network.responseReceived', e => {
  if (e.response.url.includes('/tasks')) interesting.set(e.requestId, e.response.url);
});
// Later, after the request completes:
for (const [requestId, url] of interesting) {
  const body = await cdp.send('Network.getResponseBody', { requestId });
  console.log(url, body.body);
}

Recipe: heap snapshot

const cdp = await context.newCDPSession(page);
await cdp.send('HeapProfiler.enable');
const chunks = [];
cdp.on('HeapProfiler.addHeapSnapshotChunk', c => chunks.push(c.chunk));
await cdp.send('HeapProfiler.takeHeapSnapshot', { reportProgress: false });
const snapshot = chunks.join('');
// Save to .harness/artifacts/<iso>/heap-<timestamp>.heapsnapshot
// Open in Chrome DevTools Memory panel

Anti-recipe: don't run raw websocat

Raw CDP via websocat/curl was an earlier approach. It's been removed because (a) every response is unfiltered protocol JSON (token-heavy), (b) error messages are numeric codes, (c) you lose Playwright's frame/target management. Use newCDPSession() instead.

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.