Atlas / Skills / affaan-m / Ai Regression Testing

Ai Regression TestingSAFE

skills/affaan-m/ai-regression-testing

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

Verdict
SAFE
Grade
B
Trust score
89 /100
Version
—
Hosts
3 documented
License
MIT
Stars
262,423
01

Overview

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

Read from source at commit e9ca581a4f44OBSERVED · 2026-09-19
02

Host compatibility

What the documentation claims. We have not run a compatibility test.

HostStatusNotes
claude-codementioned
codexmentioned
cursormentioned
03

What it tells the agent

The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.

---
name: ai-regression-testing
description: AI 支援開発のためのリグレッションテスト戦略。データベース依存なしのサンドボックスモード API テスト、自動化されたバグチェックワークフロー、同じモデルがコードを書いてレビューする AI のブラインドスポットを捕捉するパターン。
origin: ECC
---

# 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)

```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 };
}
```

### リグレッションテストの作成

重要な原則:**機能するコードのためではなく、見つかったバグのためにテストを書く**。

```typescript
// __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 リグレッション:本番パスを修正してサンドボックスパスを忘れる(またはその逆)。

```typescript
// サンドボックスレスポンスが期待されるコントラクトと一致することをテスト
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);
      }
    }
  });
});
```

## バグチェックワークフローへのテスト統合

### カスタムコマンド定義

```markdown
<!-- .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 つで観察)

```typescript
// 失敗: AI が本番パスのみにフィールドを追加する
if (isSandboxMode()) {
  return { data: { id, email, name } };  // 新しいフィールドが欠落
}
// 本番パス
return { data: { id, email, name, notification_settings } };

// 成功: 両方のパスが同じ形状を返す必要がある
if (isSandboxMode()) {
  return { data: { id, email, name, notification_settings: 
04

Trust audit

SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.

LayerWhat it checksResult
L0Provenance & inventoryPASS
L1Static analysis of the codeNA
L2Instruction surface (what it tells the agent)PASS
L3Class-specific surfacePASS
L4Behavioural (sandbox)SKIPPED

What the source does

Filesystem
none-observed
Network
none-observed
Shell
none-observed
Dependencies
pinned
Secrets in source
none-found

Findings (0)

No findings outside the package's declared scope.

Gates applied: no_behavioural_pass.

Audited 2026-09-19 · audit v0.4.1 · source sha e9ca581a4f44full audit observations/trust-audit/skill/affaan-m__ai-regression-testing.json · Report an issue / request a re-scan
05

Audit history

Every audit this skill has had.

DateSourceVerdictGradeScoreChange
2026-09-19e9ca581a4f44SAFEB89first audit
06

Questions

What does the Ai Regression Testing skill do?

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

Is Ai Regression Testing safe to install?

The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.

What can Ai Regression Testing access on my machine?

The audit observed no filesystem, network or shell use at all in its source.

Which assistants does Ai Regression Testing work with?

Its documentation mentions claude-code, codex and cursor. That is what the text claims, not a compatibility test we ran.

How current is this page?

The grade is for one exact copy of the source (e9ca581a4f44), read on 2026-09-19. The repository is watched, and a new audit runs when it changes — this is the first audit.

Advertisement