Testing

Regression Test Planner

Given a bug that shipped, design the minimal set of tests that would have caught it, plus the nearby cases it implies are also at risk.

When to use this

  • After a production incident or a bug report, to close the gap that let it ship.
  • Before a risky refactor, to build a safety net for behavior that must not change.
  • Not for routine feature testing -- use test-writer for that; this is specifically about closing a demonstrated gap.

The skill file

Copy this verbatim. It's written in the SKILL.md format (YAML frontmatter + markdown instructions) that Claude Code, and increasingly other agent tools, read directly.

SKILL.md
---
name: regression-test-planner
description: Given a bug report or incident, design the minimal test (or small set of tests) that would have caught it before it shipped, plus nearby cases the same class of bug threatens. Use after a bug is found, to prevent recurrence.
---

# Regression Test Planner

## Step 1: pin down the exact failure

State the precise input/sequence of events that caused the bug, and the
wrong output it produced. If this isn't precise, the regression test won't
actually pin the bug down.

## Step 2: write the direct regression test

The smallest test that fails on the buggy code and passes on the fix. This
is the non-negotiable minimum.

## Step 3: generalize, carefully

Ask: what's the *class* of input this bug belongs to, and are there
sibling cases that share the same root cause but weren't reported yet?
(e.g. if the bug was "negative quantity causes overflow," check zero and
the type's max value too.) Add 1-3 more tests for genuinely related cases
-- don't sprawl into unrelated coverage.

## Step 4: check for the same bug elsewhere

If the root cause is a pattern (e.g. a specific unsafe cast, a missing
null check pattern), grep for the same pattern in sibling code. Report
other locations even if you don't fix them here.

## Output

The regression test(s), a one-line description of the bug class they
guard against, and a list of any sibling locations that share the same
risk and should be checked separately.

Installing it elsewhere

The frontmatter/body split above is Claude Code's convention. Here's how to carry the same instructions into other tools:

Claude Code
.claude/skills/regression-test-planner/SKILL.md

Save the file below verbatim (frontmatter included) at that path, project-local or in ~/.claude/skills/ for a user-level skill. Claude Code loads the name/description pair to decide when to pull it in, or you invoke it directly as /regression-test-planner.

Cursor
.cursor/rules/regression-test-planner.mdc

Convert the YAML frontmatter to Cursor's rule format (description, globs, alwaysApply: false) and keep the markdown body as the rule content. Cursor surfaces it by description match, same idea as Claude Code's auto-load.

Codex CLI / Copilot
AGENTS.md

Codex CLI (and increasingly other agentic CLIs) read AGENTS.md at the repo root as always-on instructions. Paste the markdown body under a heading like ## {title}; for GitHub Copilot's coding agent, the equivalent file is .github/copilot-instructions.md.

Windsurf
.windsurfrules

Append the markdown body to .windsurfrules at the repo root. Windsurf treats the whole file as always-on context, so keep only the instructions you want applied on every request.

Where this goes wrong
  • Writing a regression test so specific it only catches the exact reported input, missing the whole class of bug.
  • Over-generalizing into a large new test suite instead of the minimal set that actually closes the gap.
  • Not checking whether the same root-cause pattern exists elsewhere in the codebase.