agentleFS
mazreanmazrean/agent-skills/skills/using-go-tool-directive/SKILL.md

using-go-tool-directive

Skill2 starsChanged 8 months agoMITView on GitHub

Manages Go development tools using the Go 1.24+ tool directive in go.mod. Use when adding linters, generators, or dev tools to Go projects, running project-specific tools, integrating tools with go:generate, or migrating from tools.go patterns.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add a tool to your project:

    line 16
  2. Very specific:

    Use go tool in generate directives for reproducible code generation:

    line 77
  3. Distinctive:

    Pin versions explicitly: Always specify versions for reproducibility

    line 121
  4. Very specific:

    Consider isolation: Use -modfile for tools with conflicting dependencies

    line 125
  5. Distinctive:

    Use separate modfile (see ADVANCED.md):

    line 145

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Using Go Tool Directive

Manage project-specific development tools in Go 1.24+ using the tool directive. Ensures consistent tool versions across team members and CI/CD environments.

Use this skill when adding dev tools (linters, generators, formatters) to Go projects, running tools via go tool, integrating with go:generate, or migrating from legacy tools.go patterns.

Supporting files: COMMANDS.md for full command reference, MIGRATION.md for migration patterns, ADVANCED.md for dependency isolation and caching.

Quick Start

Add a tool to your project:

go get -tool golang.org/x/tools/cmd/stringer@latest

This adds to go.mod:

tool golang.org/x/tools/cmd/stringer

Run the tool:

go tool stringer -type=MyType

Core Workflows

Adding Tools

# Add with latest version
go get -tool github.com/golangci/golangci-lint/cmd/golangci-lint

# Add with specific version
go get -tool honnef.co/go/tools/cmd/staticcheck@v0.5.1

Running Tools

# Run by short name
go tool staticcheck ./...

# List all available tools
go tool

# Show binary path
go tool -n stringer

Updating Tools

# Update specific tool
go get -tool honnef.co/go/tools/cmd/staticcheck@v0.6.0

# Update all tools to latest
go get tool

Removing Tools

go get -tool golang.org/x/tools/cmd/stringer@none

Integration with go:generate

Use go tool in generate directives for reproducible code generation:

//go:generate go tool stringer -type=Level
//go:generate go tool mockgen -source=service.go -destination=mocks/service.go

Run with:

go generate ./...

Makefile Integration

.PHONY: lint audit generate

lint:
	go tool golangci-lint run ./...

audit:
	go vet ./...
	go tool staticcheck ./...
	go tool govulncheck ./...

generate:
	go generate ./...

Common Tools

ToolInstall Command
stringergo get -tool golang.org/x/tools/cmd/stringer
mockgengo get -tool go.uber.org/mock/mockgen
golangci-lintgo get -tool github.com/golangci/golangci-lint/cmd/golangci-lint
staticcheckgo get -tool honnef.co/go/tools/cmd/staticcheck
govulncheckgo get -tool golang.org/x/vuln/cmd/govulncheck
enumergo get -tool github.com/dmarkham/enumer
wirego get -tool github.com/google/wire/cmd/wire

Best Practices

  1. Pin versions explicitly: Always specify versions for reproducibility
  2. Use with go:generate: Replace direct tool calls in generate directives
  3. Document in README: List required tools and their purposes
  4. Run go mod verify: Validate checksums after adding tools
  5. Consider isolation: Use -modfile for tools with conflicting dependencies

Limitations

  • Go 1.24+ required: Earlier versions cannot parse tool directive
  • Go tools only: Non-Go tools (eslint, prettier) need separate management
  • Shared dependencies: Tool dependencies mix with application dependencies (see ADVANCED.md for isolation)

Troubleshooting

Tool not found after install:

# Verify it's in go.mod
go list tool

# Check if go version is 1.24+
go version

Version conflict with application: Use separate modfile (see ADVANCED.md):

go tool -modfile=tools/go.mod <toolname>

CI/CD caching: Cache $GOPATH/pkg/mod and $GOCACHE for faster tool execution.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.