go-documentation
Skill85 starsChanged 18 days agoMITView on GitHub
Go documentation conventions: godoc comments, package docs, testable Example functions, deprecation notices, doc links, and project docs (README, CHANGELOG, llms.txt). Use when: "add godoc", "document this package", "write doc comments", "add examples to docs", "deprecate a function", "write a README", "update the changelog", "improve the docs". Not for: commit messages (git-commit), code style (go-coding-standards).
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
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
- Distinctive: line 33
Read a reference file only when the summary below is not enough.
- Distinctive: line 37
Every exported identifier gets a doc comment.
- Very specific: line 116
Write an example for every non-trivial exported API.
- Distinctive: line 130
Always name the replacement.
- Distinctive: line 146
If a doc comment can only restate the signature, improve the name until the comment says something the signature can't — or accept a …
- Distinctive: line 181
Every exported identifier has a doc comment starting with its name
- Distinctive: line 188
No comments restating signatures, tracking history, or holding dead code
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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.
Files
Go Documentation
Godoc is not free-form prose — it's a convention the toolchain renders. Comments that follow the convention become browsable documentation on pkg.go.dev; comments that don't become noise.
Community default. A project skill or agent-config rule that explicitly supersedes
go-documentationtakes precedence over this one.
Detailed reference material, loaded on demand:
references/project-docs.md— README templates for libraries and services, CHANGELOG, llms.txt, CONTRIBUTING.
Read a reference file only when the summary below is not enough.
1. Doc Comment Form
Every exported identifier gets a doc comment. It starts with the identifier's name and is a complete sentence:
// ✅ Good
// ParseDuration parses a duration string such as "300ms" or "2h45m".
// It returns an error if the string is not a valid duration.
func ParseDuration(s string) (Duration, error) { ... }
// ❌ Bad — doesn't start with the name, fragment, restates signature
// this function parses durations
func ParseDuration(s string) (Duration, error) { ... }- Groups of related constants/variables may share one comment on the
block:
// Common HTTP methods.above theconst (...)group. - Unexported identifiers: comment when the purpose isn't obvious from the name — same form, no obligation.
- Say what the caller needs: behavior, error conditions, nil/zero-value handling, concurrency safety. Not the implementation.
2. Package Documentation
One package comment per package, on the package clause. For more than
a few sentences, put it in a dedicated doc.go:
// Package retry implements backoff strategies for retrying failed
// operations.
//
// The zero value of Policy retries three times with exponential
// backoff. Use functional options to customize:
//
// p := retry.NewPolicy(retry.WithMaxAttempts(5))
// err := p.Do(ctx, fetchUser)
package retry- Begins with "Package
<name>...". - Indented lines (one tab) render as code blocks.
mainpackages: the comment describes the command and its flags — it becomes the command's documentation.
3. Doc Links and Formatting (Go 1.19+)
// Fetch retrieves the resource. It honors the deadline of ctx and
// returns [ErrNotFound] if the resource does not exist.
//
// For batch retrieval use [Client.FetchAll]. See the [net/http]
// package for transport configuration.
func (c *Client) Fetch(ctx context.Context, id string) (*Resource, error)[Name],[Type.Method],[pkg/path]become hyperlinks on pkg.go.dev.- A line starting with
#is a heading (rare; only in long package docs). - Lists: lines starting with a space and a bullet. Keep them shallow.
4. Testable Examples
Example functions are documentation the compiler checks. Put them in
example_test.go in the <pkg>_test package:
func ExampleParseDuration() {
d, _ := ParseDuration("1h30m")
fmt.Println(d.Minutes())
// Output: 90
}
// Method example: ExampleType_Method
func ExamplePolicy_Do() { ... }
// Second example for the same symbol: suffix
func ExampleParseDuration_negative() { ... }- The
// Output:comment makes it a test —go testfails if the printed output differs. Examples without it compile but don't run. - Write an example for every non-trivial exported API. It renders directly under the symbol on pkg.go.dev.
5. Deprecation
// Fetch retrieves the resource.
//
// Deprecated: Use [Client.FetchContext] instead, which honors
// context cancellation.
func (c *Client) Fetch(id string) (*Resource, error)- The paragraph must start exactly with
Deprecated:. - Always name the replacement.
- Tools (gopls, staticcheck, pkg.go.dev) surface these automatically.
6. What NOT to Write
// ❌ Noise — restates the code
// GetName returns the name.
func (u *User) GetName() string { return u.name }
// ❌ Maintenance history — belongs in git
// Changed 2024-03-01 by alice: added caching.
// ❌ Commented-out code kept "for reference"If a doc comment can only restate the signature, improve the name until the comment says something the signature can't — or accept a minimal comment for symmetry in a fully documented API.
7. Project-Level Documentation
- README — a library leads with what it does, install, the minimal working example, and a pkg.go.dev link instead of duplicating the API. A service leads with how to run it, its configuration table (generated from the config struct where possible), and where health, metrics and runbooks live.
- CHANGELOG — Keep a Changelog sections (Added, Changed, Deprecated, Removed, Fixed, Security), written for the module's users, not as a commit log.
- llms.txt — a short Markdown index at the docs root pointing AI assistants at the API reference and examples.
- Go 1.27+:
go doc example.com/pkg@v1.2.3reads another version's docs without changinggo.mod;go doc -exlists executable examples.
Templates: references/project-docs.md.
Executable Verification
go vet ./... # flags some malformed doc comments
gofmt -l . # Go 1.19+ gofmt normalizes doc comments
go test ./... # runs Example functions with Output
go doc ./mypkg Symbol # render what users will actually seeFor a browsable preview, run a local pkgsite if available:
go run golang.org/x/pkgsite/cmd/pkgsite@latest and open the module.
Verification Checklist
- Every exported identifier has a doc comment starting with its name
- Package has a package comment ("Package
<name>..."), in doc.go if long - Error conditions and nil/zero-value behavior documented for exported APIs
- Concurrency safety stated where callers could guess wrong
[Symbol]doc links used instead of bare names in running text- Non-trivial exported APIs have Example functions with
// Output: - Deprecations use the exact
Deprecated:form and name a replacement - No comments restating signatures, tracking history, or holding dead code
go test ./...passes with examples enabled- README leads with purpose and a working example; CHANGELOG updated for user-visible changes
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- h0rn3t/golang-skills★ 7same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository38 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/go-skills.mdcCursor rule
- go-api-designSkill
- go-architecture-reviewSkill
- go-cliSkill
- go-dependency-injectionSkill
- go-design-patternsSkill
- go-graphqlSkill
- go-grpcSkill
- go-interface-designSkill
- go-openapiSkill
- go-project-layoutSkill
- go-code-reviewSkill
- go-coding-standardsSkill
- go-contextSkill
- go-data-structuresSkill
- go-error-handlingSkill
- go-modernizeSkill
- go-namingSkill
- go-databaseSkill
- go-concurrency-reviewSkill
- go-defensive-codingSkill
- go-observabilitySkill
- go-performance-reviewSkill
- go-security-auditSkill
- go-troubleshootingSkill
- go-test-qualitySkill
- go-test-table-drivenSkill
- git-commitSkill
- go-binary-sizeSkill
- go-build-releaseSkill
- go-ciSkill
- go-dependency-auditSkill
- go-refactoringSkill
- go-semantic-toolsSkill
- go-skills-routerSkill
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
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.

