Zum Inhalt springen
Skillpedia
Agenten280k · #262

ai-regression-testing

Was er macht

Dieses Tool hilft dir, deinen Code automatisch zu testen, besonders dann, wenn die KI ihn geschrieben und geprüft hat. Es stellt sicher, dass Bugfixes keine neuen Probleme verursachen, und konzentriert sich auf Tests ohne Datenbankabhängigkeiten.

Wann du ihn nutzt

  • ✓Wenn die KI wichtige Codeteile ändert (API-Routen, Backend-Logik).
  • ✓Nach einer Fehlerbehebung, um sicherzustellen, dass der Fehler nicht wieder auftaucht.
  • ✓Wenn du einen „Sandbox“- oder „Mock“-Modus nutzt, um ohne echte Datenbank zu testen.

Link zum Skill

https://github.com/affaan-m/ECC/blob/main/skills/ai-regression-testing/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/affaan-m/ECC/blob/main/skills/ai-regression-testing/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Prüfe, ob meine User-Profil-API alle Pflichtfelder zurückgibt, einschließlich „notification_settings“.”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Das Tool richtet eine schnelle Testumgebung ein, die deine Anwendung ohne echte Datenbank simuliert. Dann schreibt es gezielte Tests, die prüfen, ob Bugfixes andere Teile des Codes nicht beschädigt haben, besonders über verschiedene Betriebsmodi hinweg (etwa Sandbox und Produktion).

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

AI Regression Testing

Testing patterns specifically designed for AI-assisted development, where the same model writes code and reviews it — creating systematic blind spots that only automated tests can catch.

When to Activate

  • AI agent (Claude Code, Cursor, Codex) has modified API routes or backend logic
  • A bug was found and fixed — need to prevent re-introduction
  • Project has a sandbox/mock mode that can be leveraged for DB-free testing
  • Running /bug-check or similar review commands after code changes
  • Multiple code paths exist (sandbox vs production, feature flags, etc.)

The Core Problem

When an AI writes code and then reviews its own work, it carries the same assumptions into both steps. This creates a predictable failure pattern:

AI writes fix → AI reviews fix → AI says "looks correct" → Bug still exists

Real-world example (observed in production):

Fix 1: Added notification_settings to API response
  → Forgot to add it to the SELECT query
  → AI reviewed and missed it (same blind spot)

Fix 2: Added it to SELECT query
  → TypeScript build error (column not in generated types)
  → AI reviewed Fix 1 but didn't catch the SELECT issue

Fix 3: Changed to SELECT *
  → Fixed production path, forgot sandbox path
  → AI reviewed and missed it AGAIN (4th occurrence)

Fix 4: Test caught it instantly on first run PASS:

The pattern: sandbox/production path inconsistency is the #1 AI-introduced regression.

Sandbox-Mode API Testing

Most projects with AI-friendly architecture have a sandbox/mock mode. This is the key to fast, DB-free API testing.

Setup (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
// Force sandbox mode — no database needed
process.env.SANDBOX_MODE = "true";
process.env.NEXT_PUBLIC_SUPABASE_URL = "";
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY = "";

Test Helper for Next.js API Routes

// __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 };
}

Writing Regression Tests

The key principle: write tests for bugs that were found, not for code that works.

// __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";

// Define the contract — what fields MUST be in the response
const REQUIRED_FIELDS = [
  "id",
  "email",
  "full_name",
  "phone",
  "role",
  "created_at",
  "avatar_url",
  "notification_settings",  // ← Added after bug found it missing
];

describe("GET /api/user/profile", () => {
  it("returns all required fields", 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);
    }
  });

  // Regression test — this exact bug was introduced by AI 4 times
  it("notification_settings is not undefined (BUG-R1 regression)", async () => {
    const req = createTestRequest("/api/user/profile");
    const res = await GET(req);

…
Häufige Fragen

Warum testen, wenn die KI den Code selbst schreibt und prüft?

Wenn dieselbe KI Code schreibt und prüft, kann sie dieselben „blinden Flecken“ haben und in beiden Schritten etwas Wichtiges übersehen. Automatisierte Tests fangen solche Fehler ab.

Was ist der „Sandbox-Modus“?

Das ist ein Testmodus, der das Verhalten deiner Anwendung simuliert, ohne sich mit einer echten Datenbank zu verbinden. Dadurch laufen Tests schneller und sind leichter einzurichten.

Welcher Fehler wird am häufigsten verhindert?

Am häufigsten passiert Folgendes: Eine Korrektur funktioniert in einer Umgebung (etwa Produktion), bricht aber in einer anderen (etwa Sandbox) oder umgekehrt. Dieses Tool prüft genau auf solche Inkonsistenzen.

Details

Originalbeschreibung des Autors

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

repo: affaan-m/ECC

Beliebtheit

GitHub-Sterne
280k
Platz im Ranking
#262
Lizenz
MIT
Aktualisiert
15.10.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills