mik2win/foureyes/test

Claude Code and agent skill by mik2win/foureyes

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Author new tests or refactor existing ones — layer classification, inventory & gap analysis, test-design table, AAA/naming/mock discipline, async safety, antipattern cleanup, and coverage verification. Covers both writing tests from scratch and improving the quality of tests that already exist. TRIGGER when: the user wants to write/add/generate tests for a file, directory, or feature, OR to audit/refactor/clean up existing tests. DO NOT TRIGGER when: the user wants to build NEW code test-first (use /tdd), only wants to run the existing suite, or wants to debug a specific failure (use /diagnose — but come back here to lock the fix with a test).

Install

npx vskill@latest install mik2win/foureyes/test

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as mik2win/foureyes/test.

Test Authoring & Refactoring

Target: $ARGUMENTS — one of:

  • A source file/dir (<src>/foo) → write tests for it.
  • A test file/dir → audit and refactor existing tests.
  • A description ("login error isolation") → write targeted scenarios.
  • staged → audit/cover the test or source files in staged changes.
  • A plan/card file with a scope note → pin the scoped modules, then write the log back into that file (see Persist to the artifact).

If $ARGUMENTS is empty, ask what to test and stop. Work the phases in order; Phases 1–3 are investigative (plan before writing), 4–7 implement, 8 verifies.

Progressive loading. Phases 1–3 and 8 need nothing but this file. Phases 4–7 carry the rules inline and the worked examples in reference/, read only when the target calls for it — each phase below names its file and its short-circuit. A run that writes three synchronous unit tests should never open the async reference.

Phase 0 — Load profile

Make this generic workflow concrete from project facts:

  • [ ] Read .claude/PROJECT.md — Stack, Commands (test, test:targeted/test:one),

and Architecture (modules/layers, and the test layout: where tests, fixtures, and factories live).

  • [ ] Read .claude/rules/_generic/testing.md.
  • [ ] If CONTEXT.md exists, read it so test names use the project's domain vocabulary.
  • [ ] Read every stack testing rule whose paths frontmatter matches the target. These

packs carry the concrete framework, assertion style, fixtures, and factory locations — never hardcode them here.

  • [ ] If PROJECT.md is missing or still TEMPLATE, fall back to the root CLAUDE.md (always in

context) when it carries the stack, test command, and test layout — note you're running without a kit profile. Only if neither has them, run /bootstrap first.

Use the test command, test layout, and layers from PROJECT.md everywhere below. Apply the stack-specific test patterns from the installed .claude/rules/* — do not invent framework idioms in this skill.


Phase 1 — Classify

Mode:

  • Source file/feature given → new tests (Phase 2, then 4–7).
  • Existing test file/dir given → refactoring (Phase 2, then 6).
  • Both → do both, in that order.
  • Source with no tests and nothing stating what it should do (no spec, ticket, docstring or sibling

test) → legacy mode: read `reference/legacy-mode.md`, characterize first.

Layer of the code under test (use the layers named in PROJECT.md → Architecture):

LayerExamplesTest approach
Pure / domaincalculations, transforms, validators, value objectsPure unit tests — no mocks, deterministic inputs from factories
Service / use-casecommands, queries, orchestrationMock only the external boundary; test the real domain logic they call
Infra / IOnetwork, DB, filesystem, queues, clockMock the boundary for its callers; async-aware where the language has async. Every persistence mapping still gets one real create/read/update/delete round-trip in the integration lane — nothing else catches SQL drifting out of step with the code
UIcomponents, viewsRender + behavior via public output; query by role/text, not internals

The layer decides the strategy: unit (no mocks) vs mock-boundary vs async-aware vs render. Find existing coverage before planning — map the target to its expected test path by the project's naming convention and grep the test tree for references to the units.


Phase 2 — Inventory & gap analysis

For new tests, list every public unit (function, method, class, exported symbol) and mark coverage. For refactoring, list the existing tests and the antipatterns they carry.

UnitKindCovered?Verdict
process_orderpurepartialunit-test thoroughly
OrderResultvalue objectyes—
fetch_remoteionoone integration test

Kind: pure (deterministic, no side effects) · stateful (mutates state) · async · io (network/file/DB/clock).

Verdict — two axes, never a coverage percentage per layer. Complexity/domain significance against the number of collaborators (mutable or out-of-process; values do not count, implicit ones through statics do). High + few → unit-test thoroughly. Low + few → do not test it at all. Low + many → one integration test. High + many → a design defect: report it and route to /refactor before any test.

Evidence before the audit (refactoring mode) — gather with the stack's own idioms (from the installed testing rule / CONTEXT.md), never a hardcoded framework token. Grep the target test tree for:

  • [ ] test functions with no assertion / no expected-exception (the stack's assert/raises idiom).
  • [ ] real sleeps and real-clock reads (sleep, now, time()), and unseeded randomness.
  • [ ] hardcoded temp/output paths instead of the framework's temp-dir helper.
  • [ ] mocks that patch the project's own modules/layers (from PROJECT.md → Architecture), not boundaries.
  • [ ] legacy xUnit-style setup/teardown/assert calls where the stack prefers plain asserts.

Record each hit as a row that feeds the Phase 6 findings table.

Before writing any fixture, check the project's factory/fixture location (from PROJECT.md / stack rules) — reuse existing builders instead of constructing domain objects inline.

For large or unfamiliar targets, delegate to the `test-gap-finder` agent to enumerate untested paths and rank them by risk, then design tests for the critical gaps it reports.


Phase 3 — Test design

Plan every test as a row before writing code:

UnitScenarioExpectedTypeMock boundary
process_orderno itemsempty result, no chargeunitnone
process_ordervalid itemstotal computed, 1 chargeunitnone
fetch_remotenetwork errorpropagates after retryintegrationnetwork client
handle_eventsubscriber callback raisesengine does not propagateasync unitnone

Mock decision — five rules:

  1. Mock external boundaries only: network, DB, filesystem, clock/now, sleep.
  2. Never mock your own domain logic or same-module internals — that tests the mock, not

behavior.

  1. Several doubles in one test is a report about the design, not a lane to change — name the defect

first (skills/tdd/mocking.md §Smell: too many mocks), then widen only if the seam is truly wide.

  1. Prefer a fake over a mock for a collaborator you own but must stand in for (a repository,

a queue, a store): a small working in-memory implementation exercises real behavior, where a mock only replays a scripted return and asserts on the script.

  1. A client for an external provider → test the contract from your side in two halves that never

call it: `reference/writing-patterns.md` §Prefer a fake over a mock.

Which scenario gets the integration test. Cover a scenario's edge cases with unit tests and give it one integration test — the longest happy path, crossing the most out-of-process dependencies; add another only to reach a dependency that path misses. A failure that crashes on the first run in any environment and cannot corrupt data needs no test: declare the skip under Remaining Gaps.

Fixture vs local helper: reusable across ≥2 files → shared fixture/setup in the nearest common location; used once → local helper at the top of the file; complex domain object → the project's factory location.


Phase 4 — Writing rules

Load on demand: writing new tests → read `reference/writing-patterns.md` (worked good/bad shapes for naming, AAA, parametrize, fixture scope, mock discipline, fakes, assertion quality, isolation). Refactor-only runs skip it except its §Refactoring conversions (Phase 6).

  • Naming: a statement of fact about behaviour in domain words (delivery_with_a_past_date_is_invalid);

method-name template only for utility code; an enforced stack shape wins. No test_works, test_case_1.

  • AAA: Arrange → Act → Assert, no interleaving. One logical assertion target per test

(several assert lines for the same outcome are fine). Never call the unit inside the assertion — store the result first. Delete arrange that the act doesn't use.

  • Parametrize: same logic over ≥2 inputs → one parametrized/table-driven test, not N

copy-pasted functions and not a for loop inside one test.

  • Properties over examples, where an invariant exists: if the unit has a nameable

invariant ("output stays sorted", "sums are conserved", "encode∘decode = identity" — rules/_generic/core.md), add one property test asserting it across generated inputs — the stack's generator library if PROJECT.md/rules name one (Hypothesis, fast-check, StreamData…), else a seeded loop over randomized + boundary inputs. Example tests pin points; the property pins the region between them. A second trigger: values that must be present but could be swapped for any others mark a property, not an example — state the invariant, generate them, keep the real boundaries as explicit cases.

  • Fixture scope: default to per-test (fresh) scope. Wider scope (module/session) only

for expensive read-only setup — never for fixtures that mutate state.

  • Mock discipline: patch at the call site, not the definition site. Assert call

count/args only when the side effect (not the return value) is the thing under test. Use the framework's teardown-safe mocking from the stack rules.

  • Isolation: no shared mutable module-level state; each test passes independently and in

any order. Filesystem → the framework's temp-dir helper, never hardcoded paths. Randomness → always seed. Time → freeze/inject, never read the real clock in assertions.

  • Assertion quality: assert specific values, not is not None / len > 0. Compare

floats with an approx/tolerance helper. For exceptions, assert both type and message (message must contain the offending value). A unit whose only visible effect is a developer-facing log line has no observable behaviour — record a coverage gap, never assert on log prose; logs read by operators or the business are contract, so assert the named event or level+key.


Phase 5 — Async test safety (where the language has async)

Load on demand: the target actually contains async code → read `reference/async-patterns.md` (async test shapes, the invariant checklist, orphaned-task cleanup, the mocked-clock hang). Short-circuit: a synchronous target skips this phase and that file entirely.

  • Use the framework's async test setup (per stack rules); don't block the loop.
  • Subscriber/callback failure is isolated — the engine/orchestrator must not propagate it.
  • Cancellation propagates: a cancellation signal must never be swallowed by a bare

catch-all except/catch.

  • Parallel fan-out: one task's failure must not kill its siblings (collect, don't crash).
  • Ordering invariants: state is persisted before events are emitted to subscribers.
  • No real sleeps/timers — inject or mock the clock; real sleep makes tests slow and flaky.
  • A mocked sleep/clock returns instantly, so an unbounded retry/poll loop under test spins at

full speed (a runaway CPU/memory hang). Guard such tests with the framework's per-test timeout and a real termination condition (e.g. a call-count ceiling) — never sleep(0), which is mocked too.


Phase 6 — Refactoring existing tests

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
2
7-day trend score
5

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/mik2win/foureyes/test/badge)](https://verified-skill.com/skills/mik2win/foureyes/test)

Something wrong with this skill or its page? Tell us.