agentsclimarketplace

Go documentation

Skill muratmirgun/gophers/skills/go-documentation

Use when writing or reviewing Go documentation — godoc comments on packages, types, functions, methods, sentinel errors; runnable Example tests; README/CONTRIBUTING/CHANGELOG. Covers the project-type detection (library vs application) that decides which docs are needed, comment grammar (start with name, full sentences), what to document vs what to skip, and Example test conventions. Apply proactively when introducing exported names, even if documentation was not requested.From its SKILL.md

Install
npx -y skills add muratmirgun/gophers --skill go-documentation

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 8 stars8 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

7.7 KB, as published. Nobody here has run it

Go Documentation

Documentation in Go is part of the API. Doc comments compile into go doc, pkg.go.dev, and IDE tooltips, so the rules exist to make those views readable. Code says what; comments say why, when, and what can go wrong.

Core Rules

  1. Every exported name has a doc comment. Packages, types, functions, methods, constants, variables.
  2. Doc comments start with the name (// Encode writes ...). Full sentences, capitalised, end with a period.
  3. Document non-obvious behaviour. Restating the signature is noise.
  4. Mark deprecations explicitly with a Deprecated: paragraph.
  5. Examples are tests — runnable Example* functions in _test.go files with // Output: blocks are verified by go test.
  6. Every package has exactly one package comment above the package clause in one file (doc.go if long).

What Project Are You Documenting?

Detect this first — it changes the doc surface area.

SignalProject typeDocs to focus on
No main package, intended to be importedLibrarygodoc, Example* tests, README usage examples, pkg.go.dev rendering
Has main package, cmd/ directory, ships a binary or Docker imageApplication/CLIInstall instructions, --help text, config docs
Both (libraries that ship CLI tools)BothAll of the above

Universal: doc comments on exported names, package comment, README, LICENSE, CONTRIBUTING (recommended), CHANGELOG (recommended).

Read references/godoc-grammar.md for the comment grammar, headings/lists, deprecation markers, and full examples.

Comment Grammar

// Encode writes the JSON encoding of req to w.
// It returns an error if req contains a non-serialisable field.
func Encode(w io.Writer, req *Request) error

Rules:

  • Start with the name of the thing.
  • Use a verb phrase for functions/methods, a noun phrase for types/values.
  • Articles (A, An, The) may precede the name.
  • Full sentences, punctuation included.
  • Wrap at ~80 columns for diff comfort; no hard limit.

Unexported names with non-obvious behaviour should also be commented — those comments are for maintainers, not godoc.

What to Document

TopicDocument whenSkip when
Parametersedge cases, units, rangestype/name already say it
Contextbehaviour differs from standard cancellationstandard ctx.Err() propagation
Concurrencyambiguous (e.g., a read that mutates internal state)read-only is safe by default; mutation is unsafe by default
Cleanupalways — defer Close(), Stop() requirements—
Errorssentinel values (ErrNotFound), error types (use *PathError pointer)—
Named returnsmultiple values of the same typetype alone is clear
Side effectsalways — file writes, network calls, init-time work—

Restating signatures is the most common waste:

// Bad — restates what you can see
// SetName sets the name.
func (u *User) SetName(name string) { ... }

// Good — explains the why and the constraints
// SetName sets the user's display name. Returns ErrInvalidName
// if name is empty or longer than MaxNameLen.
func (u *User) SetName(name string) error { ... }

Package Comments

Every package has exactly one. Place it above the package clause in one file. For long descriptions, use a dedicated doc.go.

// Package store provides a transactional key-value store backed by
// SQLite. It is safe for concurrent use; see (*Store).BeginTx for
// transaction semantics.
package store

For main packages, use the binary name:

// The migrate command applies SQL migrations from disk to a database.
package main

Runnable Examples

func ExampleEncode() {
    var buf bytes.Buffer
    _ = Encode(&buf, &Request{ID: "abc"})
    fmt.Println(buf.String())
    // Output: {"id":"abc"}
}

Naming:

  • func Example() — package-level example.
  • func ExampleFoo() — example for Foo.
  • func ExampleFoo_bar() — alternate example for Foo titled "bar".
  • func ExampleT_Method() — example for T.Method.

go test runs these and verifies the // Output: line matches. They appear in godoc attached to the named symbol — the best documentation is the kind the compiler keeps honest.

Read references/examples-and-readme.md for Example* patterns, the canonical README outline, and CONTRIBUTING/CHANGELOG templates.

Error and Type Docs

Sentinel errors: document on the variable, not on each return.

// ErrNotFound is returned when no record matches the query.
var ErrNotFound = errors.New("store: not found")

Error types: document with the pointer form so errors.Is/errors.As examples match.

// PathError records the operation and path that caused an error.
// Use errors.As(err, new(*PathError)) to inspect the fields.
type PathError struct { Op, Path string; Err error }

Anti-Patterns

Anti-patternWhy it hurtsDo this instead
// SetName sets the name.restates signature, no valueexplain constraints, side effects, errors
// TODO: improve this with no owner/dateforever-todolink to issue or remove
// Note: this is fast.unsupported claimbenchmark in test, link to it
// Deprecated. (no body)tooling reads the body// Deprecated: use NewFoo instead.
Trailing period missinginconsistent godoc layoutend every sentence with .
Multi-paragraph doc with no blank linegodoc collapses itseparate paragraphs with // blank lines
Documenting unexported names with godoc-style sentenceswastes effort; not renderedone-line maintainer note is enough
Doc comment above the wrong symbol (blank line between)godoc treats it as orphanno blank line between comment and symbol

Verification Checklist

  • go doc ./... renders cleanly for every package (no missing doc warnings from linters).
  • Every exported identifier has a comment starting with its name.
  • Every package has exactly one package comment.
  • All deprecations include the Deprecated: paragraph.
  • At least one Example* test per non-trivial exported function in a library package.
  • README contains: title, summary, install, minimal working example, license.
  • golangci-lint run --enable=godot,revive passes (revive's exported rule).

Enforce With Linters

Mechanical checks belong to CI:

  • revive exported — missing doc comments on exported names.
  • godot — missing trailing periods in doc comments.
  • misspell — typos in comments.
  • go vet — basic format-string and other issues that also surface in docs.

References

What ships with it: 3 files

13.3 KB alongside SKILL.md

Gives 0 of the 12 instructions most test skills give

Counted across 1,201 of the 2,096 authors here whose files we hold, read 2026-09-06

  • Write a failing test before writing codein 43 of 1201, across 36 files
  • Run the full test suitein 36 of 1201, across 35 files
  • Test only one variable per experimentin 34 of 1201, across 17 files
  • Read product marketing context before asking questionsin 34 of 1201, across 14 files
  • Mock external dependenciesin 34 of 1201, across 30 files
  • Define primary, secondary, and guardrail metricsin 33 of 1201, across 16 files
  • Pre-determine sample size before startingin 31 of 1201, across 14 files
  • Test behavior rather than implementationin 31 of 1201, across 29 files
  • Formulate a hypothesis before designing a testin 30 of 1201, across 13 files
  • Document every test hypothesis, variant, and resultin 29 of 1201, across 11 files
  • Use descriptive test function namesin 25 of 1201, across 21 files
  • Commit to the methodology without stopping earlyin 24 of 1201, across 8 files

Said here and by no other author read

  • Add doc comments to every exported name
  • Start doc comments with the name of the identifier
  • Use full sentences and end with a period
  • Document non-obvious behavior instead of restating signatures
  • Mark deprecations with a Deprecated paragraph
  • Provide exactly one package comment per package

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.

Keep looking

Skills are one crate of 613,373. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.