agentleFS
itsmuskanagarwalitsmuskanagarwal/claude-pack/skills/characterization-tests/SKILL.md

characterization-tests

Skill0 starsChanged 4 months agoMITView on GitHub

Pin the CURRENT behavior of untested legacy code in tests before any modification. Use whenever code must change but has no tests, before refactors of legacy modules, when the user mentions "no tests", "afraid to touch", "regression", or when the code-archaeology plan requires a safety net. These tests assert what the code DOES, not what it should do.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    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:

    Place tests in __characterization__/ beside the module, named <module>.char.spec.ts (or language equivalent), so they are visibly distinct …

    line 29
  2. Distinctive:

    Run the whole suite. Any red test → the test is wrong.

    line 32

≈ “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
<!-- owner: Muskan, added: 2026-07-16, model: claude-sonnet-5, review: quarterly -->

Characterization Tests

Prime directive

The test suite must be green against the UNMODIFIED code. A characterization test that fails on current code is a wrong test, not a found bug. Found bugs get logged, not fixed, during this procedure.

Procedure

  1. Enumerate the public surface of the target module (exports, routes, handlers, selectors). Target: ≥ 80% of public functions get ≥ 1 test.
  2. For each entrypoint, derive input cases from: call sites (real usage first), boundary values, null/undefined/empty, and any oddities noted in archaeology findings.
  3. Discover actual behavior empirically: run the function/harness with the input, observe the real output, and write the assertion from the observation. Do not write assertions from reading the code alone — reading produces what you think it does; running produces what it does.
  4. Odd behavior gets a test with the comment format: // PINS CURRENT BEHAVIOR: <description>. Looks unintended; preserved // deliberately. See findings doc <link>. Do not "fix" without a ticket.
  5. Side effects: assert them with fakes/spies at the boundary (DB layer, HTTP client). Never mock the unit under test itself.
  6. Place tests in __characterization__/ beside the module, named <module>.char.spec.ts (or language equivalent), so they are visibly distinct from intent tests and can be retired after modernization.
  7. Run the whole suite. Any red test → the test is wrong; fix the test. Repeat until green. Report: functions covered / total, behaviors pinned, bugs logged (with file:line), inputs you could NOT exercise and why.

Anti-patterns (hard bans)

  • Asserting on implementation details (private state, call order) unless that IS the observable contract.
  • Tests that pass trivially (no assertion, assert(true), snapshot of everything). Every test names the behavior it pins.
  • "Improving" the code while writing tests. Zero production edits.

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.