# Go Tool

> Manage Go tool dependencies using the tool directive (Go 1.24+). Use when a Go project needs code generation tools like sqlc, moq, templ, swag, or stringer managed as reproducible Go tool dependencies.

- **Type:** Skill
- **Install:** `agentstack add skill-sgaunet-claude-plugins-go-tool`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [sgaunet](https://agentstack.voostack.com/s/sgaunet)
- **Installs:** 0
- **Category:** [Cloud & Infrastructure](https://agentstack.voostack.com/c/cloud-infrastructure)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [sgaunet](https://github.com/sgaunet)
- **Source:** https://github.com/sgaunet/claude-plugins/tree/main/plugins/go-specialist/skills/go-tool

## Install

```sh
agentstack add skill-sgaunet-claude-plugins-go-tool
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Go Tool Dependency Management

Manage Go development tool dependencies using the `tool` directive introduced in Go 1.24. This ensures reproducible builds by tracking tool versions in `go.mod` — eliminating the old `tools.go` workaround and version drift across developers and CI.

For detailed per-tool information, see the [reference catalog](${CLAUDE_SKILL_DIR}/../../docs/go-tool-catalog.md).

## When to Use

- A Go project needs external code generation or build tools
- Indicator files suggest a tool should be added (`.templ`, `.proto`, `sqlc.yml`, etc.)
- The user explicitly requests adding a Go tool dependency
- Auditing existing tool dependencies for consistency or cleanup
- Migrating from `tools.go` pattern to the native `tool` directive

## Prerequisites

Before proceeding, verify:

1. **go.mod exists**: Check for `go.mod` in the project root. Abort if missing.
2. **Go version ≥ 1.24**: Read the `go` directive in `go.mod`. If the version is below 1.24, inform the user: "The Go tool directive requires Go 1.24+. Update the `go` directive in go.mod to 1.24 or later."

## Workflow: Detect Recommended Tools

Scan the project for indicator files and compare against existing tool declarations in `go.mod`.

### Step 1: Read Existing Tools

Parse `go.mod` for the `tool` block to identify already-tracked tools.

### Step 2: Scan for Indicator Files

Use Glob to detect files that suggest specific tools:

| Indicator | Tool | Module Path |
|-----------|------|-------------|
| `sqlc.yml` / `sqlc.yaml` / `sqlc.json` | sqlc | `github.com/sqlc-dev/sqlc/cmd/sqlc` |
| `**/*.templ` | templ | `github.com/a-h/templ/cmd/templ` |
| `swagger.yaml` / `swagger.json` | swag | `github.com/swaggo/swag/cmd/swag` |

For **stringer** and **enumer**, detection requires context: `const` blocks with `iota` patterns. These are best suggested when the user is working with enum-like types.

### Step 3: Report Findings

Present a table comparing detected recommendations against existing tools:

| Tool | Status | Reason |
|------|--------|--------|
| templ | Missing | `.templ` files found but tool not in go.mod |
| sqlc | Present | Already tracked in go.mod |

## Workflow: Add Tool

### Step 1: Install

```bash
go get -tool @latest
```

Replace `@latest` with a specific version if the user requests one.

### Step 2: Tidy

```bash
go mod tidy
```

### Step 3: Verify

```bash
go tool  --help
```

Confirm the tool runs without error.

### Step 4: Suggest go:generate Directive

Based on the tool, suggest the appropriate `//go:generate` directive. See the [reference catalog](${CLAUDE_SKILL_DIR}/../../docs/go-tool-catalog.md) for canonical directives per tool.

General pattern:
```go
//go:generate go tool  
```

Place the directive in the file closest to the generated output.

## Workflow: Remove Tool

### Step 1: Remove from go.mod

```bash
go get -tool @none
```

### Step 2: Tidy

```bash
go mod tidy
```

### Step 3: Clean Up

Search for and remove any `//go:generate` directives that reference the removed tool:

```
Grep for: //go:generate go tool 
```

## Workflow: Audit Tools

### Step 1: List Declared Tools

Parse the `tool (...)` block from `go.mod`.

### Step 2: Cross-Reference with Source

For each declared tool, search for `//go:generate go tool ` in Go source files.

### Step 3: Report

| Tool | In go.mod | Has go:generate | Status |
|------|-----------|-----------------|--------|
| sqlc | Yes | Yes | OK |
| moq | Yes | No | Possibly unused |
| templ | No | Yes | Missing from go.mod |

## go:generate Best Practices

1. **Always use `go tool `** in directives — not a direct binary path. This ensures the version pinned in `go.mod` is used.
2. **Place directives near generated output** — in the package that owns the generated code.
3. **Run all generators**: `go generate ./...`
4. **Commit generated code** to version control so builds don't require running generators.
5. **One directive per tool invocation** — avoid chaining multiple tools in a single directive.

## Non-Go Tools

The `go tool` directive only supports tools written in Go. For non-Go tools (Node.js, Rust, Python), use alternative management:

- **Taskfile.yml** or **Makefile** for running non-Go tools
- **Docker** for tools with complex dependencies

## Error Handling

| Condition | Action |
|-----------|--------|
| No `go.mod` found | Abort: "Not a Go module — no go.mod found. Run `go mod init` first." |
| Go version ` fails after install | Check `go mod tidy` was run. Verify the module provides a binary at the expected path. |

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [sgaunet](https://github.com/sgaunet)
- **Source:** [sgaunet/claude-plugins](https://github.com/sgaunet/claude-plugins)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-sgaunet-claude-plugins-go-tool
- Seller: https://agentstack.voostack.com/s/sgaunet
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
