agentleFS
neijixneijix/AICodeFactory/skills/headless-ui-smoke/SKILL.md

headless-ui-smoke

Skill0 starsChanged 16 days agoMITView on GitHub

Use after changing HTML, CSS or front-end JS when only unit tests ran; when the user says the page is blank, broken or \"looks wrong\", or asks to check, screenshot or match a design; before calling UI work done; when chrome --headless --dump-dom/--screenshot comes back empty or hangs. Headless Chrome over DevTools: page errors, clicks, screenshots. No Playwright.

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:

    Plain scripts share one global scope: When a page is several <script> files without modules, a later file silently redefines an earlier …

    line 82

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

Headless UI smoke check

Unit tests do not load the page. A renamed function, a script tag in the wrong order, a CSS rule that hides the main column: all green in the test runner, all broken in the browser. If you changed what a browser renders, look at it in a browser before you say it works — and since you can read images, actually look at the screenshot.

The three traps (why the obvious commands fail)

You tryWhat happensWhy
chrome --headless --dump-dom URL / --screenshotEmpty shell, or the sidebar but never the content — and it differs between runsBoth fire at the load event. A client-rendered app has not fetched its data yet.
add --virtual-time-budget=5000Hangs until your timeout kills itVirtual time never drains on a page with setInterval, SSE or WebSocket connections.
wait for Chrome to exitIt never does (macOS, --headless=new)The process lingers after writing its output.

The way through is the DevTools protocol: start Chrome with --remote-debugging-port, open the page's WebSocket from /json/list, then Page.navigate, poll a "rendered" condition with Runtime.evaluate, Page.captureScreenshot, and stop Chrome yourself. The bundled script does exactly that; do not rebuild it.

Use it

The script ships with this skill (scripts/cdp_smoke.py, next to this file) and is the same on every machine: a symlink into the template repo on macOS / Linux, a copy refreshed at session start on Windows. It needs only uv — its one dependency is declared inline.

# macOS / Linux / Git Bash
SMOKE=~/.agents/skills/headless-ui-smoke/scripts/cdp_smoke.py   # same file under ~/.claude/skills
uv run "$SMOKE" http://127.0.0.1:3000/ \
  --wait-for "document.querySelectorAll('#list .row').length > 0" \
  --expect-text "Dashboard" \
  --shot /tmp/home.png
# Windows PowerShell — same flags; mind the quoting of the JavaScript
$Smoke = "$HOME\.agents\skills\headless-ui-smoke\scripts\cdp_smoke.py"
uv run $Smoke http://127.0.0.1:3000/ `
  --wait-for "document.querySelectorAll('#list .row').length > 0" `
  --expect-text "Dashboard" `
  --shot "$env:TEMP\home.png"

Chrome, Chromium, Edge or Brave is found by itself (per-machine and per-user installs on Windows included); --chrome <path> or $CHROME_PATH overrides it.

  • Exit code 0 = no page error and every expectation met; 1 = something is wrong (each problem on its own FAIL line); 2 = Chrome could not be driven at all.
  • It reports uncaught exceptions (with file:line), console.error, and failed or non-2xx requests. Then open the PNG and check it against what you meant to build.
  • --wait-for is the important flag: a JavaScript condition that means "rendered". Prefer it to a longer --settle; a fixed sleep is either too short or wasted.
NeedFlag
Sign in first, then open the pageseveral URLs in order — one tab, one profile, cookies carry over
Click, type, open a dialog before the shot--eval "document.querySelector('#open-settings').click()" (repeatable)
The whole document, not the viewport--full-page
A phone layout--size 390x844
An error the app makes on purpose (a 401 probing "am I signed in?")--ignore "401.*api/me"
Stay signed in across runs--profile /tmp/my-profile
Assert content--expect-text, --forbid-text "undefined"
Inspect what rendered--dump-dom /tmp/page.html
CI or a container running as root--no-sandbox

Things that cost time once

  • --eval awaits promises. --eval "send()" returns only when send() settles — for a streaming reply that is the whole stream, and the call times out. End fire-and-forget calls with ; 0: --eval "send(); 0".
  • Check against a throwaway instance, not the user's live data. Start the app on a free port with a temp data dir and seeded content; a smoke run that signs in to the real thing can create, rename or delete real records. If the project has no such harness, a 40-line script that boots the server in-process with fixtures pays for itself on the second UI change.
  • Plain scripts share one global scope. When a page is several <script> files without modules, a later file silently redefines an earlier one's function. The symptom is a component drawing another component's markup; the screenshot shows it, no test does.
  • Scale 2 by default, so text in the PNG stays readable when you view it. Use --scale 1 for pixel comparisons with a reference.
  • Matching a reference screenshot: take yours at the same viewport size, put both side by side, and go region by region (header, list, composer) — colours and spacing first, then states the reference shows that yours does not (hover, running, empty).

When not to use it

The project already has Playwright or Cypress wired in: use that, it does more. Do not add one of them to a project just to look at a page once — that is what this is for.

Report honestly

Say what you loaded, what the script reported, and what you saw in the screenshot. "Tests pass" is not "the page works"; if you could not run a browser, say so 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.