Skip to content
Agentmart
Submit a tool

ai-regression-testing

AI 辅助开发的回归测试策略。包括无数据库依赖的沙盒模式 API 测试、自动化缺陷检查工作流,以及用于捕捉同一模型编写并评审代码时产生的 AI 盲区的模式。

Skill by lza6

IndexedApache-2.0★ 8
Write a review

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/lza6-ai-regression-testing

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

AI 辅助开发的回归测试策略。包括无数据库依赖的沙盒模式 API 测试、自动化缺陷检查工作流,以及用于捕捉同一模型编写并评审代码时产生的 AI 盲区的模式。

Use cases: backend, testing

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/ai-regression-testing

What's inside

Skill name
ai-regression-testing
Description
AI 辅助开发的回归测试策略。包括无数据库依赖的沙盒模式 API 测试、自动化缺陷检查工作流,以及用于捕捉同一模型编写并评审代码时产生的 AI 盲区的模式。
License
Apache-2.0
Instructions
382 lines in SKILL.md · view on GitHub

Before installing

  • Instructions call the network

Files (1)

  • SKILL.md

SKILL.md (first lines)

# AI 回归测试 (AI Regression Testing)

专门为 AI 辅助开发设计的测试模式。在这种开发模式下,同一个模型既编写代码又评审代码,往往会产生系统性的盲区,而这些盲区只能通过自动化测试来捕捉。

## 何时激活

- AI 代理(如 Claude Code, Cursor, Codex)修改了 API 路由或后端逻辑。
- 发现并修复了一个缺陷 —— 需要防止该缺陷再次引入。
- 项目具有沙盒/模拟 (Sandbox/Mock) 模式,可用于无数据库依赖的测试。
- 代码更改后运行 `/bug-check` 或类似的评审命令。
- 存在多个代码路径(如沙盒 vs 生产、特性标志等)。

## 核心问题

当 AI 编写代码并随后评审自己的工作时,它会在两个步骤中携带相同的假设。这会产生一种可预测的失败模式:

```
AI 编写修复代码 → AI 评审修复代码 → AI 说“看起来正确” → 缺陷仍然存在
```

**真实案例**(在生产环境中观察到):

```
修复 1:在 API 响应中添加了 notification_settings
  → 忘记将其添加到 SELECT 查询中
  → AI 进行了评审但未能发现(相同的盲区)

修复 2:将其添加到了 SELECT 查询中
  → 出现 TypeScript 构建错误(生成的类型中没有该列)
  → AI 评审了修复 1,但未捕捉到 SELECT 问题

修复 3:更改为 SELECT *
  → 修复了生产路径,但忘记了沙盒路径
  → AI 再次评审并再次遗漏(第 4 次发生)

修复 4:测试在第一次运行时立即捕捉到了问题:通过 (PASS)!
```

该模式:**沙盒/生产路径的不一致** 是 AI 引入的头号回归问题。

## 沙盒模式 API 测试

大多数具有“AI 友好”架构的项目都有沙盒/模拟模式。这是实现快速、无数据库 API 测试的关键。

### 配置 (Vitest + Next.js App Router)

```typescript
// vitest.config.ts
import { defineConfig } from "vitest/config";
import path from "path";

export default defineConfig({
  test: {
    environment: "node",
    globals: true,
    include: ["__tests__/**/*.test.ts"],
    setupFiles: ["__tests__/setup.ts"],
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "."),
    },
  },
});
```

```typescript
// __tests__/setup.ts
// 强制开启沙盒模式 —— 无需数据库
process.env.SANDBOX_MODE = "true";
process.env.NEXT_PUBLIC_SUPABASE_URL = "";
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY = "";
```

### Next.js API 路由测试辅助函数

```typescript
// __tests__/helpers.ts
import { NextRequest } from "next/server";

export function createTestRequest(
  url: string,
  options?: {
    method?: string;
    body?: Record<string, unknown>;
    headers?: Record<string, string>;
    sandboxUserId?: string;
  },
): NextRequest {
  const { method = "GET", body, headers = {}, sandboxUserId } = options || {};
  const fullUrl = url.startsWith("http") ? url : `http://localhost:3000${url}`;
  const reqHeaders: Record<string, string> = { ...headers };

  if (sandboxUserId) {
    reqHeaders["x-sandbox-user-id"] = sandboxUserId;
  }

  const init: { method: string; headers: Record<string, string>; body?: string } = {
    method,
    headers: reqHeaders,
  };

  if (body) {
    init.body = JSON.stringify(body);
    reqHeaders["content-type"] = "application/json";
  }

  return new NextRequest(fullUrl, init);
}

export async function parseResponse(response: Response) {
  const json = await response.json();
  return { status: response.status, json };
}
```

### 编写回归测试

核心原则:**为已发现的缺陷编写测试,而不是为正常工作的代码编写测试**。

From lza6/Claude-code-cli-config, Apache-2.0.

More from lza6/Claude-code-cli-config

Signals

Stars
8
Forks
1
Open issues
0
Last commit (this folder)
Apr 13, 2026 (6 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from lza6

Cite this page

ai-regression-testing skill. Agent Mart. https://agentmart.dev/skills/lza6-ai-regression-testing (last updated 2026-10-24)