agentleFS
ahilles107ahilles107/gravity/.claude/skills/visual-regression/SKILL.md

visual-regression

Skill22 starsChanged 43 days agoMITView on GitHub

Work with the Ladle visual-regression check — read a failing `visual` CI run, decide whether a pixel diff is a regression or an intended redesign, and adopt CI-produced baselines into the PR. Use when the `visual` workflow fails, when a PR needs updated component snapshots, when adding or changing a `*.stories.tsx` file, or when someone asks to update/refresh/accept UI snapshots.

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

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

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

    Before adopting, verify the repository, branch and exact run commit.

    line 26
  2. Very specific:

    When visual fails, the job regenerates the complete baseline set inside the container and uploads it as the visual-snapshots artifact.

    line 32
  3. Very specific:

    Use the fixed fixtures in src/test/fixtures.ts.

    line 85
  4. Very specific:

    No randomness, no network, no setTimeout-driven reveal.

    line 89
  5. Distinctive:

    Keep the rendered component inside the viewport.

    line 90

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “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

Visual regression for Ladle stories

The visual workflow screenshots every Ladle story and compares it byte for byte against a committed baseline in apps/desktop/tests/visual/__screenshots__/. One PNG per story id.

The rule that governs everything here

Adopt baselines from the pinned CI environment. They are only reproducible inside the pinned Playwright container that CI uses (mcr.microsoft.com/playwright — the tag lives in scripts/vr-ci.sh). A macOS or bare-Linux checkout renders different glyphs and antialiasing, so a locally produced PNG is guaranteed to fail on the next push while looking correct in the diff.

playwright.config.ts enforces this: --update-snapshots throws unless CI=true, and updateSnapshots: "none" makes a missing baseline a hard failure rather than a silent write. Do not work around either guard.

Adopting new baselines

Before adopting, verify the repository, branch and exact run commit. Inspect git status --short -- apps/desktop/tests/visual/__screenshots__ for existing edits and untracked files. Do not overwrite them. The acceptance script replaces the entire directory: identify that target, preserve local work, and obtain approval for replacement if it is not already authorized.

When visual fails, the job regenerates the complete baseline set inside the container and uploads it as the visual-snapshots artifact. Adopt it with:

scripts/vr-accept.sh            # newest `visual` run for the current branch
scripts/vr-accept.sh 1234567890 # or a specific run id

It downloads the artifact, replaces __screenshots__ wholesale (so baselines for deleted stories disappear too), and stages the result. Then commit:

test(desktop): update story baselines for <what changed>

The script warns when the run's headSha differs from local HEAD. If it does, push first and re-run — otherwise you commit baselines describing a different tree.

Deciding first, adopting second

vr-accept.sh is mechanical; the judgement is yours. Before running it, look at what actually changed:

VR_REPORT_DIR=$(mktemp -d "${TMPDIR:-/tmp}/gravity-visual.XXXXXX")
gh run download <run-id> --name visual-report --dir "$VR_REPORT_DIR"

The Playwright HTML report has expected/actual/diff for every failure. Read the diffs and classify:

  • Intended — the PR changes that component, spacing, or token. Adopt.
  • Unintended blast radius — a shared token or a rule in src/styles/ moved something the PR never meant to touch. Fix the CSS, don't adopt.
  • Non-determinism — the same story flips between runs. Adopting hides it. Find the source (a live Date, an unpinned locale, a loading font, an animation) and make the story deterministic instead.

Say which category each diff falls into when you report back. "Snapshots updated" without that judgement is not a review.

Adding a story

New stories have no baseline, so the first CI run after adding one fails with snapshot doesn't exist. That is the expected bootstrap: push, let it fail, run scripts/vr-accept.sh, commit the new PNGs.

Determinism requirements for stories

The suite pins timezoneId: "UTC", locale: "en-US", a 1024x720 viewport and deviceScaleFactor: 1. Stories must supply the rest:

  • Use the fixed fixtures in src/test/fixtures.ts. Their timestamps are frozen at 2024-05-01, which keeps fmtTimestamp/fmtShortTime off their isToday() branch. A story that builds a date from new Date() will pass once and fail forever after.
  • No randomness, no network, no setTimeout-driven reveal.
  • Keep the rendered component inside the viewport; content below the fold is not captured.

Running the comparison yourself

You can run the real check locally if Docker is available — this uses the same container as CI, so it is safe:

scripts/vr-ci.sh

What you must not do is pnpm vr:update on your machine. pnpm vr alone (outside the container) will also report false diffs; it exists for the container to call.

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.