From gavel
Author API tests using the service-layer pattern in the target repo. Generates test code only — not OpenAPI governance, contract platforms, or env provisioning. Framework-adaptive. Use when asked to write API tests with existing patterns.
How this skill is triggered — by the user, by Claude, or both
Slash command
/gavel:gavel-apiThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
API test authoring workflow. Framework-adaptive via active profile.
API test authoring workflow. Framework-adaptive via active profile.
Check if a service class exists for the endpoint domain. If not, create one.
Service classes encapsulate HTTP calls. Define methods: create, list, retrieve, update, delete. Use typed responses.
Use fixture DI for services. Use factories for test data. Group with test.step().
Type-check, lint, run the test. Verify pass.
Each endpoint needs: happy path (200/201), validation (400), auth (401), authZ (403), edge cases.
| Method | HTTP | Usage |
|---|---|---|
createX({ data }) | POST | Create resource |
listX({ params? }) | GET | List (paginated) |
retrieveX(id) | GET | Get single |
updateX(id, { data }) | PUT/PATCH | Update |
deleteX(id) | DELETE | Delete |
Every API response must match a schema. Schema drift is the #1 cause of silent prod bugs. Validate on every test.
import Ajv from 'ajv';
const ajv = new Ajv({ strict: false });
// Define or import the schema from your OpenAPI spec:
const userSchema = {
type: 'object',
required: ['id', 'email', 'createdAt'],
properties: {
id: { type: 'string', format: 'uuid' },
email: { type: 'string', format: 'email' },
createdAt: { type: 'string', format: 'date-time' },
},
additionalProperties: false,
};
test('GET /api/users/123 returns valid schema', async ({ request }) => {
const response = await request.get('/api/users/123');
expect(response.status()).toBe(200);
const body = await response.json();
expect(ajv.validate(userSchema, body)).toBe(true); // hard gate
});
openapi.yaml) — import once, share across all API testsMocking is acceptable only for: external paid APIs, payment gateways, third-party services you don't control. Never mock your own backend; hit the real one (staging env, isolated DB). A test that mocks your own API tests your mock, not your code.
API tests must cover, per endpoint:
That's the minimum. Negative edge cases (boundary inputs, malformed bodies) belong in unit tests, not here.
npx claudepluginhub dsolisp/gavel --plugin gavelRoutes gstack requests to the correct skill (planning, review, QA, shipping, debugging, docs, security, design). Invokes when user types /gstack or asks which skill to use.
Provides UI/UX design intelligence with 50+ styles, 161 color palettes, 57 font pairings, 99 UX guidelines, and 25 chart types across 10 stacks. Use for designing pages, components, or reviewing visual quality.