MCP HubMCP Hub
SKILL·4EB6C8

go-documentation

eduardo-sl
更新日 27 days ago
6 閲覧
69
9
69
GitHubで表示
テストwordaitestingdesign

について

このClaudeスキルは、開発者がgodocコメント、パッケージドキュメント、テスト可能な例など、標準的な規約に従ってGoのドキュメントを作成するのを支援します。パッケージや関数へのドキュメント追加、非推奨通知の作成などのタスクにご利用いただけます。このスキルは特にコードレベルのドキュメントに焦点を当てており、コミットメッセージやREADMEファイルは対象外です。

クイックインストール

Claude Code

推奨
メイン
npx skills add eduardo-sl/go-agent-skills -a claude-code
プラグインコマンド代替
/plugin add https://github.com/eduardo-sl/go-agent-skills
Git クローン代替
git clone https://github.com/eduardo-sl/go-agent-skills.git ~/.claude/skills/go-documentation

このコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします

ドキュメント

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.

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 the const (...) 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.
  • main packages: 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 test fails 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.

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 see

For a browsable preview, run a local pkgsite if available: go run golang.org/x/pkgsite/cmd/pkgsite@latest and open the module.

Verification Checklist

  1. Every exported identifier has a doc comment starting with its name
  2. Package has a package comment ("Package <name> ..."), in doc.go if long
  3. Error conditions and nil/zero-value behavior documented for exported APIs
  4. Concurrency safety stated where callers could guess wrong
  5. [Symbol] doc links used instead of bare names in running text
  6. Non-trivial exported APIs have Example functions with // Output:
  7. Deprecations use the exact Deprecated: form and name a replacement
  8. No comments restating signatures, tracking history, or holding dead code
  9. go test ./... passes with examples enabled

GitHub リポジトリ

eduardo-sl/go-agent-skills
パス: skills/(code-quality)/go-documentation
0
FAQ

よくある質問

go-documentation Skillとは何ですか?

go-documentation はeduardo-sl が作成した Claude Skillです。Skillは、Claudeが必要に応じて読み込む指示とリソースをまとめ、追加の指示なしで go-documentation に関連するタスクを実行できるようにします。

go-documentation をインストールするには?

このページのインストールコマンドを使用してください。go-documentation をプラグインとして Claude Code に追加するか、リポジトリを skills ディレクトリにクローンし、Claudeを再起動してSkillを読み込みます。

go-documentation はどのカテゴリに属しますか?

go-documentation は テスト カテゴリに属します。

go-documentation は無料で利用できますか?

はい。go-documentation は AIMCP に掲載されており、無料でインストールできます。

関連スキル

evaluating-llms-harness
テスト

このClaudeスキルは、lm-evaluation-harnessを実行し、MMLUやGSM8Kなど60以上の標準化学術タスクでLLMをベンチマークします。開発者がモデルの品質を比較し、トレーニングの進捗を追跡し、学術的な結果を報告するために設計されています。このツールはHuggingFaceやvLLMモデルを含む様々なバックエンドをサポートしています。

スキルを見る
cloudflare-cron-triggers
テスト

このスキルは、cron式を使用してWorkersをスケジュールするためのCloudflare Cron Triggersの実装に関する包括的な知識を提供します。定期的なタスクの設定、メンテナンスジョブ、自動化されたワークフローの構築を網羅し、無効なcron式やタイムゾーン問題といった一般的な課題への対処法も含みます。開発者はこれを使用して、スケジュールされたハンドラーの設定、cronトリガーのテスト、WorkflowsやGreen Computeとの連携を構成できます。

スキルを見る
webapp-testing
テスト

このClaude Skillは、Playwrightベースのツールキットを提供し、Pythonスクリプトを通じてローカルWebアプリケーションのテストを可能にします。フロントエンドの検証、UIデバッグ、スクリーンショット撮影、ログ表示を実現し、サーバーライフサイクルを管理します。ブラウザ自動化タスクにご利用いただけますが、コンテキストの汚染を避けるため、スクリプトのソースコードを読むのではなく直接実行してください。

スキルを見る
finishing-a-development-branch
テスト

このスキルは、開発者がテストの合格を確認し、構造化された統合オプションを提示することで、完成した作業を仕上げることを支援します。実装が完了した後のマージ、PR作成、ブランチの整理といったワークフローを案内します。コードが準備できてテスト済みの際に使用し、開発プロセスを体系的に完了させましょう。

スキルを見る