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.
In this repository29 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- building-lit-componentsSkill
- building-static-site-rss-feedsSkill
- building-templ-componentsSkill
- checking-wsh-vrtSkill
- committing-codeSkill
- creating-agent-skillsSkill
- creating-test-casesSkill
- deploying-with-isucon-ansibleSkill
- designing-isucon-architectureSkill
- frontend-designSkill
- operating-isucon-servers-via-sshSkill
- planning-wsh-improvementsSkill
- porting-isucon-rust-to-goSkill
- releasing-zig-with-goreleaserSkill
- running-isucon-as-an-agentSkill
- sharing-sockets-with-so-reuseport-in-zigSkill
- tuning-isucon-linux-and-nginxSkill
- using-grafana-mcpSkill
- using-unocss-with-templSkill
- winning-isuconSkill
- winning-web-speed-hackathonSkill
- writing-feature-specSkill
- writing-implementation-tasksSkill
- writing-isucon-arch-subagent-tasksSkill
- writing-project-constitutionSkill
- writing-technical-designSkill
- writing-zig-cli-toolsSkill
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
- Distinctive: line 16
Add a tool to your project:
- Very specific: line 77
Use go tool in generate directives for reproducible code generation:
- Distinctive: line 121
Pin versions explicitly: Always specify versions for reproducibility
- Very specific: line 125
Consider isolation: Use -modfile for tools with conflicting dependencies
- Distinctive: line 145
Use separate modfile (see ADVANCED.md):
≈ “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.
Files
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@latestThis adds to go.mod:
tool golang.org/x/tools/cmd/stringerRun the tool:
go tool stringer -type=MyTypeCore 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.1Running Tools
# Run by short name
go tool staticcheck ./...
# List all available tools
go tool
# Show binary path
go tool -n stringerUpdating Tools
# Update specific tool
go get -tool honnef.co/go/tools/cmd/staticcheck@v0.6.0
# Update all tools to latest
go get toolRemoving Tools
go get -tool golang.org/x/tools/cmd/stringer@noneIntegration 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.goRun 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
| Tool | Install Command |
| stringer | go get -tool golang.org/x/tools/cmd/stringer |
| mockgen | go get -tool go.uber.org/mock/mockgen |
| golangci-lint | go get -tool github.com/golangci/golangci-lint/cmd/golangci-lint |
| staticcheck | go get -tool honnef.co/go/tools/cmd/staticcheck |
| govulncheck | go get -tool golang.org/x/vuln/cmd/govulncheck |
| enumer | go get -tool github.com/dmarkham/enumer |
| wire | go get -tool github.com/google/wire/cmd/wire |
Best Practices
- Pin versions explicitly: Always specify versions for reproducibility
- Use with go:generate: Replace direct tool calls in generate directives
- Document in README: List required tools and their purposes
- Run
go mod verify: Validate checksums after adding tools - Consider isolation: Use
-modfilefor tools with conflicting dependencies
Limitations
- Go 1.24+ required: Earlier versions cannot parse
tooldirective - 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 versionVersion 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.
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
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.

