← 返回 Skills 市场
samber

Golang Documentation

作者 Samuel Berthe · GitHub ↗ · v1.1.2 · MIT-0
cross-platform ✓ 安全检测通过
184
总下载
0
收藏
0
当前安装
3
版本数
在 OpenClaw 中安装
/install golang-documentation
功能描述
Comprehensive documentation guide for Golang projects, covering godoc comments, README, CONTRIBUTING, CHANGELOG, Go Playground, Example tests, API docs, and...
使用说明 (SKILL.md)

Persona: You are a Go technical writer and API designer. You treat documentation as a first-class deliverable — accurate, example-driven, and written for the reader who has never seen this codebase before.

Modes:

  • Write mode — generating or filling in missing documentation (doc comments, README, CONTRIBUTING, CHANGELOG, llms.txt). Work sequentially through the checklist in Step 2, or parallelize across packages/files using sub-agents.
  • Review mode — auditing existing documentation for completeness, accuracy, and style. Use up to 5 parallel sub-agents: one per documentation layer (doc comments, README, CONTRIBUTING, CHANGELOG, library-specific extras).

Community default. A company skill that explicitly supersedes samber/cc-skills-golang@golang-documentation skill takes precedence.

Go Documentation

Write documentation that serves both humans and AI agents. Good documentation makes code discoverable, understandable, and maintainable.

Cross-References

See samber/cc-skills-golang@golang-naming skill for naming conventions in doc comments. See samber/cc-skills-golang@golang-testing skill for Example test functions. See samber/cc-skills-golang@golang-project-layout skill for where documentation files belong.

Step 1: Detect Project Type

Before documenting, determine the project type — it changes what documentation is needed:

Library — no main package, meant to be imported by other projects:

  • Focus on godoc comments, ExampleXxx functions, playground demos, pkg.go.dev rendering
  • See Library Documentation

Application/CLI — has main package, cmd/ directory, produces a binary or Docker image:

Both apply: function comments, README, CONTRIBUTING, CHANGELOG.

Architecture docs: for complex projects, use the docs/ directory and design description docs.

Step 2: Documentation Checklist

Every Go project needs these (ordered by priority):

Item Required Library Application
Doc comments on exported functions Yes Yes Yes
Package comment (// Package foo...) — MUST exist Yes Yes Yes
README.md Yes Yes Yes
LICENSE Yes Yes Yes
Getting started / installation Yes Yes Yes
Working code examples Yes Yes Yes
CONTRIBUTING.md Recommended Yes Yes
CHANGELOG.md or GitHub Releases Recommended Yes Yes
Example test functions (ExampleXxx) Recommended Yes No
Go Playground demos Recommended Yes No
API docs (e.g., OpenAPI) If applicable Maybe Maybe
Documentation website Large projects Maybe Maybe
llms.txt Recommended Yes Yes

A private project might not need a documentation website, llms.txt, Go Playground demos...

Parallelizing Documentation Work

When documenting a large codebase with many packages, use up to 5 parallel sub-agents (via the Agent tool) for independent tasks:

  • Assign each sub-agent to verify and fix doc comments in a different set of packages
  • Generate ExampleXxx test functions for multiple packages simultaneously
  • Generate project docs in parallel: one sub-agent per file (README, CONTRIBUTING, CHANGELOG, llms.txt)

Step 3: Function & Method Doc Comments

Every exported function and method MUST have a doc comment. Document complex internal functions too. Skip test functions.

The comment starts with the function name and a verb phrase. Focus on why and when, not restating what the code already shows. The code tells you what happens — the comment should explain why it exists, when to use it, what constraints apply, and what can go wrong. Include parameters, return values, error cases, and a usage example:

// CalculateDiscount computes the final price after applying tiered discounts.
// Discounts are applied progressively based on order quantity: each tier unlocks
// additional percentage reduction. Returns an error if the quantity is invalid or
// if the base price would result in a negative value after discount application.
//
// Parameters:
//   - basePrice: The original price before any discounts (must be non-negative)
//   - quantity: The number of units ordered (must be positive)
//   - tiers: A slice of discount tiers sorted by minimum quantity threshold
//
// Returns the final discounted price rounded to 2 decimal places.
// Returns ErrInvalidPrice if basePrice is negative.
// Returns ErrInvalidQuantity if quantity is zero or negative.
//
// Play: https://go.dev/play/p/abc123XYZ
//
// Example:
//
//	tiers := []DiscountTier{
//	    {MinQuantity: 10, PercentOff: 5},
//	    {MinQuantity: 50, PercentOff: 15},
//	    {MinQuantity: 100, PercentOff: 25},
//	}
//	finalPrice, err := CalculateDiscount(100.00, 75, tiers)
//	if err != nil {
//	    log.Fatalf("Discount calculation failed: %v", err)
//	}
//	log.Printf("Ordered 75 units at $100 each: final price = $%.2f", finalPrice)
func CalculateDiscount(basePrice float64, quantity int, tiers []DiscountTier) (float64, error) {
    // implementation
}

For the full comment format, deprecated markers, interface docs, and file-level comments, see Code Comments — how to document packages, functions, interfaces, and when to use Deprecated: markers and BUG: notes.

Step 4: README Structure

README SHOULD follow this exact section order. Copy the template from templates/README.md:

  1. Title — project name as # heading
  2. Badges — shields.io pictograms (Go version, license, CI, coverage, Go Report Card...)
  3. Summary — 1-2 sentences explaining what the project does
  4. Demo — code snippet, GIF, screenshot, or video showing the project in action
  5. Getting Started — installation + minimal working example
  6. Features / Specification — detailed feature list or specification (very long section)
  7. Contributing — link to CONTRIBUTING.md or inline if very short
  8. Contributors — thank contributors (badge or list)
  9. License — license name + link

Common badges for Go projects:

[![Go Version](https://img.shields.io/github/go-mod/go-version/{owner}/{repo})](https://go.dev/) [![License](https://img.shields.io/github/license/{owner}/{repo})](./LICENSE) [![Build Status](https://img.shields.io/github/actions/workflow/status/{owner}/{repo}/test.yml?branch=main)](https://github.com/{owner}/{repo}/actions) [![Coverage](https://img.shields.io/codecov/c/github/{owner}/{repo})](https://codecov.io/gh/{owner}/{repo}) [![Go Report Card](https://goreportcard.com/badge/github.com/{owner}/{repo})](https://goreportcard.com/report/github.com/{owner}/{repo}) [![Go Reference](https://pkg.go.dev/badge/github.com/{owner}/{repo}.svg)](https://pkg.go.dev/github.com/{owner}/{repo})

For the full README guidance and application-specific sections, see Project Docs.

Step 5: CONTRIBUTING & Changelog

CONTRIBUTING.md — Help contributors get started in under 10 minutes. Include: prerequisites, clone, build, test, PR process. If setup takes longer than 10 minutes, then you should improve the process: add a Makefile, docker-compose, or devcontainer to simplify it. See Project Docs.

Changelog — Track changes using Keep a Changelog format or GitHub Releases. Copy the template from templates/CHANGELOG.md. See Project Docs.

Step 6: Library-Specific Documentation

For Go libraries, add these on top of the basics:

  • Go Playground demos — create runnable demos and link them in doc comments with // Play: https://go.dev/play/p/xxx. Use the go-playground MCP tool when available to create and share playground URLs.
  • Example test functions — write func ExampleXxx() in _test.go files. These are executable documentation verified by go test.
  • Generous code examples — include multiple examples in doc comments showing common use cases.
  • godoc — your doc comments render on pkg.go.dev. Use go doc locally to preview.
  • Documentation website — for large libraries, consider Docusaurus or MkDocs Material with sections: Getting Started, Tutorial, How-to Guides, Reference, Explanation.
  • Register for discoverability — add to Context7, DeepWiki, OpenDeep, zRead. Even for private libraries.

See Library Documentation for details.

Step 7: Application-Specific Documentation

For Go applications/CLIs:

  • Installation methods — pre-built binaries (GoReleaser), go install, Docker images, Homebrew...
  • CLI help text — make --help comprehensive; it's the primary documentation
  • Configuration docs — document all env vars, config files, CLI flags

See Application Documentation for details.

Step 8: API Documentation

If your project exposes an API:

API Style Format Tool
REST/HTTP OpenAPI 3.x swaggo/swag (auto-generate from annotations)
Event-driven AsyncAPI Manual or code-gen
gRPC Protobuf buf, grpc-gateway

Prefer auto-generation from code annotations when possible. See Application Documentation for details.

Step 9: AI-Friendly Documentation

Make your project consumable by AI agents:

  • llms.txt — add a llms.txt file at the repository root. Copy the template from templates/llms.txt. This file gives LLMs a structured overview of your project.
  • Structured formats — use OpenAPI, AsyncAPI, or protobuf for machine-readable API docs.
  • Consistent doc comments — well-structured godoc comments are easily parsed by AI tools.
  • Clarity — a clear, well-structured documentation helps AI agents understand your project quickly.

Step 10: Delivery Documentation

Document how users get your project:

Libraries:

go get github.com/{owner}/{repo}

Applications:

# Pre-built binary
curl -sSL https://github.com/{owner}/{repo}/releases/latest/download/{repo}-$(uname -s)-$(uname -m) -o /usr/local/bin/{repo}

# From source
go install github.com/{owner}/{repo}@latest

# Docker
docker pull {registry}/{owner}/{repo}:latest

See Project Docs for Dockerfile best practices and Homebrew tap setup.

安全使用建议
This skill appears to do what it says: generate and review Go project documentation and templates. Before enabling it with autonomous access, consider: (1) running it in a sandbox or on a fork/branch because its instructions may run `go build`/`go test` and linters (these execute repository code); (2) whether you want the agent to be allowed to write/commit changes or only propose edits (review diffs first); (3) installing or making available tools referenced in templates (golangci-lint, git) since metadata only requires `go`; and (4) restricting or auditing network access (WebFetch/Agent) if your environment forbids automated outbound requests. If you need me to produce a minimal set of policy recommendations (e.g., CI job vs local dev, devcontainer setup, or sandboxing commands), tell me your security constraints and I will suggest concrete controls.
功能分析
Type: OpenClaw Skill Name: golang-documentation Version: 1.1.2 The golang-documentation skill bundle is a comprehensive set of instructions and templates designed to help AI agents generate and review high-quality documentation for Go projects. It covers standard practices such as godoc comments, README structures, CHANGELOGs (Keep a Changelog format), and CONTRIBUTING guides, while also introducing modern AI-friendly conventions like llms.txt. The skill uses standard OpenClaw tools (Read, Write, Bash, Agent, WebFetch) appropriately for its stated purpose, and the provided evaluation cases in evals/evals.json reinforce these best practices without any evidence of malicious intent, data exfiltration, or harmful prompt injection.
能力评估
Purpose & Capability
Name/description, templates, and references all describe Go documentation work and the only declared required binary is `go`, which is appropriate. The skill's allowed tools include git and golangci-lint, and templates reference running linters and tests — this is consistent with documentation/validation workflows, though the metadata does not declare those extra binaries as required (minor inconsistency).
Instruction Scope
SKILL.md explicitly instructs the agent to read the repo, edit/write documentation files, run validations (e.g., `go build`, `go test`, `golangci-lint` in templates), and use up to 5 parallel sub-agents. Those actions are reasonable for producing/validating documentation, but executing build/test commands will run repository code (which can execute arbitrary code). The skill does not request unrelated secrets or system paths, but users should be aware of the runtime risk of executing untrusted code/tests.
Install Mechanism
Instruction-only skill with no install spec and no downloads — low install risk.
Credentials
The skill declares no required environment variables or credentials. Documentation templates show example env var names (e.g., MYTOOL_DB_URL) for guidance only. There is no request for unrelated secrets.
Persistence & Privilege
always:false (normal). The skill permits autonomous invocation (platform default) and encourages using the Agent and WebFetch tools. That is coherent for a documentation assistant (parallel sub-agents, web lookups), but gives the agent the ability to perform network requests and spawn sub-agents — consider limiting autonomous use or network access if you need stronger controls.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install golang-documentation
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /golang-documentation 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.2
golang-documentation 1.1.2 - Updated SKILL.md to clarify directory usage for architecture docs, minor formatting/clarity improvements, and corrected a small typo in the documentation checklist. - Improved language in various documentation templates (README.md, CONTRIBUTING.md). - Refinements to library documentation guidance. - Version bump in metadata.
v1.1.1
- Version bump to 1.1.1 with updated metadata. - Added an evals/evals.json file. - Minor formatting and punctuation tweaks in the description and metadata. - No changes to documentation content or usage instructions.
v0.1.0
Initial release of golang-documentation skill: - Provides comprehensive guidelines for documenting Go projects, covering godoc comments, README, CONTRIBUTING, CHANGELOG, Go Playground demos, code examples, API docs, and llms.txt. - Supports both write (generating/filling docs) and review (auditing/editing docs) modes, with parallel sub-agent suggestions. - Includes detailed checklists, comment formatting standards, README section ordering, and cross-references to related skills. - Applicable to Go libraries, applications/CLIs, and complex project architectures.
元数据
Slug golang-documentation
版本 1.1.2
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 3
常见问题

Golang Documentation 是什么?

Comprehensive documentation guide for Golang projects, covering godoc comments, README, CONTRIBUTING, CHANGELOG, Go Playground, Example tests, API docs, and... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 184 次。

如何安装 Golang Documentation?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install golang-documentation」即可一键安装,无需额外配置。

Golang Documentation 是免费的吗?

是的,Golang Documentation 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Golang Documentation 支持哪些平台?

Golang Documentation 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Golang Documentation?

由 Samuel Berthe(@samber)开发并维护,当前版本 v1.1.2。

💬 留言讨论