api-gateway-patterns
API Gateway patterns for routing, authentication, rate limiting, and service composition in microservices architectures. Use when implementing API gateways, building BFF layers, or managing service-to-service communication at scale.
Best use case
api-gateway-patterns is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
API Gateway patterns for routing, authentication, rate limiting, and service composition in microservices architectures. Use when implementing API gateways, building BFF layers, or managing service-to-service communication at scale.
Teams using api-gateway-patterns should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/api-gateway-patterns/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How api-gateway-patterns Compares
| Feature / Agent | api-gateway-patterns | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
API Gateway patterns for routing, authentication, rate limiting, and service composition in microservices architectures. Use when implementing API gateways, building BFF layers, or managing service-to-service communication at scale.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# API Gateway Patterns Expert guidance for implementing API gateways with routing, authentication, traffic management, and service composition patterns for microservices architectures at scale. ## When to Use This Skill - Implementing API gateway infrastructure for microservices - Designing Backend for Frontend (BFF) layers - Adding authentication and authorization at the gateway level - Implementing rate limiting, circuit breakers, and retry logic - Setting up service discovery and dynamic routing - Building API composition and aggregation layers - Managing cross-cutting concerns (logging, monitoring, CORS) - Evaluating gateway solutions (Kong, Nginx, Envoy, AWS API Gateway) ## Core Concepts ### Gateway Responsibilities **Routing**: Direct requests to appropriate backend services based on path, headers, or host **Security**: Centralized authentication, authorization, and API key validation **Traffic Management**: Rate limiting, circuit breakers, retry logic **Composition**: Aggregate multiple service calls into unified responses **Transformation**: Modify requests/responses for client optimization or legacy adaptation ### Architecture Patterns **Single Gateway**: One gateway for all clients (simple, potential bottleneck) **BFF Pattern**: Separate gateway per client type (mobile, web, admin) - optimized for each **GraphQL Gateway**: Schema stitching across services, client-driven data fetching **Service Mesh**: Distributed gateway pattern with sidecar proxies (Istio, Linkerd) ## Quick Reference | Task | Load reference | | --- | --- | | Routing strategies (path, header, host-based) | `skills/api-gateway-patterns/references/routing-patterns.md` | | Request/response transformation | `skills/api-gateway-patterns/references/transformation.md` | | API composition and aggregation | `skills/api-gateway-patterns/references/composition.md` | | Authentication & authorization (JWT, OAuth, RBAC) | `skills/api-gateway-patterns/references/authentication.md` | | Traffic management (rate limiting, circuit breakers) | `skills/api-gateway-patterns/references/traffic-management.md` | | Backend for Frontend (BFF) pattern | `skills/api-gateway-patterns/references/bff-pattern.md` | | Service discovery integration | `skills/api-gateway-patterns/references/service-discovery.md` | | Gateway implementations (Kong, Nginx, Envoy, AWS) | `skills/api-gateway-patterns/references/implementations.md` | ## Implementation Workflow ### Phase 1: Requirements Analysis 1. **Identify client types**: Mobile, web, admin, partners 2. **Map service landscape**: Catalog backend services and endpoints 3. **Define cross-cutting concerns**: Auth, logging, monitoring, CORS 4. **Determine composition needs**: Which endpoints require aggregation? 5. **Establish SLAs**: Latency, throughput, availability targets ### Phase 2: Gateway Design 1. **Choose architecture**: Single gateway vs BFF vs GraphQL 2. **Select implementation**: Kong, Nginx, Envoy, AWS API Gateway 3. **Design routing rules**: Path-based, header-based, host-based 4. **Plan authentication**: JWT, OAuth 2.0, API keys, or hybrid 5. **Define traffic policies**: Rate limits, circuit breakers, timeouts ### Phase 3: Implementation 1. **Set up infrastructure**: Deploy gateway instances, configure load balancer 2. **Implement routing**: Configure service discovery and route definitions 3. **Add authentication**: JWT validation, OAuth integration, API key management 4. **Apply traffic management**: Rate limiting, circuit breakers, retry logic 5. **Enable observability**: Distributed tracing, metrics, structured logging ### Phase 4: Testing & Optimization 1. **Load testing**: Verify performance under expected and peak load 2. **Failure injection**: Test circuit breakers and retry logic 3. **Security testing**: Verify auth flows, token validation, RBAC policies 4. **Latency optimization**: Cache strategies, connection pooling 5. **Monitor and tune**: Adjust timeouts, limits based on real traffic ## Best Practices 1. **Centralize Cross-Cutting Concerns**: Authentication, logging, monitoring at gateway 2. **Keep Gateway Lightweight**: Avoid complex business logic, delegate to services 3. **Implement Health Checks**: Monitor upstream service health, remove unhealthy instances 4. **Use Circuit Breakers**: Prevent cascading failures, fail fast 5. **Apply Rate Limiting**: Protect services from overload, implement tiered limits 6. **Enable Observability**: Distributed tracing, metrics, structured logging 7. **Version APIs**: Support multiple API versions, plan deprecation 8. **Secure Communication**: TLS everywhere, mutual TLS for service-to-service 9. **Cache Strategically**: Response caching, but invalidate properly 10. **Test Resilience**: Chaos engineering, failure injection, load testing ## Common Mistakes 1. **Business Logic in Gateway**: Keep gateway focused on routing/security, not business rules 2. **Chatty Composition**: Too many upstream calls (use BFF, GraphQL, or caching) 3. **Single Point of Failure**: Deploy redundantly, use load balancers 4. **No Timeout Configuration**: Always set connection/read timeouts to prevent hanging requests 5. **Ignoring Backpressure**: Implement queue limits, graceful degradation 6. **Over-Aggregation**: Don't make gateway do too much work (compute-heavy transformations) 7. **Inadequate Monitoring**: Must track latency, errors, throughput at gateway level 8. **No Rate Limiting**: Services will be overwhelmed eventually without protection 9. **Synchronous Everything**: Use async patterns for non-critical operations 10. **No Version Strategy**: Breaking changes break all clients simultaneously ## Resources - **Kong**: https://docs.konghq.com/gateway/latest/ - **Nginx**: https://nginx.org/en/docs/ - **Envoy**: https://www.envoyproxy.io/docs/envoy/latest/ - **AWS API Gateway**: https://docs.aws.amazon.com/apigateway/ - **Patterns**: "Microservices Patterns" by Chris Richardson - **Service Mesh**: https://istio.io/latest/docs/ - **Circuit Breakers**: Martin Fowler's CircuitBreaker pattern - **BFF Pattern**: Sam Newman's "Building Microservices"
Related Skills
llm-app-patterns
Production-ready patterns for building LLM applications. Covers RAG pipelines, agent architectures, prompt IDEs, and LLMOps monitoring. Use when designing AI applications, implementing RAG, building agents, or setting up LLM observability.
dbt-transformation-patterns
Master dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or ...
data-fetching-patterns
Explains data fetching strategies including fetch on render, fetch then render, render as you fetch, and server-side data fetching. Use when implementing data loading, optimizing loading performance, or choosing between client and server data fetching.
airflow-dag-patterns
Build production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.
ai-product-patterns
Builds AI-native products using OpenAI's development philosophy and modern AI UX patterns. Use when integrating AI features, designing for model improvements, implementing evals as product specs, or creating AI-first experiences. Based on Kevin Weil (OpenAI CPO) on building for future models, hybrid approaches, and cost optimization.
a2a-executor-patterns
Agent-to-Agent (A2A) executor implementation patterns for task handling, execution management, and agent coordination. Use when building A2A executors, implementing task handlers, creating agent execution flows, or when user mentions A2A protocol, task execution, agent executors, task handlers, or agent coordination.
GitOps Patterns
ArgoCD ApplicationSets, progressive delivery, Harness GitX, and multi-cluster GitOps patterns
dotnet-gha-patterns
Composes GitHub Actions workflows. Reusable workflows, composite actions, matrix, caching.
bats-testing-patterns
Comprehensive guide for writing shell script tests using Bats (Bash Automated Testing System). Use when writing or improving tests for Bash/shell scripts, creating test fixtures, mocking commands, or setting up CI/CD for shell script testing. Includes patterns for assertions, setup/teardown, mocking, fixtures, and integration with GitHub Actions.
bash-defensive-patterns
Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.
apollo-client-patterns
Use when implementing Apollo Client patterns for queries, mutations, cache management, and local state in React applications.
url-routing-patterns
Use when designing URL structures, slug generation, SEO-friendly URLs, redirects, or localized URL patterns. Covers route configuration, URL rewriting, canonical URLs, and routing APIs for headless CMS.