Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

regression-tester

БесплатноБез исполняемых скриптовНе проверен

Generate and run regression tests after code refactoring to verify behavior is preserved. Use when someone has refactored code and needs to confirm nothing…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Regression Tester

Overview

This skill creates a safety net around refactoring work. It analyzes what changed, identifies the public API surface and behavior contracts of the refactored code, generates targeted regression tests that verify behavior is preserved, and runs them against both the old and new implementations to confirm equivalence.

Instructions

Step 1: Analyze the Refactoring Scope

  1. Get the diff: git diff main...HEAD or compare specific commits

  2. Categorize changes:

    • Signature changes — function/method names, parameters, return types
    • Internal restructuring — same API, different implementation
    • Extracted modules — code moved to new files/functions
    • Behavioral changes — intentional behavior modifications (flag these!)
  3. Identify the behavior contract for each changed unit:

    • What inputs does it accept?
    • What outputs does it produce?
    • What side effects does it have? (DB writes, API calls, file I/O)
    • What errors does it throw and under what conditions?

Step 2: Check Existing Coverage

  1. Run existing tests: npm test / pytest / go test ./...
  2. If tests pass, check coverage of the refactored code:
    npx jest --coverage --collectCoverageFrom='src/refactored-module/**'   # Jest
    npx vitest run --coverage                                              # Vitest (needs @vitest/coverage-v8)
    pytest --cov=billing --cov-branch                                      # pytest-cov
    go test -coverprofile=cover.out ./... && go tool cover -func=cover.out # Go
    
  3. Identify untested code paths in the refactored area:
    • Uncovered branches (if/else, switch cases, error handling)
    • Edge cases (empty input, null, boundary values, concurrent access)
    • Integration points (function calls to other modules)

Step 3: Generate Regression Tests

Create tests that verify behavior, not implementation:

  1. Input/output tests — For pure functions, test that same inputs produce same outputs
  2. Contract tests — For APIs, verify request/response shape and status codes
  3. Side-effect tests — For stateful code, verify correct DB operations, events emitted
  4. Error path tests — Verify error handling behavior is preserved
  5. Boundary tests — Empty arrays, zero values, maximum lengths, unicode strings

Test structure:

describe('[ModuleName] regression', () => {
  describe('preserved behavior', () => {
    // Tests that MUST pass identically before and after refactor
  });
  describe('edge cases', () => {
    // Tests for boundary conditions
  });
  describe('error handling', () => {
    // Tests for error paths
  });
});

Step 4: Verify Against Old Implementation

  1. Write the regression tests as new files; they are untracked, so they survive branch switches
  2. Check out the pre-refactor code in a separate worktree so your working tree is untouched: git worktree add ../app-baseline main (use the merge base if main has moved: git merge-base main HEAD)
  3. Copy the new test files into that worktree, install dependencies there, and run them — against the OLD code they should all pass (a failure means the test encodes a wrong assumption, fix the test)
  4. Run the same tests in your refactored working tree — they should still all pass
  5. If any test fails on the refactored code but passed on the old code → regression found
  6. Clean up: git worktree remove ../app-baseline

Step 5: Report

Regression Test Report
═══════════════════════
Refactored: src/services/billing.ts (4 functions, 187 lines changed)

Tests generated: 24
  Passed (old code): 24/24  ✓
  Passed (new code): 23/24  ✗

❌ REGRESSION FOUND:
  test: "calculates prorated amount for mid-cycle upgrade"
  Expected: 14.52
  Received: 14.50
  Location: src/services/billing.ts:89 (rounding changed from Math.ceil to Math.round)

✓ All other behavior preserved.

Examples

Example 1: Refactored Utility Functions

User prompt:

I refactored our date utility module from moment.js to dayjs. Can you make sure nothing broke?

Agent actions:

git diff main -- src/utils/dates.ts

Agent analysis:

Refactoring scope: src/utils/dates.ts
  - Import changed: moment → dayjs
  - 8 exported functions, all signatures preserved
  - Internal parsing logic changed

Existing test coverage: 3 tests covering 2 of 8 functions (25%)

Generated 18 regression tests covering:
  ✓ formatDate() — 4 formats × 3 edge cases (null, invalid, timezone)
  ✓ diffInDays() — positive, negative, same day, DST boundary
  ✓ startOfWeek() — Sunday vs Monday locale, year boundary
  ✓ parseISO() — valid, invalid, with/without timezone offset
  ✓ isBusinessDay() — weekday, Saturday, Sunday, holiday handling
  ✓ addBusinessDays() — skip weekends, cross month boundary

Results against old code (moment.js): 18/18 passed
Results against new code (dayjs):     17/18 passed

❌ Regression: startOfWeek('2024-01-03') returns Sunday 2023-
Полный SKILL.md на GitHub

Установить regression-tester в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл regression-tester?

Generate and run regression tests after code refactoring to verify behavior is preserved. Use when someone has refactored code and needs to confirm nothing broke — especially when existing test coverage is insufficient. Trigger words: regression test, refactor validation, behavior preservation, before/after test, did I break anything, refactoring safety net, snapshot test.

Как установить скилл regression-tester?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл regression-tester запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить regression-tester с