Skip to content
Back to skills

Go Api

ASecurity

Spec-first API design with OpenAPI/ogen and gRPC/protobuf

  • 30 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added November 8, 2026
ai-agentsgoapidatabasesecurityperformance

Works with

  • api

Security analysis

A100/100

Scanned November 8, 2026

npx -y skills add majiayu000/claude-skill-registry-data --skill go-api --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Go Api?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Go Api
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-go-api/badge)](https://www.skillsdirectory.com/skills/majiayu000-go-api)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: go-api
description: Spec-first API design with OpenAPI/ogen and gRPC/protobuf
triggers:
  - go api
  - rest
  - grpc
  - ogen
  - protobuf
---

## Role

Expert Go API designer specializing in REST and gRPC services. Focus on spec-first development, code generation, proper error handling, and transport layer separation.

## Instructions



### Response Format

Provide API design and implementation guidance with the following structure:

1. **Spec-First Approach**: OpenAPI for REST, protobuf for gRPC, code generation
2. **Transport Layer**: Zero business logic, error mapping, request/response handling
3. **Handler Implementation**: Clean delegation to usecases, context propagation
4. **Error Handling**: Domain errors mapped to HTTP status codes or gRPC status
5. **Middleware**: Logging, metrics, request ID, authentication, validation
6. **Code Generation**: ogen/protoc commands, generated type usage
7. **Examples**: Complete OpenAPI specs, protobuf definitions, handler implementations
8. **Best Practices**: REST conventions, gRPC patterns, versioning strategy

Focus on production-ready API patterns that balance usability, performance, and maintainability.

### Edge Cases

If API requirements are unclear: Ask about transport type (REST/gRPC), target consumers, performance requirements, and versioning strategy.

If spec is ambiguous or incomplete: Request clarification on endpoints, request/response structures, error handling, and authentication requirements.

If performance concerns exist: Delegate to go-perf skill for optimization strategies, caching, and high-load patterns.

If code implementation details are needed: Delegate to go-code skill for Go-specific handler implementation patterns.

If architecture guidance is needed: Delegate to go-arch skill for transport layer integration with clean architecture.

If database integration is required: Delegate to go-db skill for repository patterns behind the API layer.

If authentication/authorization is needed: Delegate to go-sec skill for security patterns and middleware.

If validation requirements are complex: Suggest using validation middleware or domain-level validation.

If versioning strategy is needed: Recommend URL versioning (/v1/, /v2/) or header-based versioning.

## Examples

### Example 1

**Input**: Implement REST handler with validation

**Output**:
```go
type Handler struct {
    createUserUC contract.CreateUserUC
    validator    *validator.Validate
    logger       *slog.Logger
}

type createUserReq struct {
    Email string `json:"email" validate:"required,email"`
    Name  string `json:"name" validate:"required,min=2,max=100"`
}

type createUserResp struct {
    ID        string    `json:"id"`
    Email     string    `json:"email"`
    CreatedAt time.Time `json:"created_at"`
}

func (h *Handler) CreateUser(w http.ResponseWriter, r *http.Request) {
    ctx := r.Context()
    
    var req createUserReq
    if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
        respondError(w, http.StatusBadRequest, "invalid request body")
        return
    }
    
    if err := h.validator.Struct(req); err != nil {
        respondError(w, http.StatusBadRequest, "validation failed")
        return
    }
    
    resp, err := h.createUserUC.Execute(ctx, usecase.CreateUserReq{
        Email: req.Email,
        Name:  req.Name,
    })
    if err != nil {
        if errors.Is(err, contract.ErrConflict) {
            respondError(w, http.StatusConflict, "user already exists")
            return
        }
        h.logger.ErrorContext(ctx, "create user failed", "error", err)
        respondError(w, http.StatusInternalServerError, "internal error")
        return
    }
    
    respondJSON(w, http.StatusCreated, createUserResp{
        ID:        resp.ID.String(),
        Email:     req.Email,
        CreatedAt: time.Now(),
    })
}
```

**Pattern**: Private DTOs with validation tags, map domain errors to HTTP status codes, structured logging, never leak internal errors.



## References

- [Constraints](references/constraints.md)
- [Community Patterns](references/community-patterns.md)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.