go-code-review
Use when reviewing Go code or checking code against community style standards. Also use proactively before submitting a Go PR or…
Use when writing or reviewing documentation for Go packages, types, functions, or methods. Also use proactively when creating new exported types, functions, or packages, even if the user doesn't explicitly ask about documentation. Does not cover code comments for non-exported
$ npx -y skills add cxuu/golang-skills --skill go-documentation --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/go-documentationContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when writing or reviewing documentation for Go packages, types, functions, or methods. Also use proactively when creating new exported types, functions, or packages, even if the user doesn't explicitly ask about documentation. Does not cover code comments for non-exported
name: go-documentation description: Use when writing or reviewing documentation for Go packages, types, functions, or methods. Also use proactively when creating new exported types, functions, or packages, even if the user doesn't explicitly ask about documentation. Does not cover code comments for non-exported symbols (see go-style-core). allowed-tools: Bash(bash:*)
---
> **Normative**: All top-level exported names must have doc comments.
1. Begin with the name of the object being described 2. An article ("a", "an", "the") may precede the name 3. Use full sentences (capitalized, punctuated)
// A Request represents a request to run a command.
type Request struct { ...
// Encode writes the JSON encoding of req to w.
func Encode(w io.Writer, req *Request) { ...Unexported types/functions with unobvious behavior should also have doc comments.
> **Validation**: After adding doc comments, run `bash scripts/check-docs.sh` to verify no exported symbols are missing documentation. Fix any gaps before proceeding.
---
> **Normative**: Documentation comments must be complete sentences.
---
> **Advisory**: Aim for ~80 columns, but no hard limit.
Break based on punctuation. Don't split long URLs.
---
Group fields with section comments. Mark optional fields with defaults:
type Options struct {
// General setup:
Name string
Group *FooGroup
// Customization:
LargeGroupThreshold int // optional; default: 10
}---
> **Normative**: Every package must have exactly one package comment.
// Package math provides basic constants and mathematical functions. package math
---
> **Advisory**: Document non-obvious behavior, not obvious behavior.
| Topic | Document when... | Skip when... | |-------|-----------------|--------------| | Parameters | Non-obvious behavior, edge cases | Restates the type signature | | Contexts | Behavior differs from standard cancellation | Standard `ctx.Err()` return | | Concurrency | Ambiguous thread safety (e.g., read that mutates) | Read-only is safe, mutation is unsafe | | Cleanup | Always document resource release | — | | Errors | Sentinel values, error types (use `*PathError`) | — | | Named results | Multiple params of same type, action-oriented names | Type alone is clear enough |
Key principles:
---
> **Advisory**: Provide runnable examples in test files (`*_test.go`).
func ExampleConfig_WriteTo() {
cfg := &Config{Name: "example"}
cfg.WriteTo(os.Stdout)
// Output:
// {"name": "example"}
}Examples appear in Godoc attached to the documented element.
---
| Topic | Key Rule | |-------|----------| | Doc comments | Start with name, use full sentences | | Line length | ~80 chars, prioritize readability | | Package comments | One per package, above `package` clause | | Parameters | Document non-obvious behavior only | | Contexts | Document exceptions to implied behavior | | Concurrency | Document ambiguous thread safety | | Cleanup | Always document resource release | | Errors | Document sentinels and types (note pointer) | | Examples | Use runnable examples in test files | | Formatting | Blank lines for paragraphs, indent for code |
---
AI Agent Skills for writing idiomatic, production-quality Go code. 20 modular skills teach AI coding assistants Go best practices derived from: Google Go Style Guide Effective Go Uber Go Style Guide Go Wiki CodeReviewComments Skills are tuned following
Use when reviewing Go code or checking code against community style standards. Also use proactively before submitting a Go PR or…
Use when writing concurrent Go code — goroutines, channels, mutexes, or thread-safety guarantees. Also use when parallelizing…
Use when working with context.Context in Go — placement in signatures, propagating cancellation and deadlines, and storing values…
Use when writing conditionals, loops, or switch statements in Go — including if with initialization, early returns, for loop…
Use when working with Go slices, maps, or arrays — choosing between new and make, using append, declaring empty slices (nil vs…
Use when declaring or initializing Go variables, constants, structs, or maps — including var vs :=, reducing scope with if-init,…