Skip to main content
skill CX Codex

go-dependency-audit — Claude Code skill: Go dependency audits

Audits Go module dependencies for vulnerabilities, stale versions, and go.mod issues. Use it before upgrades or a dependency review.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add eduardo-sl/go-agent-skills --skill go-dependency-audit -a claude-code
Open on GitHub

What go-dependency-audit does

go-dependency-audit reviews a Go module for known vulnerabilities, outdated packages, unused entries, redundant transitive dependencies, and go.mod hygiene. It also assesses dependency maintenance, licensing, tree size, API stability, and whether the standard library could cover the use case.

The skill relies on Go commands and govulncheck to inspect module versions, available updates, checksums, dependency graphs, and why a transitive module is present. It is read-only and does not edit code. The Go toolchain is required, and govulncheck needs network access to proxy.golang.org.

This is a dependency audit rather than a code-security or architecture review. After upgrades, it recommends running the full test suite, including go test -race ./....

What it helps with

  • scan Go modules for known CVEs
  • spot outdated dependency versions
  • clean stale entries from go.mod
  • trace unexpected transitive modules
  • assess a package before adding it

Example prompts for the agent

  • Audit this Go module for dependency vulnerabilities and version issues.
  • Review go.mod for unused packages and available updates.
  • Explain why this transitive module is present and assess its dependency risks.

How to install go-dependency-audit

1Skills CLI (Vercel)

npx skills add eduardo-sl/go-agent-skills --skill go-dependency-audit -a claude-code

2Manually: put the files in place

~/.claude/skills/go-dependency-audit/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/go-dependency-audit/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about go-dependency-audit

How do I install go-dependency-audit in Claude Code?

Run npx skills add eduardo-sl/go-agent-skills --skill go-dependency-audit -a claude-code. The installed skill file is then available at ~/.claude/skills/go-dependency-audit/SKILL.md.

What does go-dependency-audit do?

It checks Go module dependencies for vulnerabilities, stale or unused packages, redundant transitive modules, and go.mod hygiene. It also reviews dependency quality before an addition or upgrade.

Is this a code-security or architecture review skill?

No. It focuses on dependencies and module configuration; code-level security and architecture review are handled separately.

Source text

SKILL.md · MIT
---
name: go-dependency-audit
description: >
  Audit Go module dependencies: detect outdated packages, check for known
  vulnerabilities, review go.mod hygiene, identify unused or redundant deps,
  and evaluate dependency quality. Use when auditing dependencies, checking
  for CVEs, cleaning up go.mod, upgrading modules, or evaluating third-party
  packages. Trigger examples: "check dependencies", "audit deps", "go.mod
  review", "update modules", "vulnerability scan", "govulncheck".
  Not for: code-level security (go-security-audit), architecture review
  (go-architecture-review).
user-invocable: true
license: MIT
compatibility: Designed for Claude Code or similar AI coding agents working on Go projects. Requires the Go toolchain. Requires network access to proxy.golang.org. Read-only: this skill reports findings, it does not edit code.
allowed-tools: Read Glob Grep Bash(go:*) Bash(gofmt:*) Bash(govulncheck:*)
metadata:
  author: eduardo-sl
  version: "1.2.0"
---

# Go Dependency Audit

Every dependency you add is code you don't control but are responsible for.
Audit ruthlessly.

Detailed reference material, loaded on demand:

- `references/resolution-and-workspaces.md` — minimal version selection,
  `replace`/`exclude`/`retract`, `go.work`, tool dependencies.

Read a reference file only when the summary below is not enough.

## 1. Vulnerability Scanning

### govulncheck (official Go tool):

```bash
# Ad hoc, without touching go.mod
go run golang.org/x/vuln/cmd/govulncheck@latest ./...

# Pinned as a module tool (Go 1.24+) — recommend this to the project so
# every developer and CI job runs the same version
go get -tool golang.org/x/vuln/cmd/govulncheck
go tool govulncheck ./...

# Scan a built binary
go tool govulncheck -mode=binary ./bin/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:

```bash
# 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:

```bash
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:

```bash
go mod tidy
git diff --exit-code go.mod go.sum
```

### No replace directives in committed code

A committed `replace => ../local-path` breaks every other checkout; local
multi-module work belongs in `go.work`. The one exception — a temporary
fork with a linked issue — is in section 8.

### Verify checksums:

```bash
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:

```bash
go list -m all
```

### Check for available updates:

```bash
go list -m -u all  # shows available updates
```

### Upgrade strategy:

```bash
# Update one module to its latest minor/patch
go get github.com/foo/bar@latest

# Patch releases only, for every dependency of the packages
go get -u=patch ./...

# Latest minor/patch of every dependency (add -t to include test deps)
go get -u ./...
```

`go get -u` never crosses a major version: `github.com/foo/bar/v2` is a
different module path. A major upgrade means changing the import paths
and reading the changelog — it is a migration, not an update.

ALWAYS run full test suite after updates:

```bash
go get github.com/foo/[email protected]
go mod tidy
go test -race ./...
```

## 5. Transitive Dependency Analysis

```bash
# 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)
- 🟡 A dependency forcing a higher minimum version of a shared module on
  everyone (minimal version selection picks the highest requirement)
- 🟡 Two major versions of one library (`v1` and `v2`) linked side by side
- 🟡 Oversized transitive trees (a logging library pulling in gRPC)

## 6. Go Version Management

```go
// go.mod
module github.com/myorg/myproject

go 1.22  // minimum Go version required
```

Rules:
- Set `go` directive to the minimum version that supports features you use.
- `toolchain` directive (Go 1.21+) pins the exact toolchain version.
- Test against multiple Go versions in CI (at minimum: current and previous).

## 7. Adding a Dependency

Ask before adding one: a new module is code the team must audit, update
and trust indefinitely, and the agent should not make that decision
silently. When proposing one:

- Name the standard-library alternative and why it is not enough — since
  Go 1.21-1.27, `slog`, `slices`/`maps`, `errors.Join`, ServeMux routing,
  `os.Root` and `uuid` each removed a common reason to add a dependency.
- Report what the evaluation criteria above found: maintenance, license,
  transitive size (`go mod graph` after a trial `go get`), API stability.
- Avoid frameworks that take over `main`, ORMs that hide the SQL, and code
  generators nobody on the team understands.

## 8. Resolving Version Problems

- Minimal version selection builds with the highest *minimum* any module
  requires — adding one dependency can raise another's version.
- Application fixes: `replace` (temporary fork, with an issue link) and
  `exclude` (a known-broken version). Both apply only in the main module.
- Library fixes: `retract` versions you published by mistake; it is the
  only signal that reaches consumers.
- Local multi-module work uses `go.work`, not committed
  `replace => ../path` directives.
- Developer tools are `go.mod` tool dependencies (`go get -tool`, Go
  1.24+), not a `tools.go` file.

Examples: `references/resolution-and-workspaces.md`.

## Audit Output Format

```text
## 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
```

© eduardo-sl · MIT · eduardo-sl/go-agent-skills

Similar skills

All skills for Programming languages →

From the same set34

go-skills-router This skill maps Go tasks to a primary skill and related ones. Use it when a request spans several areas or you’re unsure which of two overlapping skills fits. CX Codex +1 ★ 83repo stars go-semantic-tools Finds function calls, interface implementations, and dependency graphs in Go via gopls and go list, not text search. Understands implicit interfaces, embedding, and cross-package dependencies that grep misses. CX Codex +1 ★ 83repo stars go-refactoring Guides coding agents through behavior-preserving Go refactorings verified by the compiler and existing tests. CX Codex +1 ★ 83repo stars go-ci A skill that helps your AI agent write and set up GitHub Actions for Go projects. Use it when you need a pipeline with linting, tests, security checks, and caching. CX Codex +1 ★ 83repo stars go-build-release Configures reproducible, verifiable Go builds and releases. Covers GoReleaser, cosign signatures, SBOM generation, and container builds. CX Codex +1 ★ 83repo stars go-binary-size This skill measures Go binaries and container images, then helps trace their size to packages, symbols, build tags, or embedded assets. Use it when trimming a CLI or checking a dependency’s build cost. CX Codex +1 ★ 83repo stars git-commit A skill that makes your agent write commit messages in Conventional Commits style: typed, scoped, imperative. Useful when the repo history has turned into noise. CX Codex +1 ★ 83repo stars go-test-table-driven Guides coding agents when writing and refactoring Go table-driven tests. It enforces clean test structs, clear subtest names, and lean loop bodies. CX Codex +1 ★ 83repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor