/go-arch-metrics:measurefrom go-arch-metrics
Use when asked to measure the current architecture quality of a Go project — running the metrics tools and collecting the numbers without judging them. Triggers for requests like "measure code quality", "ベースラインを取って", "アーキテクチャメトリクスを測って", "今の複雑度どれくらい".
Ships in go-arch-metrics. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Go プロジェクトの現状のメトリクスを取る。数値の解釈と違反の優先順位付けは
go-arch-metrics:evaluate が持つ。ここは「ツールを回して数値を出す」までを扱う。
ツールが見つからない場合 (PATH にも go.mod の tool directive にも無い)、手動計算や代替手段で回避してはならない。 arch-baseline のエラー出力にある足りないコマンド名をユーザーに伝え、 用意できてから再実行すること。
禁止: wc -l で LOC 判定、analyze-modularity なしで Distance や public ratio の推定、 ツールエラーの無視
必要なコマンドの一覧は go-arch-metrics:setup。
arch-baseline ./ [<output-json>] # PATH にあるとき (nix の devShell など)
go tool arch-baseline ./ [<output-json>] # 対象プロジェクトの go.mod の tool directive にあるとき
command -v arch-baseline で PATH にあるかを見て、無ければ go tool の形で呼ぶ。どちらでも動かなければ
go-arch-metrics:setup の references/tools.md の「この plugin の CLI を入れる」を案内する。
1 つめの引数は Go プロジェクトのルート (go.mod があるディレクトリ)。2 つめは JSON の出力先で、
省くとルートの baseline.json に書く。
go と git は PATH に要る。ほかのツールは PATH を先に見て、無ければ対象プロジェクトの go.mod の
tool directive から go tool で呼ぶ。どちらにも無いツールがあればエラー終了する。
ツールの実行そのものが失敗したとき (コンパイルできない、設定の誤り) も、理由を stderr に出して非 0 で終わる。
出力は 2 つ:
JSON は go-arch-metrics:evaluate がそのまま読む。キーと取りうる値は references/baseline.schema.json。既定の出力先は測るたびに上書きする。
出力が文書で説明できないときの扱い (この plugin の実装は読まず issue にする) も go-arch-metrics:evaluate が持つ。
パッケージは import_path とモジュールルートからの相対パスで出るので、どの checkout で測っても同じ文字列になる。
改善の前後を比べるときは、前の JSON を残しておくのではなく、比べたい commit を git worktree で取り出して
同じ版のツールで測り直す。2 つめの引数で出力先を分ければ上書きし合わない。
git worktree add --detach ../base origin/main
arch-baseline ../base "$TMPDIR/before.json"
arch-baseline ./ "$TMPDIR/after.json"
CI で base と比べる組み方は go-arch-metrics:setup の references/ci-integration.md。
govulncheck は plugin が組み込んだ vulncheck で回す。埋め込みの roots で TLS を検証するので、
Claude Code の sandbox の中でも vuln.go.dev に届く。それでも「未測定」になったら DB に届いていない
(ネットワークが無い等) ので、JSON の govulncheck.status が unmeasured のものを「脆弱性なし」と読まない。
gosec も plugin に組み込んで回す。版は plugin が決め、JSON の gosec.GosecVersion に残る。
測定の結果には、git が ignore するディレクトリとファイルは入らない。
ただし脆弱性 (vulncheck) は、追跡されるパッケージの中にある ignore されたファイルの分も数える。
go build はそのファイルもバイナリに入れるため。
型検査は ignore されたファイルも含めて行う。そこがコンパイルできないと、ほかのコンパイルエラーと同じく測定を止める。 git リポジトリの外では何も除かずに測り、その旨を stderr に 1 行出す。
| カテゴリ | メトリクス | ツール | しきい値 |
|---|---|---|---|
| モジュール性 | パッケージ依存方向 | go-arch-lint | 違反 = 0 |
| モジュール性 | 依存ルール設定自体の健全性 | analyze-arch-lint | analyze-arch-lint --metrics が出す |
| モジュール性 | import 禁止リスト | golangci-lint/depguard | 指定パッケージ = 0 |
| テスト可能性 | 認知的複雑度 | gocognit | ≤ 20 |
| テスト可能性 | 循環複雑度 | gocyclo | ≤ 20 |
| テスト可能性 | 関数の長さ | funlen | ≤ 100行 / 60文 |
| テスト可能性 | ネストの深さ | nestif | ≤ 8 (導入時推奨) → 目標 ≤ 5 |
| 保守性 | 保守性指数 | maintidx | ≥ 20 |
| 静的解析 | 高度なバグ検出・未使用コード | staticcheck | デフォルト有効 (U1000 系で未使用コードをカバー) |
| セキュリティ | 既知の脆弱性 | vulncheck (govulncheck の組み込み) | 違反 = 0 |
| セキュリティ | セキュリティ問題 | gosec | 違反 = 0 (CI ゲート) |
| テスト品質 | テストカバレッジ | go test -cover | ≥ 60% (段階的に引き上げ) |
| モジュール性 | Afferent/Efferent Coupling | analyze-modularity | 参考値 (しきい値なし) |
| モジュール性 | 抽象度・不安定度・距離 | analyze-modularity | アクション可能 Distance ≤ 0.5 |
| モジュール性 | 外から参照されない exported | analyze-modularity | internal パッケージで 0 |
| モジュール性 | パッケージサイズ均一性 | analyze-modularity | LOC ≤ max(mean + 2σ, 1000) (下限 1000 は固定) |
しきい値の根拠と、Distance の「アクション可能」の定義は go-arch-metrics:evaluate。
arch-baseline を通さず 1 つのツールだけ回したいときは
go-arch-metrics:setup の references/tools.md に各ツールの実行方法がある。
出力の読み方は references/output-examples.md。
数値が出たら go-arch-metrics:evaluate でしきい値と照らす。
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
go-arch-metrics@usadamasa is listed by usadamasa/agents-marketplace — review the source before installing
npx claudepluginhub usadamasa/agents-marketplace --plugin go-arch-metrics4 skills in this plugin
/evaluateUse when interpreting Go architecture metrics: comparing measured numbers against thresholds, classifying violations, and deciding what to fix first. Also covers the health of the `.go-arch-lint.yml` itself — when the config has grown long or components have become 1:1 with packages. Triggers for requests like "依存ルールの健全性を評価して", ".go-arch-lint.yml が長大化した", "どこから直すべき", "この数値はまずいのか"./remediateUse when fixing Go architecture metric violations: inverted dependencies, high cognitive complexity, deep nesting, oversized public API surface, packages far from the Main Sequence, and `.go-arch-lint.yml` configs that have degraded into a copy of the package tree. Triggers for requests like "improve testability", "public ratio を下げたい", "unreferenced_exported を直したい", "モジュール化の目的から逸脱している", "循環参照を解消したい"./