api-server
Provides patterns and standards for building robust REST APIs and middleware using Go.
Install
mkdir -p .claude/skills/api-server && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5098" && unzip -o skill.zip -d .claude/skills/api-server && rm skill.zipInstalls to .claude/skills/api-server
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Build HTTP services, REST APIs, and middleware in Go. Use when building Go HTTP servers, REST APIs, or custom middleware.Key capabilities
- →Implement REST API endpoints
- →Develop custom middleware
- →Configure HTTP service architecture
- →Handle graceful shutdowns
How it works
The skill provides standards for building Go HTTP services, emphasizing separation of concerns, middleware usage, and graceful shutdown patterns.
Inputs & outputs
When to use api-server
- →Create new REST API endpoint
- →Implement Go middleware
- →Define API service architecture
About this skill
Golang API Server
Priority: P0 (CRITICAL)
Router & GraphQL Selection
- Standard Lib (
net/http): Use for simple services or zero-dependency requirements.http.ServeMux(Go 1.22+) method-based routing. - Echo (
labstack/echo) / Gin: Recommended for production REST APIs with middleware, binding, and error handling. - GraphQL (
99designs/gqlgen): Standard for schema-first GraphQL services. Handlers/resolvers act as thin transport adapters.
Implementation Workflow
- Choose transport layer — REST (Echo/Gin/stdlib) or GraphQL (gqlgen).
- Thin Handlers & Resolvers — Handlers and resolvers parse/validate inputs, invoke use-case services, and map to transport models. Zero direct database queries or business rules.
- Transport-to-Domain Mapping — Domain models remain pure; transport models adapt to domain models via dedicated mappers.
- Response Nullability & Slice Defaulting — Default empty slices to
[](notnull) unless the schema explicitly requires null. Avoid unnecessarynullablefields in GraphQL response schemas when zero-values suffice. - Add middleware — Use middleware for cross-cutting concerns (Logging, Recovery, CORS, Auth, Tracing, RequestID).
- Enforce pagination limits — Support
first/after(GraphQL cursor) orlimit/offset(REST) with strict max caps to prevent memory exhaustion. - Implement graceful shutdown — Handle SIGINT/SIGTERM to drain in-flight requests.
See graceful shutdown example and Echo handler patterns
Anti-Patterns
- No business logic in handlers or resolvers: parse request, call service, and format response only.
- No direct DB calls in resolvers: resolvers must call service interfaces, never execute SQL queries.
- No nil slices in responses: return empty slice
[]rather thannullin API responses unless distinguishing null from empty. - No global router/schema vars: pass router/handler dependencies explicitly via constructor.
- No missing shutdown: handle SIGTERM to drain in-flight requests.
References
When not to use it
- →Non-HTTP service development
Limitations
- →Requires Go language knowledge
How it compares
It enforces architectural standards and best practices for Go APIs rather than allowing unstructured implementation.
Compared to similar skills
api-server side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| api-server (this skill) | 1 | 2mo | No flags | Intermediate |
| templ-htmx | 3 | 8mo | No flags | Intermediate |
| ccxt-go | 1 | 8mo | Review | Intermediate |
| generating-grpc-services | 1 | 2mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by HoangNguyen0403
View all by HoangNguyen0403 →You might also like
templ-htmx
Xe
Build interactive hypermedia-driven applications with templ and HTMX. Use when creating dynamic UIs, real-time updates, AJAX interactions, mentions 'HTMX', 'dynamic content', or 'interactive templ app'.
ccxt-go
ccxt
CCXT cryptocurrency exchange library for Go developers. Covers both REST API (standard) and WebSocket API (real-time). Helps install CCXT, connect to exchanges, fetch market data, place orders, stream live tickers/orderbooks, handle authentication, and manage errors in Go projects. Use when working with crypto exchanges in Go applications, microservices, or trading systems.
generating-grpc-services
jeremylongshore
Generate gRPC service definitions, stubs, and implementations from Protocol Buffers. Use when creating high-performance gRPC services. Trigger with phrases like "generate gRPC service", "create gRPC API", or "build gRPC server".
higress-wasm-go-plugin
alibaba
Develop Higress WASM plugins using Go 1.24+. Use when creating, modifying, or debugging Higress gateway plugins for HTTP request/response processing, external service calls, Redis integration, or custom gateway logic.
API service
TheBearIsOne
Use this skill when: - adding HTTP endpoints; - defining request and response models; - wiring document generation into an API surface; - shaping controller, route, or handler behavior.
senior-backend
Cor-Incorporated
Guides backend system development with Node.js, Express, Go, Python, PostgreSQL, GraphQL, and REST APIs. Use when the user says: 'design an API', 'optimize database queries', 'implement authentication', 'set up backend', 'create API endpoint', 'database migration', 'fix N+1 query', 'add rate limitin