Api test suite builder

From borghei/Claude-Skills · View interactive version

Api test suite builder is an AI agent skill from the GitHub repository borghei/Claude-Skills. Generates API test skeletons from an OpenAPI spec, measures which endpoints tests really assert on, and checks response samples against the spec. Use when adding API tests, auditing API test coverage, or catching contract drift.

How to use this skill

Skill file

API Test Suite Builder

Scan API route definitions across frameworks (Next.js App Router, Express, FastAPI, Django REST, Go net/http), analyze request/response schemas, and generate comprehensive test suites covering authentication, authorization, input validation, error handling, pagination, file uploads, rate limiting, contract testing, and load testing. Outputs ready-to-run test files for Vitest+Supertest (Node), Pytest+httpx (Python), or k6 (load testing).

Core Capabilities

When to Use

Clarify First

Before generating the suite, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.

Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.

Quick Start Workflow

The scripts read OpenAPI 3.x / Swagger 2.0 JSON specs. Auth, validation, Pact and k6 patterns

for the parts the scripts do not generate are in the references.

# 1. Generate skeletons (pytest+httpx or vitest+supertest) into a scratch dir, then move what you keep
python scripts/test_generator.py assets/sample_openapi.json --framework vitest --output /tmp/api-tests

# 2. Measure coverage: endpoints called by a test, and endpoints whose tests assert on the body
python scripts/coverage_analyzer.py assets/sample_openapi.json assets/sample_tests --threshold 50 --show-covered
python scripts/coverage_analyzer.py assets/sample_openapi.json /tmp/api-tests --threshold 95   # exit 1: skeletons only

# 3. Validate recorded responses against the spec's response schemas
python scripts/contract_validator.py assets/sample_openapi.json assets/sample_responses          # exit 0
python scripts/contract_validator.py assets/sample_openapi.json assets/sample_responses_flawed   # exit 1, 3 violations

Tools overview.

All three accept --json.

Exit codes. 0 sound (or files generated); 1 coverage below --threshold or a sample violates its contract; 2 missing or unreadable spec, directory or sample set, invalid JSON, or a file that is not an OpenAPI spec.

Done when:

  1. Every TODO in the generated files is replaced by a real assertion or deleted.
  2. The suite runs green against a local or mocked server, and red when you break the handler on purpose.
  3. coverage_analyzer.py --threshold passes at the bar your team agreed (asserted coverage, not call coverage).
  4. Each auth and validation rule in the spec has a negative test, and contract_validator.py passes on fresh recorded responses.

Anti-Patterns

Status-code-only tests

Mistake: Every test asserts status == 200 and nothing about the body.

Why it happens: Generated skeletons look finished, and status checks are easy to write.

Instead: Assert the fields the spec promises (ids, types, error messages). coverage_analyzer.py counts only these tests toward the gate.

Testing the happy path only

Mistake: No test sends a missing field, a wrong type or an expired token.

Why it happens: Negative cases need fixtures and feel like extra work.

Instead: Start from the generated 401 and 422 cases and add one negative test per validation rule and per role boundary.

Contract checks on hand-made samples

Mistake: Validating response samples someone typed, which match the spec by construction.

Why it happens: Recording real traffic takes setup.

Instead: Record responses from a running build (staging or a local server) and validate those. Drift only shows up in real output.

Files

Reference Documentation

Load the reference that matches the task — keep this file lean and pull detail on demand:

Scope & Limitations

This skill covers:

This skill does NOT cover:

See Also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.