From golang-skills
Automatically checks and guides Go doc comment writing for exported packages, types, functions, and methods. Runs validation scripts and provides templates.
How this skill is triggered — by the user, by Claude, or both
Slash command
/golang-skills:go-documentationThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
- `scripts/check-docs.sh` - Run when checking exported functions, types, methods, constants, and packages for missing doc comments.
scripts/check-docs.sh - Run when checking exported functions, types, methods, constants, and packages for missing doc comments.scripts/check-docs-ast.go - Implementation helper invoked by check-docs.sh; patch this when changing documentation analysis behavior.assets/doc-template.go - Use when starting a documented package or exported API.references/CONVENTIONS.md - Read when documenting parameters, context behavior, concurrency safety, cleanup, errors, or named results.references/EXAMPLES.md - Read when adding runnable examples or package examples.references/FORMATTING.md - Read when formatting Godoc lists, paragraphs, links, and code blocks.Normative: All top-level exported names must have doc comments.
// 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.shto 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
main packages, use the binary name: // The seed_generator command ...doc.go fileAdvisory: 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:
ctx.Err() is implied — don't restate itCall Stop to release resources)*PathError) for correct errors.Is/errors.AsAdvisory: 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 |
Example test functions that appear in godocnpx claudepluginhub cxuu/golang-skills --plugin golang-skills2plugins reuse this skill
First indexed Jun 20, 2026
Go documentation conventions: godoc comments, package docs, testable Example functions, deprecation notices, and doc links. Use when: "add godoc", "document this package", "write doc comments", "add examples to docs", "deprecate a function", "package documentation", "improve the docs". Do NOT use for: commit messages (use git-commit), README-level project guides (plain writing task), or code style rules (use go-coding-standards).
Writes and reviews Go documentation including godoc comments, README, CONTRIBUTING, CHANGELOG, and llms.txt. Useful for generating or auditing docs for Go libraries and CLI apps.
Automatically generates documentation comments and docstrings for code functions/classes, matching project style or language conventions like Google/NumPy for Python, JSDoc for JS/TS, godoc for Go.