regression-tester

Regression-tester:在代码重构后生成并运行回归测试以验证行为未发生变化,适用于在重构后确认未引入问题或现有测试覆盖不足时使用。触发词包括回归测试、重构验证、行为保持、前后测试、是否破坏了功能、重构安全网、快照测试。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
7

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "regression-tester":https://skillpi.com/zh/skills/deepskill-ad1a92b867b316c8cf2110c6e0d1e6371d7930969959efcddd34255e540b52af。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

Regression-tester:在代码重构后生成并运行回归测试以验证行为未发生变化,适用于在重构后确认未引入问题或现有测试覆盖不足时使用。触发词包括回归测试、重构验证、行为保持、前后测试、是否破坏了功能、重构安全网、快照测试。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: regression-tester
description: >-
  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.
license: Apache-2.0
compatibility: "Works with any test framework (Jest, Vitest, pytest, Go test). Requires git for diff analysis."
metadata:
  author: terminal-skills
  version: "1.0.0"
  category: development
  tags: ["regression-testing", "refactoring", "testing", "code-quality"]

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/**'
  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. Stash or commit current changes
  2. Checkout the pre-refactor code: git stash && git checkout main
  3. Run the new regression tests against the OLD code — they should all pass
  4. Return to refactored code: git checkout - && git stash pop
  5. Run the regression tests again — they should still all pass
  6. If any test fails on the refactored code but passed on the old code → regression found

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-01') returns Sunday with dayjs
   but returned Monday with moment (locale-dependent).
   Fix: Add dayjs.extend(weekOfYear) and set locale explicitly.

Example 2: Extracted Service Layer

User prompt:

I split our monolithic UserController into UserService + UserController. Did I break anything?

Agent output:

Analyzed refactoring: 1 file → 2 files
  Old: src/controllers/UserController.ts (342 lines)
  New: src/controllers/UserController.ts (98 lines) + src/services/UserService.ts (267 lines)

Public API surface: 6 endpoints unchanged (routes, params, response shapes)
Internal: Business logic extracted to UserService, controller delegates

Generated 22 regression tests:
  POST /users — creation with valid data, duplicate email, missing fields
  GET /users/:id — existing user, non-existent (404), invalid ID format
  PUT /users/:id — partial update, full update, unauthorized (403)
  DELETE /users/:id — soft delete, already deleted, cascade check
  GET /users — pagination, filtering, sorting, empty result

Results: 22/22 passed on both old and new code ✓
No regressions detected. Refactoring is safe.

Guidelines

  • Test behavior, not implementation — don't assert on internal method calls
  • Run tests against BOTH old and new code to confirm equivalence
  • Flag intentional behavior changes separately from regressions
  • Focus test generation on the changed code, not the entire codebase
  • Include edge cases that the original code may not have tested
  • For database-touching code, use transactions that roll back after each test
  • If the refactoring changes performance characteristics, add benchmark comparisons
  • Keep regression tests permanent — they protect against future changes too

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值88/100

亮点

  • 解决代码重构后验证行为一致性的核心痛点,适用于广泛开发场景
  • 提供从变更分析到测试生成再到双向验证的完整闭环流程
触发精准92/100

亮点

  • 触发词覆盖全面且边界清晰,能有效识别用户重构验证需求
结构规范90/100

亮点

  • 五步式结构清晰,每步有具体操作和出口条件
  • 包含两个高质量端到端示例,frontmatter 完整规范
执行可靠88/100

亮点

  • 工具链明确(git + 主流测试框架),参数示例准确
  • 覆盖主要异常场景,关键操作有上下文说明
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 46 行

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。