agentleFS
jhonatan-oliveiradevjhonatan-oliveiradev/agent-skills/skills/building-regression-tests/SKILL.md

building-regression-tests

Skill1 starsChanged 3 months agoMITView on GitHub

Use when a bug, outage, production defect, or failed higher-level test must become a durable automated guard before the implementation is changed.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    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:

    Write one test that fails on the current buggy implementation.

    line 15
  2. Distinctive:

    Run the new test and the relevant surrounding suite.

    line 17
  3. Distinctive:

    If the bug suggests a family of nearby failures, add only the distinct cases justified by the same root cause.

    line 18
  4. Distinctive:

    Keep the regression test after the fix.

    line 19
  5. Distinctive:

    avoid broad fixtures and unrelated assertions.

    line 28
  6. Distinctive:

    Do not call an intermittently failing test a regression guard.

    line 34
  7. Distinctive:

    Before declaring the bug fixed, prove the full cycle:

    line 37
  8. Distinctive:

    If RED was never observed, the test has not demonstrated that it guards this regression.

    line 43

≈ “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

Building Regression Tests

Core principle

A known defect is not safely fixed until an automated test can reproduce it and fail for the right reason before the fix. Keep that test at the narrowest layer that still proves the broken contract.

Regression workflow

  1. Reproduce the defect from a concrete report, failing test, log, trace, request, data shape, or user sequence. Do not encode a guessed failure mode.
  2. State the violated contract in observable terms: expected output, persisted state, emitted event, UI behavior, error handling, authorization, or side effect.
  3. Find the narrowest layer that can reproduce the real defect. A bug found by E2E may belong in an integration or unit regression test once the failing boundary is understood.
  4. Write one test that fails on the current buggy implementation. Confirm the failure message and evidence correspond to the defect, not a setup error.
  5. Apply the minimal production fix.
  6. Run the new test and the relevant surrounding suite. The new test must turn GREEN without weakening its assertion.
  7. If the bug suggests a family of nearby failures, add only the distinct cases justified by the same root cause.
  8. Keep the regression test after the fix. Remove it only if the protected behavior disappears or another test demonstrably supersedes the same contract.

Test quality

A regression test should:

  • reproduce the smallest meaningful failing case;
  • assert behavior, not the implementation detail you plan to change;
  • be deterministic and isolated;
  • have a name that describes the protected contract;
  • fail if the bug is intentionally reintroduced;
  • avoid broad fixtures and unrelated assertions.

Higher-level discoveries

When a broad system or browser test exposes a defect, first preserve the evidence that proves the user-visible failure. Then trace the defect downward. If a smaller test can reproduce the same root cause, add the durable regression there and keep the broad test only when it proves additional integration or journey value.

Flakiness

Do not call an intermittently failing test a regression guard. If the same code can produce pass and fail outcomes, isolate nondeterminism before relying on the test as a release signal.

Verification

Before declaring the bug fixed, prove the full cycle:

  1. the new test fails against the buggy behavior;
  2. the production fix is applied;
  3. the same test passes;
  4. relevant neighboring tests still pass.

If RED was never observed, the test has not demonstrated that it guards this regression.

References

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.