New: Earn 20% as an AgentAlley affiliate. Share your link and earn on every sale you refer. Join now New: Earn 20% as an affiliate. Join now

Generate API tests, create integration test suites

API test suite builder

by alirezarezvani · MIT license · ★ 26,349 on GitHub · updated Aug 30

API test suite builder cover

Use when the user asks to generate API tests, create integration test suites, test REST endpoints, or build contract tests.

---
name: "api-test-suite-builder"
description: "Use when the user asks to generate API tests, create integration test suites, test REST endpoints, or build contract tests."
---

# API Test Suite Builder

**Tier:** POWERFUL
**Category:** Engineering
**Domain:** Testing / API Quality

---

## Overview

Scans API route definitions across frameworks (Next.js App Router, Express, FastAPI, Django REST) and
auto-generates comprehensive test suites covering auth, input validation, error codes, pagination, file
uploads, and rate limiting. Outputs ready-to-run test files for Vitest+Supertest (Node) or Pytest+httpx

Overview

Tier: POWERFUL Category: Engineering Domain: Testing / API Quality

Manual install (npx, ZIP)
Claude Codenpx skills add alirezarezvani/claude-skills --skill api-test-suite-builder -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/alirezarezvani/claude-skills/tar.gz/19392f7a0826 \ | tar -xz -C ~/.claude/skills --strip-components=3 claude-skills-19392f7a0826/engineering/skills/api-test-suite-builder
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/918c62516c040a287ec0/api-test-suite-builder.zip" -OutFile "$env:TEMP\api-test-suite-builder.zip"; Expand-Archive "$env:TEMP\api-test-suite-builder.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md6.2 KB
  • references/1 file · 16.3 KB
Read the files here
alirezarezvani/19392f72 files
SKILL.md
Show the full text178 lines

API Test Suite Builder

Tier: POWERFUL Category: Engineering Domain: Testing / API Quality


Overview

Scans API route definitions across frameworks (Next.js App Router, Express, FastAPI, Django REST) and auto-generates comprehensive test suites covering auth, input validation, error codes, pagination, file uploads, and rate limiting. Outputs ready-to-run test files for Vitest+Supertest (Node) or Pytest+httpx (Python).


Core Capabilities

  • Route detection — scan source files to extract all API endpoints
  • Auth coverage — valid/invalid/expired tokens, missing auth header
  • Input validation — missing fields, wrong types, boundary values, injection attempts
  • Error code matrix — 400/401/403/404/422/500 for each route
  • Pagination — first/last/empty/oversized pages
  • File uploads — valid, oversized, wrong MIME type, empty
  • Rate limiting — burst detection, per-user vs global limits

When to Use

  • New API added — generate test scaffold before writing implementation (TDD)
  • Legacy API with no tests — scan and generate baseline coverage
  • API contract review — verify existing tests match current route definitions
  • Pre-release regression check — ensure all routes have at least smoke tests
  • Security audit prep — generate adversarial input tests

Route Detection

Next.js App Router
# Find all route handlers
find ./app/api -name "route.ts" -o -name "route.js" | sort

# Extract HTTP methods from each route file
grep -rn "export async function\|export function" app/api/**/route.ts | \
  grep -oE "(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)" | sort -u

# Full route map
find ./app/api -name "route.ts" | while read f; do
  route=$(echo $f | sed 's|./app||' | sed 's|/route.ts||')
  methods=$(grep -oE "export (async )?function (GET|POST|PUT|PATCH|DELETE)" "$f" | \
    grep -oE "(GET|POST|PUT|PATCH|DELETE)")
  echo "$methods $route"
done
Express
# Find all router files
find ./src -name "*.ts" -o -name "*.js" | xargs grep -l "router\.\(get\|post\|put\|delete\|patch\)" 2>/dev/null

# Extract routes with line numbers
grep -rn "router\.\(get\|post\|put\|delete\|patch\)\|app\.\(get\|post\|put\|delete\|patch\)" \
  src/ --include="*.ts" | grep -oE "(get|post|put|delete|patch)\(['\"][^'\"]*['\"]"

# Generate route map
grep -rn "router\.\|app\." src/ --include="*.ts" | \
  grep -oE "\.(get|post|put|delete|patch)\(['\"][^'\"]+['\"]" | \
  sed "s/\.\(.*\)('\(.*\)'/\U\1 \2/"
FastAPI
# Find all route decorators
grep -rn "@app\.\|@router\." . --include="*.py" | \
  grep -E "@(app|router)\.(get|post|put|delete|patch)"

# Extract with path and function name
grep -rn "@\(app\|router\)\.\(get\|post\|put\|delete\|patch\)" . --include="*.py" | \
  grep -oE "@(app|router)\.(get|post|put|delete|patch)\(['\"][^'\"]*['\"]"
Django REST Framework
# urlpatterns extraction
grep -rn "path\|re_path\|url(" . --include="*.py" | grep "urlpatterns" -A 50 | \
  grep -E "path\(['\"]" | grep -oE "['\"][^'\"]+['\"]" | head -40

# ViewSet router registration
grep -rn "router\.register\|DefaultRouter\|SimpleRouter" . --include="*.py"

Test Generation Patterns

Auth Test Matrix

For every authenticated endpoint, generate:

Test Case Expected Status
No Authorization header 401
Invalid token format 401
Valid token, wrong user role 403
Expired JWT token 401
Valid token, correct role 2xx
Token from deleted user 401
Input Validation Matrix

For every POST/PUT/PATCH endpoint with a request body:

Test Case Expected Status
Empty body {} 400 or 422
Missing required fields (one at a time) 400 or 422
Wrong type (string where int expected) 400 or 422
Boundary: value at min-1 400 or 422
Boundary: value at min 2xx
Boundary: value at max 2xx
Boundary: value at max+1 400 or 422
SQL injection in string field 400 or 200 (sanitized)
XSS payload in string field 400 or 200 (sanitized)
Null values for required fields 400 or 422

Example Test Files

→ See references/example-test-files.md for details

Generating Tests from Route Scan

When given a codebase, follow this process:

  1. Scan routes using the detection commands above
  2. Read each route handler to understand:
    • Expected request body schema
    • Auth requirements (middleware, decorators)
    • Return types and status codes
    • Business rules (ownership, role checks)
  3. Generate test file per route group using the patterns above
  4. Name tests descriptively: "returns 401 when token is expired" not "auth test 3"
  5. Use factories/fixtures for test data — never hardcode IDs
  6. Assert response shape, not just status code

Common Pitfalls

  • Testing only happy paths — 80% of bugs live in error paths; test those first
  • Hardcoded test data IDs — use factories/fixtures; IDs change between environments
  • Shared state between tests — always clean up in afterEach/afterAll
  • Testing implementation, not behavior — test what the API returns, not how it does it
  • Missing boundary tests — off-by-one errors are extremely common in pagination and limits
  • Not testing token expiry — expired tokens behave differently from invalid ones
  • Ignoring Content-Type — test that API rejects wrong content types (xml when json expected)

Best Practices

  1. One describe block per endpoint — keeps failures isolated and readable
  2. Seed minimal data — don't load the entire DB; create only what the test needs
  3. Use beforeAll for shared setup, afterAll for cleanup — not beforeEach for expensive ops
  4. Assert specific error messages/fields, not just status codes
  5. Test that sensitive fields (password, secret) are never in responses
  6. For auth tests, always test the "missing header" case separately from "invalid token"
  7. Add rate limit tests last — they can interfere with other test suites if run in parallel
1---
2name: "api-test-suite-builder"
3description: "Use when the user asks to generate API tests, create integration test suites, test REST endpoints, or build contract tests."
4---
5 
6# API Test Suite Builder
7 
8**Tier:** POWERFUL
9**Category:** Engineering
10**Domain:** Testing / API Quality
11 
12---
13 
14## Overview
15 
16Scans API route definitions across frameworks (Next.js App Router, Express, FastAPI, Django REST) and
17auto-generates comprehensive test suites covering auth, input validation, error codes, pagination, file
18uploads, and rate limiting. Outputs ready-to-run test files for Vitest+Supertest (Node) or Pytest+httpx
19(Python).
20 
21---
22 
23## Core Capabilities
24 
25- **Route detection** — scan source files to extract all API endpoints
26- **Auth coverage** — valid/invalid/expired tokens, missing auth header
27- **Input validation** — missing fields, wrong types, boundary values, injection attempts
28- **Error code matrix** — 400/401/403/404/422/500 for each route
29- **Pagination** — first/last/empty/oversized pages
30- **File uploads** — valid, oversized, wrong MIME type, empty
31- **Rate limiting** — burst detection, per-user vs global limits
32 
33---
34 
35## When to Use
36 
37- New API added — generate test scaffold before writing implementation (TDD)
38- Legacy API with no tests — scan and generate baseline coverage
39- API contract review — verify existing tests match current route definitions
40- Pre-release regression check — ensure all routes have at least smoke tests
41- Security audit prep — generate adversarial input tests
42 
43---
44 
45## Route Detection
46 
47### Next.js App Router
48```bash
49# Find all route handlers
50find ./app/api -name "route.ts" -o -name "route.js" | sort
51 
52# Extract HTTP methods from each route file
53grep -rn "export async function\|export function" app/api/**/route.ts | \
54 grep -oE "(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)" | sort -u
55 
56# Full route map
57find ./app/api -name "route.ts" | while read f; do
58 route=$(echo $f | sed 's|./app||' | sed 's|/route.ts||')
59 methods=$(grep -oE "export (async )?function (GET|POST|PUT|PATCH|DELETE)" "$f" | \
60 grep -oE "(GET|POST|PUT|PATCH|DELETE)")
61 echo "$methods $route"
62done
63```
64 
65### Express
66```bash
67# Find all router files
68find ./src -name "*.ts" -o -name "*.js" | xargs grep -l "router\.\(get\|post\|put\|delete\|patch\)" 2>/dev/null
69 
70# Extract routes with line numbers
71grep -rn "router\.\(get\|post\|put\|delete\|patch\)\|app\.\(get\|post\|put\|delete\|patch\)" \
72 src/ --include="*.ts" | grep -oE "(get|post|put|delete|patch)\(['\"][^'\"]*['\"]"
73 
74# Generate route map
75grep -rn "router\.\|app\." src/ --include="*.ts" | \
76 grep -oE "\.(get|post|put|delete|patch)\(['\"][^'\"]+['\"]" | \
77 sed "s/\.\(.*\)('\(.*\)'/\U\1 \2/"
78```
79 
80### FastAPI
81```bash
82# Find all route decorators
83grep -rn "@app\.\|@router\." . --include="*.py" | \
84 grep -E "@(app|router)\.(get|post|put|delete|patch)"
85 
86# Extract with path and function name
87grep -rn "@\(app\|router\)\.\(get\|post\|put\|delete\|patch\)" . --include="*.py" | \
88 grep -oE "@(app|router)\.(get|post|put|delete|patch)\(['\"][^'\"]*['\"]"
89```
90 
91### Django REST Framework
92```bash
93# urlpatterns extraction
94grep -rn "path\|re_path\|url(" . --include="*.py" | grep "urlpatterns" -A 50 | \
95 grep -E "path\(['\"]" | grep -oE "['\"][^'\"]+['\"]" | head -40
96 
97# ViewSet router registration
98grep -rn "router\.register\|DefaultRouter\|SimpleRouter" . --include="*.py"
99```
100 
101---
102 
103## Test Generation Patterns
104 
105### Auth Test Matrix
106 
107For every authenticated endpoint, generate:
108 
109| Test Case | Expected Status |
110|-----------|----------------|
111| No Authorization header | 401 |
112| Invalid token format | 401 |
113| Valid token, wrong user role | 403 |
114| Expired JWT token | 401 |
115| Valid token, correct role | 2xx |
116| Token from deleted user | 401 |
117 
118### Input Validation Matrix
119 
120For every POST/PUT/PATCH endpoint with a request body:
121 
122| Test Case | Expected Status |
123|-----------|----------------|
124| Empty body `{}` | 400 or 422 |
125| Missing required fields (one at a time) | 400 or 422 |
126| Wrong type (string where int expected) | 400 or 422 |
127| Boundary: value at min-1 | 400 or 422 |
128| Boundary: value at min | 2xx |
129| Boundary: value at max | 2xx |
130| Boundary: value at max+1 | 400 or 422 |
131| SQL injection in string field | 400 or 200 (sanitized) |
132| XSS payload in string field | 400 or 200 (sanitized) |
133| Null values for required fields | 400 or 422 |
134 
135---
136 
137## Example Test Files
138→ See references/example-test-files.md for details
139 
140## Generating Tests from Route Scan
141 
142When given a codebase, follow this process:
143 
1441. **Scan routes** using the detection commands above
1452. **Read each route handler** to understand:
146 - Expected request body schema
147 - Auth requirements (middleware, decorators)
148 - Return types and status codes
149 - Business rules (ownership, role checks)
1503. **Generate test file** per route group using the patterns above
1514. **Name tests descriptively**: `"returns 401 when token is expired"` not `"auth test 3"`
1525. **Use factories/fixtures** for test data — never hardcode IDs
1536. **Assert response shape**, not just status code
154 
155---
156 
157## Common Pitfalls
158 
159- **Testing only happy paths** — 80% of bugs live in error paths; test those first
160- **Hardcoded test data IDs** — use factories/fixtures; IDs change between environments
161- **Shared state between tests** — always clean up in afterEach/afterAll
162- **Testing implementation, not behavior** — test what the API returns, not how it does it
163- **Missing boundary tests** — off-by-one errors are extremely common in pagination and limits
164- **Not testing token expiry** — expired tokens behave differently from invalid ones
165- **Ignoring Content-Type** — test that API rejects wrong content types (xml when json expected)
166 
167---
168 
169## Best Practices
170 
1711. One describe block per endpoint — keeps failures isolated and readable
1722. Seed minimal data — don't load the entire DB; create only what the test needs
1733. Use `beforeAll` for shared setup, `afterAll` for cleanup — not `beforeEach` for expensive ops
1744. Assert specific error messages/fields, not just status codes
1755. Test that sensitive fields (password, secret) are never in responses
1766. For auth tests, always test the "missing header" case separately from "invalid token"
1777. Add rate limit tests last — they can interfere with other test suites if run in parallel
178 
View all files on GitHub →

Details

Updated
Aug 30, 2026
License
MIT
Stars on the repo
★ 26,349
Checked
Source
alirezarezvani/claude-skills ↗
Creator
alirezarezvani · 363 listings
View creator

Similar skills

See all →
SkillGuides stable API and interface designaddyosmani/agent-skills · by addyosmaniGuides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.★ 98.7k GitHub starsMCPPulls up-to-date, version-specific library docsContext7upstash/context7 · by upstashPulls up-to-date, version-specific library docs and code examples into the prompt so the AI stops inventing old APIs.★ 62.3k GitHub starsSkillFetch up-to-date documentation and code examples for anyContext7 Documentation Lookupupstash/context7 · by upstashFetch up-to-date documentation and code examples for any library, framework, SDK, CLI tool, or cloud service. Use whenever the user asks about a specific library — even well-known ones like React, Next.js, Prisma, Express, Tailwind, Django, or Spring Boot — because training data may not reflect recent API changes or version updates. Always use for: API syntax questions, configuration options, version migration issues, "how do I" questions mentioning a library name, debugging that involves library-specific behavior, setup instructions, and CLI tool usage. Use even when you think you know the answer. Do not rely on training data for API details, signatures, or configuration options — they are frequently out of date. Prefer this over web search for library documentation.★ 62.3k GitHub starsSkillHow to use the Adaptyv Bio Foundry API and Python SDKK-Dense-AI/scientific-agent-skills · by K-Dense-AIHow to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.★ 46k GitHub starsSkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillGuides the usage of Gemini Interactions API on GeminiGemini Interactions API Skillgoogle/skills · by googleGuides the usage of Gemini Interactions API on Gemini Enterprise Agent Platform. Use when the user wants to use the stateful, server-managed Interactions API for multi-turn conversations, background execution, streaming, structured output, and function calling on the Agent Platform.★ 20.9k GitHub stars

More from alirezarezvani

SkillResume a paused experiment/ar:ar-resume — Resume Experimentalirezarezvani/claude-skills · by alirezarezvaniResume a paused experiment. Checkout the experiment branch, read results history, continue iterating. Use when the user runs /ar:ar-resume or asks to pick up a previously started autoresearch experiment.★ 26.3k GitHub starsSkillShow experiment dashboard with results, active loops/ar:ar-status — Experiment Dashboardalirezarezvani/claude-skills · by alirezarezvaniShow experiment dashboard with results, active loops, and progress. Use when the user runs /ar:ar-status or asks how an autoresearch experiment is going.★ 26.3k GitHub starsSkillStart an autonomous experiment loop with user-selected/ar:loop — Autonomous Experiment Loopalirezarezvani/claude-skills · by alirezarezvaniStart an autonomous experiment loop with user-selected interval (10min, 1h, daily, weekly, monthly). Uses CronCreate for scheduling. Use when the user runs /ar:loop or asks to run an autoresearch experiment continuously on a schedule.★ 26.3k GitHub starsSkillRun a single experiment iteration/ar:run — Single Experiment Iterationalirezarezvani/claude-skills · by alirezarezvaniRun a single experiment iteration. Edit the target file, evaluate, keep or discard. Use when the user runs /ar:run or asks for one manual autoresearch iteration.★ 26.3k GitHub starsSkillSet up a new autoresearch experiment interactively/ar:setup — Create New Experimentalirezarezvani/claude-skills · by alirezarezvaniSet up a new autoresearch experiment interactively. Collects domain, target file, eval command, metric, direction, and evaluator. Use when the user runs /ar:setup or asks to start optimizing a file with the autoresearch loop.★ 26.3k GitHub starsSkill/cs:boardroom <brief/cs:boardroom — Multi-Role Boardroom Deliberationalirezarezvani/claude-skills · by alirezarezvani/cs:boardroom <brief> — 6-phase multi-role deliberation across the C-suite with Phase 2 isolation, critic pre-screen, and synthesis. Outputs a board memo. Use when a decision spans multiple executive domains — e.g. a pricing change touching finance, positioning, and product, or a raise-vs-cut runway call.★ 26.3k GitHub stars