api-test-writer
Skill4 starsChanged 27 days agoMITView on GitHub
Use when writing automated API tests or integration tests for REST or GraphQL endpoints, testing from an OpenAPI/Swagger spec or Postman collection, or checking status codes, response schemas, auth and error handling — Supertest, pytest + httpx, REST Assured, Postman/Newman and others.
In this repository30 other files it gives its agents.
- accessibility-auditSkill
- api-design-reviewSkill
- architecture-diagramSkill
- bug-debuggerSkill
- bug-report-writerSkill
- changelog-writerSkill
- codebase-onboardingSkill
- code-reviewSkill
- database-schema-designSkill
- dependency-upgradeSkill
- design-handoff-specSkill
- design-reviewSkill
- dockerize-appSkill
- figma-design-compareSkill
- flaky-test-fixerSkill
- git-commit-writerSkill
- github-actions-ciSkill
- playwright-e2e-testsSkill
- prd-writerSkill
- proof-of-done-liteSkill
- readme-writerSkill
- refactor-plannerSkill
- security-auditSkill
- seo-auditSkill
- test-case-generatorSkill
- test-plan-writerSkill
- test-writerSkill
- ux-research-synthesisSkill
- ux-writingSkill
- web-performance-auditSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Control data: create what each test needs through the API or factories, clean up afterwards, use unique values to allow parallel runs.
- Distinctive: line 69
Only testing the happy path.
- Distinctive: line 72
Never testing authorization with a second user.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API Test Writer
Overview
API tests check the contract clients depend on: status codes, response shape, validation, authorization and side effects. They are faster and more stable than UI tests, so most functional coverage belongs here.
Method
- Inventory the endpoints from routes, controllers or the OpenAPI spec: method, path, auth, request schema, responses.
- Match the project's tooling: existing test framework and HTTP client (Supertest for Node,
httpx/requestswith pytest, REST Assured for Java, Newman for Postman collections). Follow existing test structure. - Write cases per endpoint using the matrix below.
- Control data: create what each test needs through the API or factories, clean up afterwards, use unique values to allow parallel runs.
- Run the suite and confirm each new test fails when the behavior is broken (change an expected value once to check).
Case matrix per endpoint
| Category | Cases |
| Success | Valid request → correct status (200/201/204), body matches schema, headers (Location, Content-Type) |
| Validation | Missing required field, wrong type, out-of-range, too long, invalid format → 400/422 with field-level errors |
| Authentication | No token, expired token, malformed token → 401 |
| Authorization | Other user's resource (IDOR), insufficient role → 403 or 404 |
| Not found | Unknown ID → 404 with the standard error shape |
| Conflicts | Duplicate unique value, stale version → 409 |
| Side effects | Record created/updated in the database, event or email queued, idempotent retry does not duplicate |
| Lists | Pagination, filters, sorting, empty results, max page size |
Example (Node, Supertest + Vitest)
import request from "supertest";
import { describe, it, expect } from "vitest";
import { app } from "../src/app";
import { createUser, tokenFor } from "./factories";
describe("POST /orders", () => {
it("creates an order and returns 201 with a Location header", async () => {
const user = await createUser();
const res = await request(app)
.post("/orders")
.set("Authorization", `Bearer ${tokenFor(user)}`)
.send({ items: [{ sku: "SKU-1", quantity: 2 }] });
expect(res.status).toBe(201);
expect(res.headers.location).toMatch(/^\/orders\/\w+$/);
expect(res.body).toMatchObject({ status: "pending", items: [{ sku: "SKU-1", quantity: 2 }] });
});
it("rejects quantity 0 with a field error", async () => {
const user = await createUser();
const res = await request(app)
.post("/orders")
.set("Authorization", `Bearer ${tokenFor(user)}`)
.send({ items: [{ sku: "SKU-1", quantity: 0 }] });
expect(res.status).toBe(422);
expect(res.body.errors).toContainEqual(expect.objectContaining({ field: "items[0].quantity" }));
});
});Common mistakes
- Only testing the happy path.
- Asserting the whole response with a snapshot that includes IDs and timestamps.
- Tests that depend on data created by another test.
- Never testing authorization with a second user.
- Hitting production or shared environments with destructive tests.
Made by Wageesha Tripathi · LinkedIn · Email · More skills
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

