From threadline-ai
Use this skill when the user wants to derive API contract specifications from reviewed use cases and technical design. Triggers include 'write the API contract', 'define the endpoints', 'derive the REST API', 'what endpoints do we need', 'produce the API spec', 'map use cases to HTTP'. Also use in the agentic pipeline during Phase 3B. Requires READY use cases and technical design output (interactors, typed errors, domain events). Do NOT use before technical design exists.
How this skill is triggered — by the user, by Claude, or both
Slash command
/threadline-ai:api-contract-writerThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Derives HTTP API contract specifications from reviewed use cases and their technical design output.
Derives HTTP API contract specifications from reviewed use cases and their technical design output.
Interactors return typed results and typed errors. HTTP endpoints must translate those into status codes, response bodies, and error envelopes. Without an explicit contract, developers invent ad-hoc mappings and frontends guess at error shapes. The contract specifies every response and traces it to the use case element it implements.
| Use case element | HTTP construct | Example |
|---|---|---|
| Goal (verb + noun) | HTTP method + resource URL | "Submit form" -> POST /forms/{formId}/submissions |
| Preconditions (state checks) | 4xx error responses | FormNotPublished -> 404 |
| MSS postconditions | Success response body + status | Record created -> 201 { recordId, status } |
| Extensions — validation | 422 with error envelope | RequiredFieldMissing -> 422 { errors } |
| Extensions — invariant conflict | 409 Conflict | DuplicateSubmission -> 409 |
| Extensions — alternate success | 2xx with different status | Approval mode -> 202 { status: "pending" } |
| QA scenarios | Auth/rate-limit headers | QA-03 -> Rate-Limit headers, 429 response |
| Domain events | Webhook payloads | RecordCreated -> webhook POST |
One contract block per endpoint:
Endpoint: [METHOD] /v1/[resource-path]
Implements: [UC-ID] -- [Use case title]
Actor: [Primary actor] ([public | authenticated | role])
Auth: [None | Bearer token | API key] (ref QA scenario)
Request:
Path params: [name (type, required)]
Query params: [name (type, optional, default)]
Body: { [field]: [type], ... }
Response -- success:
[status] [reason] -> { [field]: [type], ... }
Derived from: [UC-ID] postconditions
Response -- errors:
[status] [reason] -> { [error envelope] }
Derived from: [UC-ID] ext [N][letter] ([ErrorType])
Pagination: [strategy or N/A]
Rate limiting: [constraint from QA scenario or "none specified"]
| Goal verb | Method |
|---|---|
| Create, submit, send | POST |
| Read, view, list, get | GET |
| Update, edit, rename | PUT (full) or PATCH (partial) |
| Delete, remove, archive | DELETE |
| Toggle, activate | PATCH on sub-resource |
/forms, /records, /workspaces/forms/{formId}/submissionsPOST /forms/{formId}/publish{
"error": "machine_readable_code",
"message": "Human-readable description",
"errors": [
{ "field": "fieldId", "code": "required", "message": "This field is required" }
]
}
Top-level error for single errors (404, 409, 403). errors array for validation (422) with per-field detail. Codes are snake_case of the typed error class.
List endpoints: cursor-based ?cursor=X&limit=N, response { data: [...], nextCursor: string | null }, default 25, max 100.
URL prefix /v1/. New version only on breaking changes.
QA scenarios constrain the contract without changing domain logic:
| QA scenario type | Contract impact |
|---|---|
| Rate limiting (QA-03) | X-RateLimit-* headers; 429 response |
| Authentication | Auth: field; 401/403 error responses |
| Response time SLA | Note for infrastructure sizing |
| Data residency | Geographic routing note |
Each constraint references its scenario ID in the contract.
For each use case with an HTTP-facing adapter, produce:
"bad_request" is useless. Use the typed error name: "required_field_missing".Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
npx claudepluginhub bflandev/threadline-ai