test-fixtures-and-factories

test-fixtures-and-factories is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 91 tokens per session (1,380 once invoked), scanned A, original, Apache-2.0.

A guide to building test fixtures and factories: reusable ways to create realistic test data such as users, orders, records, files, and database state. It favours small, explicit data that each test can change safely.

In plain words
What is it for?
Use it when adding builders, factories, sample files, seed data, or test-database setup, including data for API responses and external webhook shapes.
Why use it?
Shared or oversized test data makes tests unclear and causes them to interfere with one another. Factories and isolated fixtures keep setup readable and prevent accidental state sharing.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when adding builders, factories, sample files, seed data, or test-database setup, including data for API responses and external webhook shapes.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tmj-90/gaffer/test-fixtures-and-factories
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add tmj-90/gaffer --skill test-fixtures-and-factories
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for test-fixtures-and-factories

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/test-fixtures-and-factories/github.svg)](https://agentmods.dev/skills/tmj-90/gaffer/test-fixtures-and-factories)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/test-fixtures-and-factories"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/test-fixtures-and-factories/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for test-fixtures-and-factories

Your own site · 80×15
<a href="https://agentmods.dev/skills/tmj-90/gaffer/test-fixtures-and-factories"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/test-fixtures-and-factories.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 91 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,380 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00091 $0.01380
Opus 5.5 $0.00036 $0.00552
Sonnet 5.5 $0.00018 $0.00276
Haiku 4.5 $0.00009 $0.00138

Measured 16d ago against content hash a8da00f584dd, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

test-fixtures-and-factories scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 16d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

runner/skills/test-fixtures-and-factories/SKILL.md · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Build test fixtures and factories that stay honest

Good test data is minimal, explicit about what matters, and impossible to share by accident. A factory gives every test a valid object in one line and lets it override only the fields the test is about; a 200-line JSON blob nobody understands is a liability. Isolation is not optional: tests that share state pass alone and fail in parallel, or — worse — pass because an earlier test left the data they needed.

Procedure

  1. Find the repo's pattern. Look for factories/, fixtures/, testing/, __fixtures__/, conftest.py, builder helpers, a seed script, or a test-database setup (in-memory SQLite, per-test schema or transaction, Testcontainers). Call search_lore for conventions. Match what exists; add a library (fishery, factory_boy, @faker-js) only if the repo already uses it. (Independent tester: only paths the runner counts as tests survive — a test/, tests/, __tests__/, spec(s)/, e2e/ or fixture(s)/ directory, *.test.*/*.spec.* JS/TS files, or test_*/test-*/test.* files. A new file under factories/, testing/ or __fixtures__/, or a root conftest.py, counts as implementation and HOLDS the run; keep factories inside your test directory — see black-box-test.)
  2. Prefer factories for domain objects. makeUser({ role: "admin" }) builds a valid default and applies overrides. Keep defaults boring and valid. Generate uniqueness with a per-run sequence (user-${seq}@example.com) rather than randomness; where randomness is used, it is seeded and the seed logged. Provide builders for related graphs (makeOrder({ user })) rather than hidden auto-creation that surprises the test.
  3. Keep static fixtures for recorded external shapes — a webhook payload, an API response, a sample file. Record them from the real source, redact secrets and personal data, commit them, and name them by scenario (stripe-invoice-paid.json).
  4. Isolate every resource a test touches:
    • Database: fresh in-memory DB with real migrations per test, or a transaction rolled back per test, or a unique schema; never a module-level connection shared by tests.
    • Files: a unique temp dir per test (mkdtempSync(join(tmpdir(), "x-")), pytest tmp_path, Go t.TempDir()), removed in teardown — never a fixed path like ./data or /tmp/test.db.
    • Ports and processes: bind to port 0 and read the assigned port; teardown kills every spawned process even when the test fails.
    • Globals: env vars, clocks, module caches and singletons restored after each test.
  5. Support concurrency and persistence tests. When an AC is about concurrent writers, restarts or crashes, fixtures must make the real schedule easy: a helper that starts the app as a separate process on a temp data dir and returns { url, stop, kill, pause, resume } (SIGTERM, SIGKILL, SIGSTOP, SIGCONT), and a helper that fires N operations together. Shared on-disk state is then deliberate and scoped to one test — not leaked between tests.
  6. Never use production data or secrets. No real personal data, no real tokens or keys; use obviously fake values ([email protected], sk_test_placeholder). This is a security rule.
  7. Make the test readable at a glance. The test body shows the inputs its assertion depends on; everything else lives in the factory default. If a reader must open the factory to understand the assertion, move that field into the override list.
  8. Type the data. Factories return the real domain type or a schema-validated shape, so a schema change breaks the factory at compile/parse time instead of silently making a test assert nonsense.
  9. Prove isolation. Run the suite shuffled and in parallel where the runner supports it (Vitest --sequence.shuffle, Jest default workers, pytest-randomly / -n auto if the repo has those plugins, go test -shuffle=on -count=1), then run one changed test alone. Record evidence with the record-evidence skill (test_output).

Read the full file on GitHub · 88 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 16d ago Changed · +27 lines · +2 tokens per session a8da00f584dd
  2. 19d ago First seen · 61 lines · 89 tokens per session scan A a10b72e000f5

Subscribe to this mod's changes

test-fixtures-and-factories is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 17d ago), licensed Apache-2.0. It adds 91 tokens to every session and 1,380 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-28.