关于
This skill audits Go module dependencies by detecting outdated packages, checking for known vulnerabilities, and reviewing go.mod hygiene. It helps identify unused dependencies, evaluate dependency quality, and perform vulnerability scans using tools like govulncheck. Use it when cleaning up go.mod, upgrading modules, or assessing third-party package risks.
快速安装
Claude Code
推荐npx skills add eduardo-sl/go-agent-skills -a claude-code/plugin add https://github.com/eduardo-sl/go-agent-skillsgit clone https://github.com/eduardo-sl/go-agent-skills.git ~/.claude/skills/go-dependency-audit在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Go Dependency Audit
Every dependency you add is code you don't control but are responsible for. Audit ruthlessly.
1. Vulnerability Scanning
govulncheck (official Go tool):
# Install
go install golang.org/x/vuln/cmd/govulncheck@latest
# Scan project
govulncheck ./...
# Scan binary
govulncheck -mode=binary ./cmd/api-server
govulncheck checks against the Go vulnerability database and reports
only vulnerabilities that actually affect your code paths — not just
transitive deps you never call.
Run this in CI. No exceptions.
Additional scanning:
# Nancy (Sonatype OSS Index)
go list -json -deps ./... | nancy sleuth
# Trivy (container + deps)
trivy fs --scanners vuln .
2. go.mod Hygiene
Check for unused dependencies:
go mod tidy
git diff go.mod go.sum # any changes = deps were stale
go mod tidy MUST be run before every commit. Add to CI:
go mod tidy
git diff --exit-code go.mod go.sum
No replace directives in committed code:
// ❌ Bad — committed replace directive
replace github.com/foo/bar => ../local-bar
// ✅ Acceptable — in monorepos with workspace
// go.work handles this instead
Exception: temporary replace for bug fixes with a comment and linked issue:
// TODO(#1234): remove after upstream merges fix
replace github.com/foo/bar => github.com/myorg/bar v0.0.0-fix
Verify checksums:
go mod verify
This confirms that downloaded modules match their expected checksums. Failures indicate supply-chain tampering.
3. Dependency Evaluation Criteria
Before adding any dependency, evaluate:
| Criterion | Check |
|---|---|
| Maintenance | Last commit < 6 months? Active issue responses? |
| Popularity | Stars/forks alone mean nothing. Usage in production projects matters. |
| License | Compatible with your project? MIT/Apache/BSD preferred. |
| Size | Does it pull in 50 transitive deps for one function? |
| Alternatives | Can you do this with stdlib in < 50 lines? |
| API stability | Is it v1+? Does it follow semver? Frequent breaking changes? |
| Test coverage | Does the project have meaningful tests? |
The stdlib question:
Go's standard library is excellent. Before adding a dependency, ask:
"Can I solve this with net/http, encoding/json, database/sql,
text/template, crypto/*, os/exec, etc.?"
If the answer is yes and the code is < 100 lines, write it yourself.
4. Module Version Audit
List all dependencies with versions:
go list -m all
Check for available updates:
go list -m -u all # shows available updates
Upgrade strategy:
# Update specific module
go get github.com/foo/bar@latest
# Update all direct deps (minor/patch only)
go get -u ./...
# Update all deps including major versions (dangerous)
go get -u -t ./...
ALWAYS run full test suite after updates:
go get github.com/foo/[email protected]
go mod tidy
go test -race ./...
5. Transitive Dependency Analysis
# Why is this module in my dependency tree?
go mod why github.com/some/transitive-dep
# Full dependency graph
go mod graph
# Visual dependency graph (with modgraphviz)
go mod graph | modgraphviz | dot -Tpng -o deps.png
Watch for:
- 🔴 Transitive deps with known CVEs
- 🔴 Abandoned transitive deps (no commits in 2+ years)
- 🟡 Diamond dependency conflicts (two versions of same module)
- 🟡 Oversized transitive trees (a logging library pulling in gRPC)
6. Go Version Management
// go.mod
module github.com/myorg/myproject
go 1.22 // minimum Go version required
Rules:
- Set
godirective to the minimum version that supports features you use. toolchaindirective (Go 1.21+) pins the exact toolchain version.- Test against multiple Go versions in CI (at minimum: current and previous).
7. Recommended vs. Avoid
Well-maintained, production-proven packages:
| Domain | Package |
|---|---|
| Logging | go.uber.org/zap, log/slog (stdlib 1.21+) |
| HTTP Router | github.com/go-chi/chi, net/http (1.22+ routing) |
| Config | github.com/caarlos0/env, github.com/spf13/viper |
| Testing | github.com/stretchr/testify, stdlib testing |
| Database | github.com/jackc/pgx, github.com/jmoiron/sqlx |
| Validation | github.com/go-playground/validator |
| UUID | github.com/google/uuid |
| Errors | go.uber.org/multierr, stdlib errors (1.20+) |
Patterns to avoid:
- ❌ Frameworks that take over
main()(Go is not Java Spring) - ❌ ORMs that hide SQL (prefer
sqlxor rawdatabase/sql) - ❌ Code generators you don't understand
- ❌ Packages with
v0.xthat have been v0 for 3+ years
Audit Output Format
## Dependency Audit Report
**Module:** github.com/myorg/myproject
**Go version:** 1.22
**Direct deps:** N | **Indirect deps:** M
### 🔴 Vulnerabilities
- CVE-XXXX-YYYY in github.com/foo/[email protected] — upgrade to v1.2.5
### 🟡 Outdated Dependencies
- github.com/foo/bar v1.2.3 → v1.5.0 available (minor)
### 🟢 Observations
- go.mod is clean, no replace directives
- All deps actively maintained
GitHub 仓库
常见问题
什么是 go-dependency-audit Skill?
go-dependency-audit 是一个 Claude Skill,作者为 eduardo-sl。Skill 将 Claude 按需加载的说明和资源打包,让 Claude 无需额外提示即可执行与 go-dependency-audit 相关的任务。
如何安装 go-dependency-audit?
使用本页的安装命令:将 go-dependency-audit 作为插件添加到 Claude Code,或将其仓库克隆到 skills 目录,然后重启 Claude 以加载该 Skill。
go-dependency-audit 属于哪个分类?
go-dependency-audit 属于设计分类。
go-dependency-audit 可以免费使用吗?
可以。go-dependency-audit 已收录在 AIMCP,可免费安装。
相关推荐技能
该Skill用于当开发者提供完整实施计划时,以受控批次方式执行代码实现。它会先审阅计划并提出疑问,然后分批次执行任务(默认每批3个任务),并在批次间暂停等待审查。关键特性包括分批次执行、内置检查点和架构师审查机制,确保复杂系统实现的可控性。
该Skill可在完成任务、实现主要功能或合并代码前自动调度代码审查子代理,确保实现符合需求和计划。它支持通过指定git SHA范围进行精准的代码变更审查,帮助开发者在关键节点及时发现潜在问题。核心原则是"早审查、勤审查",适用于开发流程的各个关键阶段。
这个Skill指导开发者如何将MCP服务器连接到Claude Code,支持HTTP、stdio和SSE三种传输协议。它涵盖了从安装配置到认证安全的完整流程,适用于集成GitHub、Notion、数据库等外部服务。当开发者需要添加集成、配置外部工具或提及MCP相关功能时,这个Skill能提供实用的操作指南。
该Skill帮助开发者根据任务特性选择Claude Code的Web或CLI界面,并指导如何在两种环境间无缝迁移会话。它能分析任务复杂度、迭代需求等要素,推荐最优工作界面和工作流。关键特性包括会话状态管理、环境切换指导和上下文优化建议。
