---
name: api-patterns
description: ALWAYS use this when the task involves API shape, contracts, auth, versioning, response structure, error handling, or service boundary design.
API Patterns
Selective Reading Rule
Start with:
references/usage-routing.md
references/quality-checklist.md
Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.
Selective Reading Rule
Start with:
references/senior-master-standard.md
Start with the file that answers the current design question:
references/contract-playbook.md for senior-level contract design and review
references/api-review-checklist.md for final review before implementation
api-style.md for REST vs GraphQL vs tRPC
rest.md for REST endpoint and resource design
graphql.md for GraphQL fit and schema considerations
trpc.md for TypeScript-first monorepo APIs
response.md for envelopes, pagination, and error contracts
versioning.md for API evolution
auth.md for authentication and caller identity
rate-limiting.md for abuse protection
documentation.md for API docs and discoverability
security-testing.md when reviewing API risk
Purpose
Choose an API style that fits the consumers, the team, and the product boundary.
An API is a contract. Changing it later is expensive, so design for clarity and operational reality early.
Use This Skill When
- picking between REST, GraphQL, and tRPC
- shaping new endpoints or procedures
- normalizing responses, errors, pagination, or filtering
- deciding auth and versioning strategy
- reviewing whether an API is too leaky, inconsistent, or hard to evolve
Core Workflow
- Identify the consumers.
- web client, mobile app, internal service, public integrators, same-repo frontend
- Choose the transport and contract style.
- REST, GraphQL, or tRPC based on usage patterns and team reality
- Define resource or procedure boundaries.
- Standardize responses.
- success shape, errors, pagination, identifiers, timestamps
- Decide control concerns.
- auth, rate limiting, idempotency, versioning, observability
- Document the contract in a way implementation can follow.
Heuristics
- Use REST when resources and cacheable operations dominate.
- Use GraphQL when the client truly needs flexible graph traversal and multiple consumer views.
- Use tRPC when TypeScript-first internal velocity matters more than public portability.
- Keep error shapes consistent across the surface.
- Avoid exposing internal storage structure as public API design.
Review Questions
- Can a new consumer understand the contract quickly?
- Are identifiers, status codes, and error shapes consistent?
- Is pagination stable and predictable?
- Can the API evolve without breaking common callers?
- Are auth and authorization boundaries obvious?
Related Skills
architecture for broader system-boundary decisions
database-design when endpoint shape is being distorted by schema issues
mcp-builder when the API surface is being adapted for tool-based LLM use
verification-before-completion before claiming an API contract is ready
1---2name: api-patterns3description: ---4---5---6name: api-patterns7description: ALWAYS use this when the task involves API shape, contracts, auth, versioning, response structure, error handling, or service boundary design.8---910# API Patterns1112## Selective Reading Rule1314Start with:1516- `references/usage-routing.md`17- `references/quality-checklist.md`1819Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.2021## Selective Reading Rule2223Start with:2425- `references/senior-master-standard.md`262728Start with the file that answers the current design question:2930- `references/contract-playbook.md` for senior-level contract design and review31- `references/api-review-checklist.md` for final review before implementation32- `api-style.md` for REST vs GraphQL vs tRPC33- `rest.md` for REST endpoint and resource design34- `graphql.md` for GraphQL fit and schema considerations35- `trpc.md` for TypeScript-first monorepo APIs36- `response.md` for envelopes, pagination, and error contracts37- `versioning.md` for API evolution38- `auth.md` for authentication and caller identity39- `rate-limiting.md` for abuse protection40- `documentation.md` for API docs and discoverability41- `security-testing.md` when reviewing API risk4243## Purpose4445Choose an API style that fits the consumers, the team, and the product boundary.4647An API is a contract. Changing it later is expensive, so design for clarity and operational reality early.4849## Use This Skill When5051- picking between REST, GraphQL, and tRPC52- shaping new endpoints or procedures53- normalizing responses, errors, pagination, or filtering54- deciding auth and versioning strategy55- reviewing whether an API is too leaky, inconsistent, or hard to evolve5657## Core Workflow58591. Identify the consumers.60 - web client, mobile app, internal service, public integrators, same-repo frontend612. Choose the transport and contract style.62 - REST, GraphQL, or tRPC based on usage patterns and team reality633. Define resource or procedure boundaries.644. Standardize responses.65 - success shape, errors, pagination, identifiers, timestamps665. Decide control concerns.67 - auth, rate limiting, idempotency, versioning, observability686. Document the contract in a way implementation can follow.6970## Heuristics7172- Use REST when resources and cacheable operations dominate.73- Use GraphQL when the client truly needs flexible graph traversal and multiple consumer views.74- Use tRPC when TypeScript-first internal velocity matters more than public portability.75- Keep error shapes consistent across the surface.76- Avoid exposing internal storage structure as public API design.7778## Review Questions7980- Can a new consumer understand the contract quickly?81- Are identifiers, status codes, and error shapes consistent?82- Is pagination stable and predictable?83- Can the API evolve without breaking common callers?84- Are auth and authorization boundaries obvious?8586## Related Skills8788- `architecture` for broader system-boundary decisions89- `database-design` when endpoint shape is being distorted by schema issues90- `mcp-builder` when the API surface is being adapted for tool-based LLM use91- `verification-before-completion` before claiming an API contract is ready