testing-kit

A testing and quality-check workflow for Next.js applications using the App Router. TDD, or test-driven development, means writing a failing test before writing the code that makes it pass; the workflow also covers unit tests, browser tests, builds, environment variables, and security checks.

In plain words
What is it for?
Use it when creating or changing Next.js routes, pages, or tests, including writing Vitest unit tests, Playwright end-to-end tests, and checking the production build.
Why use it?
It makes each route and page prove its expected behavior and catches failures before changes reach users.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/fermonterom/claude-testing-kit/testing-kit
Any agent
npx skills add fermonterom/claude-testing-kit --skill testing-kit
Clone the repo
git clone --depth 1 https://github.com/fermonterom/claude-testing-kit

Made for: Claude Code, Codex.

Per session 78 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,867 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00078 $0.03867
Opus 5 $0.00039 $0.01934
Sonnet 5 $0.00016 $0.00773
Haiku 4.5 $0.00008 $0.00387

Measured 2d ago against content hash 05fbd464c80f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-kit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/testing-kit/SKILL.md · 485 lines

How it starts

The opening of the file, as written. The whole thing — 485 lines — stays where its author put it; the contents beside it link to each section on GitHub.

testing-kit — TDD + Unit + E2E + Quality Gate para Next.js

Parte 1: TDD — Test First, Code Second

3 Reglas de Hierro

1. TEST FIRST, CODE SECOND — sin excepciones
2. NUNCA codigo de produccion sin un test que falle primero
3. CADA route.ts tiene route.test.ts, CADA page.tsx tiene .spec.ts

Ciclo RED → GREEN → REFACTOR

RED: Escribir UN test que describe UN comportamiento → ejecutar → DEBE FALLAR GREEN: Escribir el codigo MINIMO para que pase → ejecutar → DEBE PASAR REFACTOR: Limpiar sin romper tests → ejecutar → SIGUE PASANDO

Repetir. Un test a la vez. SIEMPRE vertical (test → codigo → green), NUNCA horizontal (todos los tests → luego todo el codigo).

Test List (antes de escribir codigo)

Listar todos los comportamientos a testear. Ejemplo para POST /api/users:

1. 201 — crea usuario con datos validos
2. 401 — rechaza sin autenticacion
3. 400 — rechaza campos requeridos vacios
4. 400 — rechaza email invalido
5. 404 — recurso padre no existe
6. 500 — maneja error de base de datos

Cada item = un ciclo RED → GREEN.


Parte 2: Unit Tests con Vitest

Template de 6 Casos (minimo obligatorio)

import { describe, it, expect, vi, beforeEach } from 'vitest'

// Mocks ANTES de los imports del codigo
const mockGetUser = vi.fn()
const mockFrom = vi.fn()

vi.mock('@/lib/supabase/server', () => ({
  createClient: vi.fn(() => Promise.resolve({
    auth: { getUser: mockGetUser },
    from: mockFrom,
  })),
}))

// Import del codigo a testear
import { POST } from './route'

const MOCK_USER = { id: 'user-123', email: '[email protected]' }

function createRequest(body?: unknown): Request {
  return new Request('http://localhost/api/resource', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    ...(body ? { body: JSON.stringify(body) } : {}),
  })
}

beforeEach(() => { vi.clearAllMocks() })

describe('POST /api/resource', () => {
  // CASO 1: Happy path (200/201)
  it('returns 201 with created resource', async () => {
    mockGetUser.mockResolvedValue({ data: { user: MOCK_USER } })
    mockFrom.mockReturnValue({
      insert: vi.fn().mockReturnThis(),
      select: vi.fn().mockReturnThis(),
      single: vi.fn().mockResolvedValue({ data: { id: '1', name: 'Test' }, error: null }),
    })

    const res = await POST(createRequest({ name: 'Test' }))
    expect(res.status).toBe(201)
  })

  // CASO 2: Sin autenticacion (401)
  it('returns 401 when not authenticated', async () => {
    mockGetUser.mockResolvedValue({ data: { user: null } })
    const res = await POST(createRequest({ name: 'Test' }))
    expect(res.status).toBe(401)
  })

  // CASO 3: Input invalido (400)
  it('returns 400 on invalid input', async () => {
    mockGetUser.mockResolvedValue({ data: { user: MOCK_USER } })
    const res = await POST(createRequest({})) // body vacio
    expect(res.status).toBe(400)
  })

  // CASO 4: No encontrado (404)
  it('returns 404 when resource not found', async () => {
    mockGetUser.mockResolvedValue({ data: { user: MOCK_USER } })
    mockFrom.mockReturnValue({
      select: vi.fn().mockReturnThis(),
      eq: vi.fn().mockReturnThis(),
      single: vi.fn().mockResolvedValue({ data: null, error: null }),
    })

    const res = await POST(createRequest({ parentId: 'not-found' }))
    expect(res.status).toBe(404)
  })

  // CASO 5: Error de BD (500)
  it('returns 500 on database error', async () => {
    mockGetUser.mockResolvedValue({ data: { user: MOCK_USER } })
    mockFrom.mockReturnValue({
      insert: vi.fn().mockReturnThis(),
      select: vi.fn().mockReturnThis(),
      single: vi.fn().mockResolvedValue({ data: null, error: { message: 'DB error' } }),
    })

    const res = await POST(createRequest({ name: 'Test' }))
    expect(res.status).toBe(500)
    // Verificar que NO expone el error interno
    const body = await res.json()
    expect(body.error).not.toContain('DB error')
  })

  // CASO 6: Extra (especifico del endpoint — SIEMPRE implementar, nunca dejar vacio)
  it('returns 409 when duplicate name exists', async () => {
    mockGetUser.mockResolvedValue({ data: { user: MOCK_USER } })
    mockFrom.mockReturnValue({
      insert: vi.fn().mockReturnThis(),
      select: vi.fn().mockReturnThis(),
      single: vi.fn().mockResolvedValue({
        data: null,
        error: { message: 'unique_violation', code: '23505' },
      }),
    })

    const res = await POST(createRequest({ name: 'Duplicado' }))
    expect(res.status).toBe(409)
  })
})

Read the full file on GitHub · 485 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 485 lines · 78 tokens per session scan A 05fbd464c80f

Subscribe to this mod's changes

testing-kit is a skill published in the GitHub repository fermonterom/claude-testing-kit (10 stars, last pushed 4mo ago), licensed MIT. It adds 78 tokens to every session and 3,867 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

agent-host-chat-contributions

Build and review cross-cutting agent-host chat behavior through lifecycle contributions. Use when adding turn lifecycle side effects, prompt or context injection, restored-history transformation, protocol-action observation, or when reviewing changes that add code to AgentSideEffects or AgentService.

microsoft/vscode · 56 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens