api-patterns
API Integration Patterns
Pick the protocol by data shape, ownership, and runtime constraints. Avoid mixing patterns without a clear boundary.
Selection Guide
- REST:
- Standard CRUD, broad client compatibility, simple caching.
- GraphQL:
- Flexible read models, multi-client data composition, schema governance.
- WebSocket:
- Bi-directional real-time channels with low-latency updates.
- SSE:
- Server-to-client streaming where client push is unnecessary.
- tRPC:
- End-to-end TypeScript contracts in monorepos.
Use This Skill When
- You need to define or refactor API boundaries.
- Frontend/server data fetching strategy is unclear.
- Real-time transport choice is blocking implementation.
Implementation Workflow
1) Define API Contract
- Identify resource ownership and versioning strategy.
- Define request/response shapes and error model.
- Standardize auth, pagination, filtering, and idempotency.
2) Choose Transport
- REST for core CRUD.
- GraphQL for query composition.
- WebSocket/SSE for live updates.
- tRPC when shared TS types are required and service boundary allows it.
3) Standardize Client Layer
- Central client factory and interceptors.
- Typed API wrappers.
- Uniform retries/timeouts and auth refresh logic.
- Cache and invalidation rules documented per endpoint group.
4) Error and Observability
- Consistent API error envelope.
- Correlation IDs and request tracing.
- Log validation and transport failures separately.
5) Security Baseline
- Validate input schema at API boundary.
- Enforce authz at resource/action level.
- Apply rate limiting and payload size limits.
Output Requirements for Agent
- Recommended transport and why.
- Endpoint/schema proposal.
- Client integration pattern.
- Real-time model if needed.
- Security and testing checklist.
References
- Full templates for REST, GraphQL, WebSocket, SSE, and tRPC:
references/guide.md
More from alicoder001/agent-skills
reasoning
Chain-of-thought reasoning, self-reflection, and systematic problem-solving patterns for AI agents. Use before any complex task to ensure logical and accurate solutions.
38typescript
TypeScript strict mode patterns, naming conventions, and type safety rules. Use when writing TypeScript code, defining types, or reviewing TypeScript projects. Includes generics, utility types, and best practices.
35collaboration
Multi-agent communication, task delegation, and coordination patterns. Use when working with multiple agents or complex collaborative workflows.
27solid
SOLID, DRY, KISS, and clean code principles for TypeScript applications. Use when designing scalable architecture, writing maintainable code, or reviewing code quality.
25security
Security best practices for web applications. Use when handling user input, authentication, or sensitive data. Covers XSS, SQL injection, CSRF, environment variables, and secure coding patterns.
22memory
Working memory management, context prioritization, and knowledge retention patterns for AI agents. Use when you need to maintain relevant context and avoid information loss during long tasks.
22