API Patterns
Selective Reading Rule
Start with:
references/usage-routing.mdreferences/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.mdfor senior-level contract design and reviewreferences/api-review-checklist.mdfor final review before implementationapi-style.mdfor REST vs GraphQL vs tRPCrest.mdfor REST endpoint and resource designgraphql.mdfor GraphQL fit and schema considerationstrpc.mdfor TypeScript-first monorepo APIsresponse.mdfor envelopes, pagination, and error contractsversioning.mdfor API evolutionauth.mdfor authentication and caller identityrate-limiting.mdfor abuse protectiondocumentation.mdfor API docs and discoverabilitysecurity-testing.mdwhen 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
architecturefor broader system-boundary decisionsdatabase-designwhen endpoint shape is being distorted by schema issuesmcp-builderwhen the API surface is being adapted for tool-based LLM useverification-before-completionbefore claiming an API contract is ready