agentleFS
AndreiBanu1AndreiBanu1/playwright-suite-skills/skills/register-fixture/SKILL.md

register-fixture

Skill1 starsChanged 3 months agoMITView on GitHub

Use when a newly written page object, API client, or helper needs to become available to specs — the Playwright fixture wiring step. Covers picking the right fixture file, scope choice, dependencies between fixtures, teardown for anything that holds a resource, and why a fixture is preferable to a beforeEach. Reads conventions from .claude/test-profile.md.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    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:

    Default to per-test scope.

    line 48
  2. Distinctive:

    Run one spec that consumes the new context entry.

    line 79
  3. Distinctive:

    Run lint and typecheck if the profile lists them.

    line 83
  4. Distinctive:

    No secrets read into a fixture and then logged.

    line 87
  5. Distinctive:

    Do not make an expensive resource a dependency of a broadly used fixture.

    line 88
  6. Distinctive:

    Do not register the same object twice under two names.

    line 90
  7. Distinctive:

    If two fixtures need to share mutable state, stop.

    line 91

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

Skill: register-fixture

Make something a spec can ask for by name.

This is the step most often skipped, and it fails loudly but misleadingly: the spec errors on an undefined argument, so the investigation starts in the spec rather than at the missing registration.

Preconditions

  1. .claude/test-profile.md exists and names where fixtures are defined. If it says none, this repo passes dependencies some other way — follow that, and do not introduce a fixture layer without asking.
  2. The thing being wired already exists and is importable.

Procedure

1. Pick the file

The profile records whether this repo has one shared context file or several independent ones, one per test group. Both designs are legitimate:

  • Independent per group — a browser spec cannot accidentally acquire a database connection. Cheap isolation, some duplication.
  • One shared, composed — no duplication, but a careless dependency makes every spec pay for a resource only some need.

Whichever it is, add to it. Do not migrate the repo to the other design as a side effect of wiring one model; that is a separate, discussable change.

2. Register

Three edits, in the repo's own style:

  1. import the thing;
  2. declare it in whatever type or shape describes the available context;
  3. provide it — construct, hand it to the test, and clean up afterwards.

Match the neighbours exactly, including ordering if the file is ordered. This file is read constantly; an entry that reads differently from the rest slows everyone down.

3. Scope deliberately

Default to per-test scope. It is the reason a failing spec does not poison the next one, and reusing a tainted object across a whole worker is one of the harder flake classes to diagnose because the failure surfaces in a spec that is not the cause.

Widen scope only for something genuinely expensive and genuinely immutable — a fetched static reference dataset, say. Write the reason in a comment next to it. If the object holds mutable state or a live connection, it stays per-test even when that is slower. Correctness first.

4. Depend on other fixtures rather than reconstructing

A client that needs a transport takes the transport fixture, rather than building its own. Keep the dependency graph acyclic and shallow: a fixture three levels deep means a browser launches for a spec that never needed one.

Sequence matters where setup is ordered — authentication before anything that needs a token.

5. Tear down what you acquire

Anything holding a connection, a browser context, a temporary file, or a created record gets released after the test, in the teardown half of the fixture. Teardown runs even when the test failed, which is exactly why resource cleanup belongs here and not at the end of a spec body.

6. Prefer this over a hook

A fixture is better than a beforeEach for three reasons worth stating, because the hook is the more familiar habit: only specs that ask for it pay for it; teardown is colocated with setup instead of sitting in a separate hook; and the spec signature documents its own dependencies, so a reader knows what the test touches without scrolling.

7. Verify

Run one spec that consumes the new context entry. Then run a second spec that does not ask for it, and confirm nothing new happens for that one — the common wiring mistake is a dependency that makes every spec in the file acquire the resource.

Run lint and typecheck if the profile lists them.

Guardrails

  • No secrets read into a fixture and then logged. Name the key; keep the value out of output.
  • Do not make an expensive resource a dependency of a broadly used fixture. That is how a fifteen-second suite becomes a four-minute one, invisibly.
  • Do not register the same object twice under two names.
  • If two fixtures need to share mutable state, stop. That is a design question, not a wiring detail.

Done when

The entry is registered, a consuming spec passes, a non-consuming spec is provably unaffected, anything acquired is released, and you have reported the file and the name specs now use.

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.