
Go Documentation
Write package, type, function, and constant doc comments that follow Google Go Style Guide conventions for godoc and pkg.go.dev.
Overview
go-documentation is an agent skill for the Build phase that teaches and applies Google-style Go doc comments for packages, types, functions, and constants.
Install
npx skills add https://github.com/cxuu/golang-skills --skill go-documentationWhat is this skill?
- Package doc with overview, Getting Started section, and cross-links like [NewWidget]
- Documented exported errors (ErrNotFound), constants (MaxRetries), and types with concurrency and cleanup notes
- Function and method comments with parameter behavior, panic rules, and linked symbol references
- Deprecated API pattern with replacement pointer (NewWidgetLegacy → NewWidget)
- Aligns comments with Google Go Style Guide for pkg.go.dev readability
- Demonstrates package, type, function, method, and constant doc patterns in one example module
Adoption & trust: 696 installs on skills.sh; 110 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your Go repo ships exported APIs but comments are missing, inconsistent, or fail pkg.go.dev linking conventions.
Who is it for?
Indie developers publishing Go modules or internal packages who want godoc-ready comments in the same coding session.
Skip if: Non-Go stacks, OpenAPI-only external docs with no godoc surface, or architecture RFCs unrelated to source comments.
When should I use this skill?
When documenting Go packages and exported symbols to follow Google Go Style Guide godoc conventions.
What do I get? / Deliverables
Exported Go symbols gain structured doc comments with cross-references, error documentation, deprecation notices, and reader-friendly package overviews.
- Documented Go source with package overview and symbol-level comments
- Deprecated notices with replacement links
Recommended Skills
Journey fit
How it compares
Use for inline godoc on Go symbols; use a general Documentation skill for READMEs and user guides outside Go source files.
Common Questions / FAQ
Who is go-documentation for?
go-documentation is for solo builders and small teams writing Go libraries, CLIs, or services who want agent help matching Google Go documentation conventions.
When should I use go-documentation?
Use it during Build while authoring or refactoring exported Go APIs, before Ship review, whenever you add packages, types, or public functions that must appear clearly on pkg.go.dev.
Is go-documentation safe to install?
Review the Security Audits panel on this Prism page; the skill is documentation-oriented example code without implied network or secret access.
SKILL.md
READMESKILL.md - Go Documentation
// Package example demonstrates proper Go documentation conventions. // // This package shows how to write doc comments for packages, types, // functions, methods, and constants following Google Go Style Guide // conventions. // // # Getting Started // // Create a new Widget with [NewWidget]: // // w := example.NewWidget("name") // defer w.Close() package example import "errors" // ErrNotFound is returned when a requested item does not exist. var ErrNotFound = errors.New("example: not found") // MaxRetries is the default number of retry attempts. const MaxRetries = 3 // Widget processes items with configurable options. // // A zero-value Widget is not valid; use [NewWidget] to create one. // Widget is safe for concurrent use. // // # Cleanup // // Call [Widget.Close] when done to release resources. type Widget struct { name string } // NewWidget creates a Widget with the given name. // // Name must be non-empty; NewWidget panics otherwise. func NewWidget(name string) *Widget { if name == "" { panic("example: name must be non-empty") } return &Widget{name: name} } // Process handles the given input and returns the result. // // Process returns [ErrNotFound] if the input references // a missing item. func (w *Widget) Process(input string) (string, error) { return input, nil } // Close releases resources held by the Widget. func (w *Widget) Close() error { return nil } // Deprecated: Use [NewWidget] with functional options instead. func NewWidgetLegacy(name string) *Widget { return NewWidget(name) } # Documentation Conventions Reference ## Parameters and Configuration > **Advisory**: Document error-prone or non-obvious parameters, not everything. ```go // Bad: Restates the obvious // Sprintf formats according to a format specifier and returns the resulting string. // // format is the format, and data is the interpolation data. func Sprintf(format string, data ...any) string // Good: Documents non-obvious behavior // Sprintf formats according to a format specifier and returns the resulting string. // // The provided data is used to interpolate the format string. If the data does // not match the expected format verbs or the amount of data does not satisfy // the format specification, the function will inline warnings about formatting // errors into the output string. func Sprintf(format string, data ...any) string ``` --- ## Contexts > **Advisory**: Don't restate implied context behavior; document exceptions. Context cancellation is implied to interrupt the function and return `ctx.Err()`. Don't document this. ```go // Bad: Restates implied behavior // Run executes the worker's run loop. // // The method will process work until the context is cancelled. func (Worker) Run(ctx context.Context) error // Good: Just the essential // Run executes the worker's run loop. func (Worker) Run(ctx context.Context) error ``` **Document when behavior differs:** ```go // Good: Non-standard cancellation behavior // Run executes the worker's run loop. // // If the context is cancelled, Run returns a nil error. func (Worker) Run(ctx context.Context) error // Good: Special context requirements // NewReceiver starts receiving messages sent to the specified queue. // The context should not have a deadline. func NewReceiver(ctx context.Context) *Receiver ``` --- ## Concurrency > **Advisory**: Document non-obvious thread safety characteristics. Read-only operations are assumed safe; mutating operations are assumed unsafe. Don't restate this. **Document when:** ```go // Ambiguous operation (looks read-only but mutates internally) // Lookup returns the data associated with the key from the cache. // // This operation is not safe for concurrent use. func (*Cache) Lookup(key string) (data []byte, ok bool) // API provides synchronization // NewFortuneTellerClient returns an *rpc.Client for the FortuneTeller service. // It is safe for simultaneous use by multiple goroutines. func NewFortuneTellerClient(cc *rpc.ClientConn)