Skip to content
Agentmart
Submit a tool

add-regression-test

After a bug fix lands (or is staged), generate a regression test that fails on the pre-fix code and passes on the post-fix code — pinning the bug so it can't…

Skill by Acauhi99

IndexedMIT★ 1
Write a review

Chalk Labs

Need help deploying add-regression-test?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/acauhi99-add-regression-test

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

After a bug fix lands (or is staged), generate a regression test that fails on the pre-fix code and passes on the post-fix code — pinning the bug so it can't silently return. Walks the agent through reproducing the failure first (against the pre-fix state via `git stash` or temporary revert), writing the assertion that captures it, then verifying the test goes red without the fix and green with it. Trigger phrases — "add a regression test", "pin this bug", "write a test for the fix", "/add-regression-test", "lock in this bug fix", "make sure this doesn't come back", or invoke automatically after a /fix-bug session that produced a code fix. Skip for — fixes whose behavior change is already covered by existing passing tests, pure refactors with no behavior delta, fixes to test code itself, and unreproducible heisenbugs.

Use cases: testing, writing, agent-building

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/add-regression-test

What's inside

Skill name
add-regression-test
Description
After a bug fix lands (or is staged), generate a regression test that fails on the pre-fix code and passes on the post-fix code — pinning the bug so it can't silently return. Walks the agent through reproducing the failure first (against the pre-fix state via `git stash` or temporary revert), writing the assertion that captures it, then verifying the test goes red without the fix and green with it. Trigger phrases — "add a regression test", "pin this bug", "write a test for the fix", "/add-regression-test", "lock in this bug fix", "make sure this doesn't come back", or invoke automatically after a /fix-bug session that produced a code fix. Skip for — fixes whose behavior change is already covered by existing passing tests, pure refactors with no behavior delta, fixes to test code itself, and unreproducible heisenbugs.
License
MIT
Compatibility
opencode
Metadata
source: Adapted from AgentSystemLabs/core (MIT) · requires_codegraph: true
Instructions
139 lines in SKILL.md · view on GitHub

Files (2)

  • SKILL.md
  • reproduction-modes.md · references/

SKILL.md (first lines)

> **Tool mapping (OpenCode):** This skill uses:
> - `question` tool for user prompts (not `AskUserQuestion`)
> - `task` tool for subagents (not `Agent` or `Task` subagent syntax)
> - `skill({ name: "..." })` to load other skills (not `Skill(skill="...", args="...")`)
> - `codegraph_explore`, `codegraph_search`, `codegraph_context` for codebase exploration (preferred)
> - `todowrite` for phase/progress tracking
> - `grep`, `glob`, `read`, `bash` as fallback when `.codegraph/` is not initialized
>
> **Context rule:** This skill supersedes any prior skill instructions. Follow ONLY these instructions now. Read the user's goal and any mode/include/skip from the conversation context.

Read `mode=`, `include=`, and `skip=` from the conversation context. Default to the mode specified in this skill if not provided.

# Add Regression Test

A regression test is only valuable if it would have failed before the fix and passes after. Anything else is a confidence test pretending to be a regression test. The whole skill is built around proving both halves.

---

## Phase 1 — Identify the Fix

Use `todowrite` to mark this phase as in_progress. Mark it completed when done.

Determine what changed:

- If the fix is staged or committed but not pushed: `git diff <base>..HEAD -- <files>` and `git log <base>..HEAD --oneline`.
- If the fix is in the working tree: `git diff` (unstaged) plus `git diff --cached` (staged).
- If the user names a commit: `git show <sha>`.

Read the changed code. Identify:
- The function / route / component the fix lives in
- The input shape that triggers the bug (from the diff context, the bug report, or the user)
- The expected externally-observable outcome (return value, DB row, HTTP response, emitted event, rendered DOM)

If the fix is purely structural (renames, refactor, reformatting) with no behavior delta — stop. Tell the user there is nothing to regression-test.

**Exit:** the bug's input shape and expected outcome are written down.

---

## Phase 2 — Detect Test Harness

Use `todowrite` to mark this phase as in_progress. Mark it completed when done.

Apply the harness-detection rules from `write-tests` (or use that skill's references file directly): config files, lockfile, scripts. If no harness exists, hand off to `skill({ name: "write-tests" })` Phase 3 to install one — do not introduce a runner here.

**Exit:** the runner command and the test-file convention are known.

---

## Phase 3 — Reproduce the Failure

Use `todowrite` to mark this phase as in_progress. Mark it completed when done.

This is the load-bearing step. **MANDATORY — READ [`references/reproduction-modes.md`](references/reproduction-modes.md)** before choosing a mode.

Pick one mode:

- **A. Fix is unstaged in working tree** → write the test, `git stash` only the fix files, run the test (must fail), `git stash pop`, run the test (must pass).
- **B. Fix is staged but not committed** → write the test, `git stash --keep-index` to set aside the test, then `git stash pop`-trick won't work cleanly; instead use mode C.
- **C. Fix is committed locally** → write the test on top, then `git revert --no-commit <fix-sha>` in a temporary worktree (or via `git stash` of the fix files), confirm the test fails, restore.
- **D. Fix is squashed into a larger commit and can't be cleanly isolated** → revert just the offending hunks via `git checkout <pre-fix-sha> -- <file>` in a worktree, confirm test fails, restore.

In every mode, the gate is the same: **the test must fail without the fix code present.** A test that passes both before and after is broken — go back and tighten the assertion.

**Exit:** the test failed against the pre-fix code with output that names the actual bug behavior (not "expected X, got undefined" — the failure message should resemble the original bug report).

---

## Phase 4 — Verify the Pass

Use `todowrite` to mark this phase as in_progress. Mark it completed when done.

Restore the fix, run the test. It must pass.

If it doesn't pass: either the assertion is wrong (too strict, asserting unrelated behavior) or the fix is incomplete. Surface to the user — do not loosen the assertion to make it green.

**Exit:** test passes with the fix in place.

---

## Phase 5 — Wire It In

Use `todowrite` to mark this phase as in_progress. Mark it completed when done.

- Place the test in the project's convention (colocated `<name>.test.ts`, `tests/`, `__tests__/`, etc. — match the nearest sibling).
- Name it after the bug's *symptom*, not the fix: `it("returns 404 when slug contains uppercase letters")`, not `it("normalizes slug case")`. The next reader needs to recognize the bug from the test name.
- If a bug tracker reference exists (issue #, ticket id), include it in a one-line comment above the test.

Run the full suite — the new test plus its neighbors must all pass.

**Exit:** test is in place; full suite is green.

---

## Phase 6 — Report

Use `todowrite` to mark this phase as in_progress. Mark it completed when done.

```
Regression test added: <path>:<line>
  Pinned: <one-line bug description>
  Verified failed against: <pre-fix sha or "stashed working tree">
  Verified passes against: HEAD
  Run: <project test command>
```

---

## NEVER

- **NEVER skip the failure verification.**
  **Instead:** stash, revert, or use a temporary worktree to confirm the test fails without the fix, every time.
  **Why:** a test written against a fix that's already in the file passes by construction. Without the failing-state proof, you have a confidence test, not a regression test — it cannot detect the bug coming back.

- **NEVER assert on internal call sequences or implementation details.**
  **Instead:** assert on the externally-observable outcome — return value, DB row state, HTTP response, rendered DOM, emitted event.
  **Why:** implementation-coupled tests pass for the wrong reasons and break on every refactor. The bug is observable; the test should be too.

- **NEVER loosen an assertion to make a failing test pass.**

From Acauhi99/opencode-agent-system, MIT.

More from Acauhi99/opencode-agent-system

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
May 24, 2026 (5 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from Acauhi99

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get add-regression-test running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying add-regression-test?

CallGet help
Cite this page

add-regression-test skill. Agent Mart. https://agentmart.dev/skills/acauhi99-add-regression-test (last updated 2026-10-24)