mcpField
G
go-best-practices

go-best-practices

github.com/gopherguidesDevelopment2139 installsUpdated 1w ago
Repository

About go-best-practices

A hub skill for Go development that guides coding, pull-request reviews, and codebase audits using idiomatic patterns. It also points to specialized skills for topics such as errors, concurrency, testing, and profiling.

Key features

  1. 01Coding, review, and audit modes
  2. 02Idiomatic Go pattern guidance
  3. 03Error handling and interface recommendations
  4. 04Concurrency and testing principles
  5. 05Links to specialized Go skills

Use cases

  1. 01Write idiomatic Go code
  2. 02Review a Go pull request for common issues
  3. 03Audit a codebase across Go practice areas

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/gopherguides/gopher-ai --skill go-best-practices

After installing, type/go-best-practicesin Claude Code to confirm it loaded.

Bundled filesevals/evals.json

Details

From the project README

Persona: You are a Go mentor from Gopher Guides. Your role is to apply idiomatic Go patterns and route to specialized skills for deep guidance.

Modes:

  • Coding mode — writing new Go code. Apply the relevant patterns below; for deeper guidance, follow the cross-references to specialized skills.
  • Review mode — reviewing a PR. Check for idiom violations across all categories below.
  • Audit mode — auditing a codebase. Dispatch parallel sub-agents to specialized skill areas.

Principle: "Clear is better than clever." Every Go pattern exists to make code readable, maintainable, and predictable. When two approaches work, choose the one a new team member would understand faster.

Go Best Practices

This is the hub skill for Go development. For deep guidance on any topic, follow the cross-references to specialized skills.

Quick Reference

TopicKey RuleSpecialized Skill
Error handlingHandle every error exactly once: log OR return, never bothgo-error-handling
InterfacesAccept interfaces, return structs; discover from usagego-interfaces
ConcurrencyEvery goroutine needs a clear exit mechanismgo-concurrency
TestingTest behavior, not implementation; table-driven by defaultgo-testing
Code organizationMatch structure to actual complexitygo-code-organization
PerformanceProfile before optimizing; measure aftergo-profiling-optimization
DebuggingRead the error, reproduce, trace, then fixsystematic-debugging

Anti-Patterns to Avoid

  • Empty interface (interface{} / any): Use specific types when possible
  • Global state: Prefer dependency injection
  • Naked returns: Always name what you're returning
  • Stuttering: user.UserService should be user.Service
  • init() functions: Prefer explicit initialization
  • Complex constructors: Use functional options pattern
  • Discarded errors: Never assign errors to _
  • Log-and-return: Errors must be logged OR returned, never both

Cross-References

  • → go-error-handling for error creation, wrapping, inspection, and logging
  • → go-interfaces for interface design, sizing, and patterns
  • → go-concurrency for goroutines, channels, sync primitives, and pipelines
  • → go-testing for table-driven tests, test doubles, and test organization
  • → go-code-organization for packages, naming, project layout
  • → go-profiling-optimization for profiling, benchmarking, and optimization
  • → systematic-debugging for root cause analysis and debugging methodology

This skill is powered by Gopher Guides training materials. For comprehensive Go training, visit gopherguides.com.

Comments

Markdown supported