BACK TO TEMPLATES
rulesany
Go Microservice Rules
Standard AGENTS.md for Golang microservices covering interface definitions, context propagation, and golangci-lint.
When to use this
Place this template in Go microservice repositories to enforce Go idioms, error wrapping, context propagation, and strict linter rules.
The template
# AGENTS.md
## Project Context
Go microservice enforcing clean architecture, gRPC/REST APIs, and structured logging.
## Commands
- `go run ./cmd/server` start service executable
- `go test -v ./...` execute unit test suite
- `golangci-lint run` execute comprehensive static code linter
Run `golangci-lint run` and `go test ./...` before submitting changes.
## Conventions
- Always accept `context.Context` as the first argument in I/O operations and handlers.
- Return explicit error values. Wrap errors with context: `fmt.Errorf("action failed: %w", err)`.
- Define interfaces where consumed, keeping interfaces small and focused.
- Package layout follows standard Go layout (`cmd/`, `internal/`, `pkg/`).
## Strict Restrictions
- Do not ignore returned errors using blank identifiers `_` in production logic.
- Do not store request-scoped data in global package variables.
- Do not panic in HTTP/gRPC request handler execution branches.
## Approval Required
- Adding new third-party Go modules (`go get`).
- Modifying Proto or OpenAPI schema files.Customization Guide
Update package directories and lint command configurations based on your project requirements.
Last verified 2026-07-26