agentleFS
MindrallyMindrally/skills/go-backend-microservices/SKILL.md

go-backend-microservices

Skill275 starsChanged 53 days agoApache-2.0View on GitHub

Go backend development best practices for microservices with clean architecture, observability, and production-ready patterns

The file

Show its rules and text

We split this skill into the rules it gives an agent

22 rules. About 0 are common, 21 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈21

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write short, focused functions with a single responsibility

    line 15
  2. Distinctive:

    Ensure safe use of goroutines, and guard shared state with channels or sync primitives

    line 16
  3. Distinctive:

    Always check and handle errors explicitly

    line 34
  4. Very specific:

    Use wrapped errors for traceability: fmt.Errorf("context: %w", err)

    line 35
  5. Distinctive:

    Create custom error types for domain-specific errors

    line 36
  6. Distinctive:

    Use context propagation for request-scoped values, deadlines, and cancellations

    line 42
  7. Distinctive:

    Add spans for significant operations

    line 52
  8. Distinctive:

    Use standard metric types (counters, gauges, histograms)

    line 58
  9. Distinctive:

    Use structured logging with consistent field names

    line 62
  10. Distinctive:

    Use secure defaults for JWT tokens and cookies

    line 69
  11. Distinctive:

    Use prepared statements for database queries

    line 72
  12. Distinctive:

    Write table-driven unit tests with adequate coverage

    line 77
  13. Distinctive:

    Use parallel test execution where safe

    line 78
  14. Distinctive:

    Use test containers for database and service dependencies

    line 84
  15. Distinctive:

    Test actual API endpoints and responses

    line 85
  16. Distinctive:

    Use goroutines appropriately for concurrent operations

    line 89
  17. Distinctive:

    Use worker pools for bounded concurrency

    line 92
  18. Distinctive:

    Document with GoDoc-style comments

    line 96
  19. Distinctive:

    Keep comments up to date with code changes

    line 97
  20. Distinctive:

    Document public APIs thoroughly

    line 98
  21. Distinctive:

    Use golangci-lint for comprehensive linting

    line 104
  22. Distinctive:

    Run tests on every pull request

    line 105

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Go Backend Development for Microservices

Core Principles

  • Apply Clean Architecture with clear separation into handlers, services, repositories, and domain models
  • Prioritize interface-driven development with explicit dependency injection
  • Write short, focused functions with a single responsibility
  • Ensure safe use of goroutines, and guard shared state with channels or sync primitives

Project Structure

Maintain modular project structure with clear directories:

project/
├── cmd/           # Application entry points
├── internal/      # Private application code
├── pkg/           # Public library code
├── api/           # API definitions (OpenAPI, protobuf)
├── configs/       # Configuration files
└── test/          # Additional test utilities

Error Handling

  • Always check and handle errors explicitly
  • Use wrapped errors for traceability: fmt.Errorf("context: %w", err)
  • Create custom error types for domain-specific errors
  • Return errors up the call stack with appropriate context
  • Log errors at the appropriate level with sufficient context

Context Propagation

  • Use context propagation for request-scoped values, deadlines, and cancellations
  • Pass context as the first parameter to functions
  • Respect context cancellation in long-running operations
  • Set appropriate timeouts for external calls

Observability

Implement OpenTelemetry for comprehensive observability:

Distributed Tracing

  • Add spans for significant operations
  • Propagate trace context across service boundaries
  • Include relevant attributes in spans

Metrics

  • Implement custom metrics for business operations
  • Use standard metric types (counters, gauges, histograms)
  • Export metrics in Prometheus format

Structured Logging

  • Use structured logging with consistent field names
  • Include trace IDs in log entries
  • Log at appropriate levels (debug, info, warn, error)

Security

  • Apply input validation rigorously on all external inputs
  • Use secure defaults for JWT tokens and cookies
  • Implement proper authentication and authorization
  • Sanitize data before logging to avoid leaking sensitive information
  • Use prepared statements for database queries

Testing

Unit Tests

  • Write table-driven unit tests with adequate coverage
  • Use parallel test execution where safe
  • Mock external dependencies using interfaces
  • Focus on testing business logic

Integration Tests

  • Separate integration tests from unit tests
  • Use test containers for database and service dependencies
  • Test actual API endpoints and responses

Concurrency

  • Use goroutines appropriately for concurrent operations
  • Guard shared state with channels or sync primitives
  • Implement proper graceful shutdown
  • Use worker pools for bounded concurrency

Documentation

  • Document with GoDoc-style comments
  • Keep comments up to date with code changes
  • Document public APIs thoroughly
  • Include examples in documentation where helpful

CI/CD Integration

  • Maintain CI integration for linting and testing
  • Use golangci-lint for comprehensive linting
  • Run tests on every pull request
  • Include code coverage reporting

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.