Go Audit: GoDoc Coverage & Standards
Purpose
Ensures every exported Go identifier has precise, authoritative comments that satisfy go doc and pkg.go.dev rendering standards, producing a formal Coverage Gap Report. This skill edits doc comments only; it does NOT change logic, signatures or unexported code.
When to Use / When NOT to Use
- Use: Preparing libraries for public release, open-source onboarding, fixing
pkg.go.dev rendering issues.
- NOT: Internal microservices where inline docs are not published to a registry.
- NOT: Generating or refactoring GoDoc beyond an audit (use
golang-godoc-engineer).
- NOT: Writing ADRs, runbooks or READMEs (use
documentation-technical-writing).
Prerequisites & Assumptions
- Go 1.19+ (for doc link syntax). Target package is compilable.
Scope & Context Resolution
- Supported scopes: package (default), directory/module, file, type, function/method.
- Rule 1 - Explicit context in the prompt: Stated Go version, package, style requirements and scope are authoritative. Apply the skill strictly within them. MUST NOT add assumptions or expand beyond them. If a user instruction conflicts with a skill rule, follow the user and state the deviation in one line, EXCEPT security/data-loss rules, which stay mandatory (flag the conflict instead).
- Rule 2 - No extra context: Use this skill's Purpose, workflow and rules as the sole context, at package scope. MUST NOT import unrelated requirements or assumptions.
- Rule 3 - Explicit scope: Operate ONLY inside the named scope. Out-of-scope files may be READ as evidence but MUST NOT be modified; report out-of-scope observations as notes, never as changes. Widening scope requires explicit user approval.
- Mutation boundary: Edits limited to doc comments (and
Example functions) inside the resolved scope. MUST NOT alter code logic.
Step-by-Step Workflow
- Resolve scope and context (see above); state the resolved scope and mutation boundary in one line at the start of the output.
- Scan
.go files in scope for exported identifiers (Packages, Types, Interfaces, Functions, Vars).
- Generate a Coverage Gap Report identifying missing or low-quality comments.
- Apply strict GoDoc formatting rules (first sentence summary, cross-references).
- Output corrected source files without altering logic.
Enterprise Rules & Standards (MUST / SHOULD / MUST NOT)
- MUST: First sentence MUST be a complete sentence ending with
. (e.g., NewNode constructs a new Node.).
- MUST: Use
[TypeName] or [pkg.Func] for cross-references (Go 1.19+).
- MUST: Include an
Example: block for constructors and core APIs.
- MUST: Stay within the resolved scope; MUST NOT modify or expand beyond it without explicit user approval.
- MUST NOT: Restate the function signature inside the comment body.
- MUST NOT: Add comments to unexported identifiers unless behavior is critical and non-obvious.
- MUST NOT: Edit identifiers in packages outside the resolved scope; list them in the report instead.
Examples (good vs. bad, with realistic code or output)
- Bad:
// NewNode is a function that returns a node. (Redundant, weak summary)
- Good:
// NewNode constructs a new [Node] with the given functional options applied.
//
// Example:
// n := graph.NewNode(graph.WithLabel("API"))
func NewNode(opts ...Option) *Node { ... }
- Good (scoped): Prompt "audit only
NewNode" -> report and fix the comment on NewNode; note undocumented Edge as a finding without editing it.
- Bad (scope-expanding): Same prompt -> rewrite comments for every exported identifier in the package.
Checklist (verifiable, copy-pasteable)
Common Pitfalls
- Restating the signature ("NewNode is a function that returns a node").
- Documenting unexported helpers, adding noise.
- Using pre-1.19 plain-text references that do not render as links.
- Auditing the whole module when only one package was requested.
References (official docs, standards)
1---2name: golang-audit-godoc-coverage3description: 'Audits and generates GoDoc-compliant inline documentation for pkg.go.dev readiness. Trigger: "audit godoc", "fix pkg.go.dev comments", "generate GoDoc examples", "coverage gap report".'4metadata:5 source: https://skillmd.com/skills/pnguyen215/golang-audit-godoc-coverage6 category: language-specific7 tags: "golang, godoc, documentation, audit, pkg-go-dev"8---910# Go Audit: GoDoc Coverage & Standards1112## Purpose1314Ensures every exported Go identifier has precise, authoritative comments that satisfy `go doc` and `pkg.go.dev` rendering standards, producing a formal Coverage Gap Report. This skill edits doc comments only; it does NOT change logic, signatures or unexported code.1516## When to Use / When NOT to Use1718- **Use**: Preparing libraries for public release, open-source onboarding, fixing `pkg.go.dev` rendering issues.19- **NOT**: Internal microservices where inline docs are not published to a registry.20- **NOT**: Generating or refactoring GoDoc beyond an audit (use `golang-godoc-engineer`).21- **NOT**: Writing ADRs, runbooks or READMEs (use `documentation-technical-writing`).2223## Prerequisites & Assumptions2425- Go 1.19+ (for doc link syntax). Target package is compilable.2627### Scope & Context Resolution2829- **Supported scopes**: package (default), directory/module, file, type, function/method.30- **Rule 1 - Explicit context in the prompt**: Stated Go version, package, style requirements and scope are authoritative. Apply the skill strictly within them. MUST NOT add assumptions or expand beyond them. If a user instruction conflicts with a skill rule, follow the user and state the deviation in one line, EXCEPT security/data-loss rules, which stay mandatory (flag the conflict instead).31- **Rule 2 - No extra context**: Use this skill's Purpose, workflow and rules as the sole context, at package scope. MUST NOT import unrelated requirements or assumptions.32- **Rule 3 - Explicit scope**: Operate ONLY inside the named scope. Out-of-scope files may be READ as evidence but MUST NOT be modified; report out-of-scope observations as notes, never as changes. Widening scope requires explicit user approval.33- **Mutation boundary**: Edits limited to doc comments (and `Example` functions) inside the resolved scope. MUST NOT alter code logic.3435## Step-by-Step Workflow36371. Resolve scope and context (see above); state the resolved scope and mutation boundary in one line at the start of the output.382. Scan `.go` files in scope for exported identifiers (Packages, Types, Interfaces, Functions, Vars).393. Generate a **Coverage Gap Report** identifying missing or low-quality comments.404. Apply strict GoDoc formatting rules (first sentence summary, cross-references).415. Output corrected source files without altering logic.4243## Enterprise Rules & Standards (MUST / SHOULD / MUST NOT)4445- **MUST**: First sentence MUST be a complete sentence ending with `.` (e.g., `NewNode constructs a new Node.`).46- **MUST**: Use `[TypeName]` or `[pkg.Func]` for cross-references (Go 1.19+).47- **MUST**: Include an `Example:` block for constructors and core APIs.48- **MUST**: Stay within the resolved scope; MUST NOT modify or expand beyond it without explicit user approval.49- **MUST NOT**: Restate the function signature inside the comment body.50- **MUST NOT**: Add comments to unexported identifiers unless behavior is critical and non-obvious.51- **MUST NOT**: Edit identifiers in packages outside the resolved scope; list them in the report instead.5253## Examples (good vs. bad, with realistic code or output)5455- **Bad**: `// NewNode is a function that returns a node.` (Redundant, weak summary)56- **Good**:5758```go59// NewNode constructs a new [Node] with the given functional options applied.60//61// Example:62// n := graph.NewNode(graph.WithLabel("API"))63func NewNode(opts ...Option) *Node { ... }64```6566- **Good (scoped)**: Prompt "audit only `NewNode`" -> report and fix the comment on `NewNode`; note undocumented `Edge` as a finding without editing it.67- **Bad (scope-expanding)**: Same prompt -> rewrite comments for every exported identifier in the package.6869## Checklist (verifiable, copy-pasteable)7071- [ ] Scope and context resolved and stated.72- [ ] No changes outside the resolved scope.73- [ ] Coverage Gap Report produced for every exported identifier in scope.74- [ ] Each first sentence is complete and ends with `.`.75- [ ] Cross-references use `[TypeName]` / `[pkg.Func]`.76- [ ] Constructors and core APIs have an `Example:` block.77- [ ] `go doc` / `go vet ./...` runs clean and logic is unchanged.7879## Common Pitfalls8081- Restating the signature ("NewNode is a function that returns a node").82- Documenting unexported helpers, adding noise.83- Using pre-1.19 plain-text references that do not render as links.84- Auditing the whole module when only one package was requested.8586## References (official docs, standards)8788- [Go Doc Comments](https://go.dev/doc/comment)89- [Effective Go: Commentary](https://go.dev/doc/effective_go#commentary)90- [pkg.go.dev About](https://pkg.go.dev/about)