api-gateway

API Gateway pattern for routing. Use for microservices entry.

7 stars

Best use case

api-gateway is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

API Gateway pattern for routing. Use for microservices entry.

Teams using api-gateway 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

$curl -o ~/.claude/skills/api-gateway/SKILL.md --create-dirs "https://raw.githubusercontent.com/G1Joshi/Agent-Skills/main/skills/architecture/api-gateway/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/api-gateway/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How api-gateway Compares

Feature / Agentapi-gatewayStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

API Gateway pattern for routing. Use for microservices entry.

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

An API Gateway sits between clients (Mobile, Web) and services. It acts as a reverse proxy, accepting all API calls, aggregating the various services required to fulfill them, and returning the appropriate result.

## When to Use

- **Microservices**: Essential to hide the complexity of backend services (Service Discovery).
- **Cross-Cutting Concerns**: Centralizing Authentication, SSL Termination, Rate Limiting, and Logging.
- **Protocol Translation**: Converting HTTP (Client) to gRPC (Internal).

## Core Functionality

### Routing

`GET /users` -> User Service
`GET /orders` -> Order Service

### Aggregation (BFF - Backend for Frontend)

Combining results. One request to Gateway -> Calls User Service + Order Service -> Returns combined JSON.

### Offloading

- **Auth**: Validating JWT tokens at the edge.
- **Cache**: Serving static or cached responses.

## Common Patterns

### Backend for Frontend (BFF)

Creating specific gateways for different clients (e.g., one for Mobile with small payloads, one for Web with rich payloads).

## Best Practices

**Do**:

- Use mature tools: **Kong**, **Traefik**, **AWS API Gateway**, **Nginx**.
- Implement **Rate Limiting** to prevent DoS.
- Use **Correlation IDs** for tracing requests across services.

**Don't**:

- Don't put business logic in the Gateway (It's not a service).
- Don't let it become a Single Point of Failure (High Availability is key).

## Troubleshooting

| Error                 | Cause                                 | Solution                                          |
| :-------------------- | :------------------------------------ | :------------------------------------------------ |
| `502 Bad Gateway`     | Upstream service down or unreachable. | Check internal service health and firewall rules. |
| `504 Gateway Timeout` | Upstream taking too long.             | Optimize service or increase timeout (carefully). |

## References

- [Microservices.io - API Gateway](https://microservices.io/patterns/apigateway.html)
- [Kong Gateway](https://konghq.com/)