
Ai Regression Testing
- 5.4k installs
- 238k repo stars
- Updated August 5, 2026
- affaan-m/everything-claude-code
ai-regression-testing is an agent skill that runs regression tests to catch AI self-review blind spots via sandbox-mode Vitest API tests and mandatory bug-check gates.
About
The ai-regression-testing skill defines regression test patterns for AI-assisted development where the same model writes and reviews code, creating systematic blind spots only automated tests can catch. Activate when AI agents change API routes or backend logic, after bugs are fixed and need recurrence prevention, when sandbox or mock modes enable DB-free API tests, before running /bug-check reviews, or when sandbox versus production code paths diverge. Core failure loop: AI writes a fix, AI reviews it, declares correct, bug remains. Production examples show notification_settings added without SELECT updates, sandbox paths omitted after production fixes, and tests finally catching the fourth recurrence. Vitest plus Next.js App Router setup forces SANDBOX_MODE with createTestRequest helpers. Write tests for discovered bugs not hypothetical coverage, assert API response shape, parity test sandbox versus production fields, and run npm run test and build as mandatory first bug-check steps before AI review.
- Targets AI blind spots when the same model writes fixes and reviews them without catching shared assumptions.
- Vitest sandbox-mode API tests with createTestRequest helpers avoid database dependencies under one second.
- Regression tests name real bugs (BUG-R1) and assert response shape plus sandbox versus production field parity.
- Bug-check workflow runs npm run test and build before AI review, then proposes tests per fixed bug.
- Documents four recurring patterns: path mismatch, SELECT omissions, error state leaks, and missing optimistic rollback.
Ai Regression Testing by the numbers
- 5,449 all-time installs (skills.sh)
- +231 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #267 of 2,153 Testing & QA skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
ai-regression-testing capabilities & compatibility
- Capabilities
- vitest sandbox mode setup without database depen · api response contract assertions with required_f · sandbox versus production parity regression test · bug check workflow with test and build gates bef · named regression tests for recurring ai introduc
- Works with
- vercel · supabase
- Use cases
- testing · api development · debugging
What ai-regression-testing says it does
同じモデルがコードを書いてレビューする場合、自動化されたテストのみが捕捉できる体系的なブラインドスポットが生まれます。
パターン:**サンドボックス/本番パスの不一致**が AI が導入するリグレッションの第 1 位。
重要な原則:**機能するコードのためではなく、見つかったバグのためにテストを書く**。
npx skills add https://github.com/affaan-m/everything-claude-code --skill ai-regression-testingAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 5.4k |
|---|---|
| repo stars | ★ 238k |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 5, 2026 |
| Repository | affaan-m/everything-claude-code ↗ |
How do I stop the same AI model from repeatedly missing sandbox versus production mismatches, incomplete SELECT clauses, and API shape regressions it introduced and then approved?
Regression tests for AI-assisted API work: sandbox-mode Vitest, bug-check gates, and blind-spot patterns when the same model writes and reviews code.
Who is it for?
Next.js or API projects with sandbox or mock modes where Claude Code, Cursor, or Codex agents edit backend routes and need recurrence prevention.
Skip if: Skip when there is no sandbox or mock path, no automated test runner, or the task is unrelated to API regression prevention.
When should I use this skill?
An AI agent changed API routes, a bug was fixed and needs a regression test, /bug-check runs after edits, or sandbox and production paths may diverge.
What you get
Fast DB-free Vitest tests that lock each discovered bug, mandatory test and build gates before AI review, and organic regression coverage where bugs actually occurred.
- Sandbox-mode API regression test files
- REQUIRED_FIELDS contract lists per route
- Bug-check command integrating test and build gates
By the numbers
- Sandbox tests target under one second total runtime
- Four documented AI regression patterns with priority rankings
- Three of four observed regressions were sandbox versus production mismatches
Files
AI リグレッションテスト
AI 支援開発のために特別に設計されたテストパターン。同じモデルがコードを書いてレビューする場合、自動化されたテストのみが捕捉できる体系的なブラインドスポットが生まれます。
起動タイミング
- AI エージェント(Claude Code、Cursor、Codex)が API ルートまたはバックエンドロジックを修正した場合
- バグが見つかり修正された — 再発を防ぐ必要がある
- プロジェクトに DB フリーテストに活用できるサンドボックス/モックモードがある場合
- コード変更後に
/bug-checkまたは同様のレビューコマンドを実行する場合 - 複数のコードパスが存在する場合(サンドボックス対本番、機能フラグなど)
コアの問題
AI がコードを書いてその後自分の作業をレビューする場合、両方のステップに同じ前提を持ち込みます。これにより予測可能な障害パターンが生まれます:
AI が修正を書く → AI が修正をレビューする → AI が「正しく見える」と言う → バグはまだ存在する実際の例(本番で観察された):
修正 1: API レスポンスに notification_settings を追加
→ SELECT クエリに追加するのを忘れた
→ AI がレビューして見逃した(同じブラインドスポット)
修正 2: SELECT クエリに追加
→ TypeScript ビルドエラー(生成された型に列がない)
→ AI が修正 1 をレビューしたが SELECT の問題を捕捉できなかった
修正 3: SELECT * に変更
→ 本番パスを修正、サンドボックスパスを忘れた
→ AI がレビューして再び見逃した(4 回目の発生)
修正 4: テストが最初の実行で即座に捕捉 PASS:パターン:サンドボックス/本番パスの不一致が AI が導入するリグレッションの第 1 位。
サンドボックスモード API テスト
AI フレンドリーなアーキテクチャを持つほとんどのプロジェクトにはサンドボックス/モックモードがあります。これが高速な DB フリー API テストの鍵です。
セットアップ(Vitest + Next.js App Router)
// 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, "."),
},
},
});// __tests__/setup.ts
// サンドボックスモードを強制 — データベース不要
process.env.SANDBOX_MODE = "true";
process.env.NEXT_PUBLIC_SUPABASE_URL = "";
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY = "";Next.js API ルート用テストヘルパー
// __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 };
}リグレッションテストの作成
重要な原則:機能するコードのためではなく、見つかったバグのためにテストを書く。
// __tests__/api/user/profile.test.ts
import { describe, it, expect } from "vitest";
import { createTestRequest, parseResponse } from "../../helpers";
import { GET, PATCH } from "@/app/api/user/profile/route";
// コントラクトを定義 — レスポンスに必ず存在すべきフィールド
const REQUIRED_FIELDS = [
"id",
"email",
"full_name",
"phone",
"role",
"created_at",
"avatar_url",
"notification_settings", // ← バグで欠落が判明した後に追加
];
describe("GET /api/user/profile", () => {
it("すべての必須フィールドを返す", async () => {
const req = createTestRequest("/api/user/profile");
const res = await GET(req);
const { status, json } = await parseResponse(res);
expect(status).toBe(200);
for (const field of REQUIRED_FIELDS) {
expect(json.data).toHaveProperty(field);
}
});
// リグレッションテスト — この正確なバグが AI によって 4 回導入された
it("notification_settings が undefined でない(BUG-R1 リグレッション)", async () => {
const req = createTestRequest("/api/user/profile");
const res = await GET(req);
const { json } = await parseResponse(res);
expect("notification_settings" in json.data).toBe(true);
const ns = json.data.notification_settings;
expect(ns === null || typeof ns === "object").toBe(true);
});
});サンドボックス/本番のパリティテスト
最も一般的な AI リグレッション:本番パスを修正してサンドボックスパスを忘れる(またはその逆)。
// サンドボックスレスポンスが期待されるコントラクトと一致することをテスト
describe("GET /api/user/messages(会話リスト)", () => {
it("サンドボックスモードで partner_name を含む", async () => {
const req = createTestRequest("/api/user/messages", {
sandboxUserId: "user-001",
});
const res = await GET(req);
const { json } = await parseResponse(res);
// これは partner_name が本番パスに追加されたが
// サンドボックスパスに追加されなかったバグを捕捉した
if (json.data.length > 0) {
for (const conv of json.data) {
expect("partner_name" in conv).toBe(true);
}
}
});
});バグチェックワークフローへのテスト統合
カスタムコマンド定義
<!-- .claude/commands/bug-check.md -->
# バグチェック
## ステップ 1: 自動テスト(必須、スキップ不可)
コードレビューの前に必ずこれらのコマンドを先に実行する:
npm run test # Vitest テストスイート
npm run build # TypeScript 型チェック + ビルド
- テストが失敗した場合 → 最高優先度のバグとして報告する
- ビルドが失敗した場合 → 型エラーを最高優先度として報告する
- 両方がパスした場合のみステップ 2 に進む
## ステップ 2: コードレビュー(AI レビュー)
1. サンドボックス / 本番パスの一貫性
2. API レスポンスの形状がフロントエンドの期待と一致するか
3. SELECT 句の完全性
4. ロールバック付きのエラー処理
5. オプティミスティックアップデートのレース条件
## ステップ 3: 修正されたバグごとにリグレッションテストを提案するワークフロー
ユーザー: "バグチェックして" (or "/bug-check")
│
├─ ステップ 1: npm run test
│ ├─ FAIL → バグが機械的に発見された(AI の判断不要)
│ └─ PASS → 続行
│
├─ ステップ 2: npm run build
│ ├─ FAIL → 型エラーが機械的に発見された
│ └─ PASS → 続行
│
├─ ステップ 3: AI コードレビュー(既知のブラインドスポットを念頭に)
│ └─ 発見事項が報告される
│
└─ ステップ 4: 各修正に対してリグレッションテストを書く
└─ 次のバグチェックで修正が壊れるか捕捉する一般的な AI リグレッションパターン
パターン 1: サンドボックス/本番パスの不一致
頻度: 最も一般的(4 つのリグレッションのうち 3 つで観察)
// 失敗: AI が本番パスのみにフィールドを追加する
if (isSandboxMode()) {
return { data: { id, email, name } }; // 新しいフィールドが欠落
}
// 本番パス
return { data: { id, email, name, notification_settings } };
// 成功: 両方のパスが同じ形状を返す必要がある
if (isSandboxMode()) {
return { data: { id, email, name, notification_settings: null } };
}
return { data: { id, email, name, notification_settings } };捕捉するためのテスト:
it("サンドボックスと本番が同じフィールドを返す", async () => {
// テスト環境では、サンドボックスモードが強制的に ON になる
const res = await GET(createTestRequest("/api/user/profile"));
const { json } = await parseResponse(res);
for (const field of REQUIRED_FIELDS) {
expect(json.data).toHaveProperty(field);
}
});パターン 2: SELECT 句の省略
頻度: 新しい列を追加する際の Supabase/Prisma で一般的
// 失敗: 新しい列がレスポンスに追加されたが SELECT に含まれていない
const { data } = await supabase
.from("users")
.select("id, email, name") // notification_settings がここにない
.single();
return { data: { ...data, notification_settings: data.notification_settings } };
// → notification_settings は常に undefined
// 成功: SELECT * を使用するか明示的に新しい列を含める
const { data } = await supabase
.from("users")
.select("*")
.single();パターン 3: エラー状態の漏洩
頻度: 既存のコンポーネントにエラー処理を追加する場合に中程度
// 失敗: エラー状態が設定されたが古いデータがクリアされていない
catch (err) {
setError("Failed to load");
// reservations は前のタブのデータをまだ表示している!
}
// 成功: エラー時に関連する状態をクリアする
catch (err) {
setReservations([]); // 古いデータをクリア
setError("Failed to load");
}パターン 4: 適切なロールバックなしのオプティミスティックアップデート
// 失敗: 失敗時のロールバックなし
const handleRemove = async (id: string) => {
setItems(prev => prev.filter(i => i.id !== id));
await fetch(`/api/items/${id}`, { method: "DELETE" });
// API が失敗した場合、アイテムは UI から消えるが DB にはまだある
};
// 成功: 前の状態をキャプチャして失敗時にロールバックする
const handleRemove = async (id: string) => {
const prevItems = [...items];
setItems(prev => prev.filter(i => i.id !== id));
try {
const res = await fetch(`/api/items/${id}`, { method: "DELETE" });
if (!res.ok) throw new Error("API error");
} catch {
setItems(prevItems); // ロールバック
alert("削除に失敗しました");
}
};戦略: バグが見つかった場所でテストする
100% カバレッジを目指さない。代わりに:
/api/user/profile でバグ発見 → プロファイル API のテストを書く
/api/user/messages でバグ発見 → メッセージ API のテストを書く
/api/user/favorites でバグ発見 → お気に入り API のテストを書く
/api/user/notifications でバグなし → テストを書かない(まだ)AI 開発でこれが機能する理由:
1. AI は同じカテゴリのミスを繰り返す傾向がある 2. バグは複雑な領域(認証、マルチパスロジック、状態管理)にクラスタリングする 3. 一度テストされると、その正確なリグレッションは再び発生できない 4. テスト数はバグ修正とともに有機的に増加する — 無駄な努力なし
クイックリファレンス
| AI リグレッションパターン | テスト戦略 | 優先度 |
|---|---|---|
| サンドボックス/本番の不一致 | サンドボックスモードで同じレスポンス形状をアサート | 高 |
| SELECT 句の省略 | レスポンス内のすべての必須フィールドをアサート | 高 |
| エラー状態の漏洩 | エラー時の状態クリーンアップをアサート | 中 |
| ロールバック欠如 | API 失敗時に状態が復元されることをアサート | 中 |
| 型キャストが null をマスク | フィールドが undefined でないことをアサート | 中 |
DO / DON'T
DO:
- バグを見つけた後すぐにテストを書く(可能であれば修正前に)
- 実装ではなく API レスポンスの形状をテストする
- すべてのバグチェックの最初のステップとしてテストを実行する
- テストを高速に保つ(サンドボックスモードで合計 1 秒未満)
- 防ぐバグにちなんでテストに名前を付ける(例:「BUG-R1 リグレッション」)
DON'T:
- バグが一度もなかったコードのテストを書く
- 自動化されたテストの代替として AI の自己レビューを信頼する
- 「モックデータだから」という理由でサンドボックスパステストをスキップする
- ユニットテストで十分な時に統合テストを書く
- カバレッジのパーセンテージを目指す — リグレッション防止を目指す
Related skills
Forks & variants (1)
Ai Regression Testing has 1 known copy in the catalog totaling 1.4k installs. They canonicalize to this original listing.
- affaan-m - 1.4k installs
How it compares
Choose ai-regression-testing over generic unit-test skills when the risk is same-model AI write-and-review blind spots on API backends.
FAQ
Why do AI-written fixes still pass AI review?
The same model shares assumptions across write and review steps, so systematic blind spots like sandbox versus production path mismatches slip through unless automated tests assert response shape.
When should I write a regression test versus chasing coverage?
Write tests only where bugs were found, assert API response contracts, and name tests after the exact regression instead of aiming for percentage coverage on untouched routes.
What must run before AI code review in the bug-check workflow?
npm run test and npm run build are mandatory first steps; failed tests or type errors report as highest-priority bugs before step two AI review begins.
Is Ai Regression Testing safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.