Generated banner for Golang How To
Generated logo for Golang How To

Golang How To

Samuel BertheCommunityCreated by samberDistributed by Samuel Berthe

  • Skill
  • Meta (authoring, orchestration, planning, memory)
  • Agent tooling
  • MIT
  • Low risk

From the author

Golang skills orchestrator — always active on any Golang coding, review, debug, or setup task. Reads the task context and loads the most relevant skills from samber/cc-skills-golang, often multiple at once: writing a gRPC service loads golang-grpc + golang-testing + golang-error-handling; debugging a panic loads golang-troubleshooting + golang-safety; auditing security loads golang-security + golang-lint + golang-safety. Also: disambiguates competing clusters when two skills seem to overlap (performance vs benchmark vs troubleshooting, samber/lo vs mo vs ro, DI cluster, safety vs security), and configures the project's agent-config file (CLAUDE.md, AGENTS.md, GEMINI.md, Cursor rules, or Copilot instructions) to force-trigger skills in a project (/golang-how-to configure).
— the description by samber

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

golang-how-to acts as a central hub for Go development within an AI agent environment. It intelligently identifies the context of a user's task and automatically loads the appropriate set of specialized Go skills from the samber/cc-skills-golang library. Beyond simple loading, it disambiguates overlapping skill domains and provides a configuration mode to persist project-specific skill requirements in agent configuration files.

What it does

  • Orchestrates multiple Go-specific skills simultaneously based on task context.
  • Disambiguates overlapping skill domains using defined boundary tables.
  • Configures project-level agent settings to force-trigger required skills.
  • Integrates with gopls for semantic code navigation and diagnostics.
  • Provides a structured approach to selecting and applying Go development tools.

When to use it

  • When starting a new Go coding, review, or debugging task.
  • When you need to ensure all relevant Go best practices and tools are active.
  • When you need to configure a project to consistently use specific Go skills.
  • When you are unsure which specific Go skill is best suited for a complex task.

Advantages

  • Reduces manual effort by automatically loading relevant toolsets.
  • Ensures consistent application of Go idioms and best practices.
  • Prevents tool overlap confusion through clear disambiguation logic.
  • Maintains project-specific agent configurations for team consistency.

Usage examples

“/golang-how-to configure”
The agent updates the project's configuration file to force-trigger necessary Go skills for future tasks.
“Help me build a gRPC service.”
The agent automatically loads golang-grpc, golang-testing, and golang-error-handling to support the task.
“Debug this panic in my Go code.”
The agent loads golang-troubleshooting and golang-safety to assist in identifying and fixing the issue.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/samber/golang-how-to/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip golang-how-to.zip -d .agents/skills

Documentation by samber

Persona: You are a Go skills orchestrator. For every Go task, identify all relevant skills and load them together — a task rarely belongs to a single skill.

Modes:

  • Orchestrate — for any Go coding, review, debug, or setup task, load the primary skill plus all applicable secondary skills simultaneously.

  • Disambiguate — when two skills seem to overlap, show the boundary table. See disambiguation.md.

  • Configure — write the always-load directive for golang-how-to itself, plus an optional ## Required Go skills block, to the project's agent-config file (CLAUDE.md, AGENTS.md, or equivalent). Follow project-config.md.

Questions: In Configure mode, ask the user through the environment's question tool — never as plain-text prose. One question at a time, wait for the answer. If the environment has no question tool, ask in prose with the same options.

Dependencies: gopls — go install golang.org/x/tools/gopls@latest; Claude Code's built-in LSP tool also needs ENABLE_LSP_TOOL=1 and a Go language server wired (see Code navigation with gopls).

Skill loading

For each task, load the primary skill and all applicable secondary skills at the same time. Do not wait — load them together at the start.

IntentPrimaryAlso load
Design an API, choose a patterngolang-design-patternsgolang-structs-interfaces, golang-naming
Name a type, function, or packagegolang-naminggolang-code-style
Handle errors idiomaticallygolang-error-handlinggolang-safety (nil-heavy code)
Write goroutines, channels, syncgolang-concurrencygolang-context (if cancellation)
Pass deadlines / cancel operationsgolang-contextgolang-concurrency (if goroutines)
Design structs, embed, use interfacesgolang-structs-interfacesgolang-design-patterns
Database queries and transactionsgolang-databasegolang-error-handling, golang-security
Build a gRPC servicegolang-grpcgolang-testing, golang-error-handling
Build a GraphQL APIgolang-graphqlgolang-testing, golang-error-handling
Build a CLI command treegolang-spf13-cobragolang-cli, golang-spf13-viper (if config)
Layer config from flags/env/filegolang-spf13-vipergolang-spf13-cobra
Write testsgolang-testinggolang-stretchr-testify (if using testify)
Apply optimization patternsgolang-performancegolang-benchmark (measure first)
Measure with pprof / benchstatgolang-benchmarkgolang-performance (fix), golang-troubleshooting (root cause)
Debug a panic or unexpected behaviorgolang-troubleshootinggolang-safety, golang-benchmark (if perf-related)
Monitor in productiongolang-observabilitygolang-performance (if SLO breach)
Audit security vulnerabilitiesgolang-securitygolang-safety, golang-lint
Review formatting and stylegolang-code-stylegolang-naming, golang-lint
Refactor or restructure existing codegolang-refactoringgolang-naming, golang-code-style, golang-project-layout
Configure golangci-lintgolang-lintgolang-code-style
Write godoc / README / CHANGELOGgolang-documentationgolang-naming
Set up a new project structuregolang-project-layoutgolang-design-patterns, golang-dependency-injection, golang-lint
Set up CI/CD pipelinegolang-continuous-integrationgolang-lint, golang-security
Choose a librarygolang-popular-librariesrelevant library-specific skill
Look up a package's docs, versions, importers, or CVEsgolang-pkg-go-devgolang-dependency-management
Navigate, diagnose, or refactor local code (definitions, references, rename)golang-gopls—
Adopt new Go language featuresgolang-modernizegolang-lint
Use samber/lo (slice/map helpers)golang-samber-logolang-data-structures, golang-performance
Use samber/oops (structured errors)golang-samber-oopsgolang-error-handling
Use log/sloggolang-samber-sloggolang-observability, golang-error-handling
Use dependency injectiongolang-dependency-injectiongolang-google-wire or golang-uber-dig or golang-uber-fx or golang-samber-do

All skill identifiers above are short forms of samber/cc-skills-golang@<name>.

Code navigation with gopls

gopls gives semantic code intelligence for Go — go-to-definition, find references, diagnostics, package API, symbol search, refactoring. → See samber/cc-skills-golang@golang-gopls skill for the three ways to reach it (its own MCP server, the native LSP tool, and its CLI), the full capability matrix, and efficient read/edit workflows.

gopls only reasons about code that is present and resolvable in the local build: your workspace plus every dependency exactly as pinned in go.sum (including replace directives). For any fact that isn't tied to your local build — version history, licenses, ecosystem-wide importers, a package you haven't added yet — use golang-pkg-go-dev (godig). See the godig vs gopls vs Context7 vs govulncheck section below for the full boundary.

godig vs gopls vs Context7 vs govulncheck

Four tools can answer "is this dependency OK to use," and they don't overlap as much as they look:

  • Context7 is a general-purpose, cross-language documentation fetcher — useful when no more specific source exists. For a Go package or module, godig is almost always the better choice: it pulls structured, Go-specific data straight from pkg.go.dev — exact versions, exported symbols with signatures, runnable examples, imported-by, and known vulnerabilities — rather than Context7's generic scraped/curated docs, which don't expose that structure and can lag or miss lesser-known Go modules. Reach for Context7 only when a dependency's documentation genuinely doesn't exist or isn't indexed on pkg.go.dev.

  • godig answers questions about the published ecosystem: any Go package or module, whether or not it's in your go.mod yet — it calls the remote pkg.go.dev API and never touches your local checkout. Its vulns command reports CVEs known for a package/version in isolation, regardless of whether your build actually reaches the vulnerable code path.

  • gopls (→ samber/cc-skills-golang@golang-gopls, via its MCP server, the native LSP tool, or its CLI) answers questions about your specific build: your code plus every dependency exactly as pinned in go.sum, including replace directives pointing at forks or local paths — neither godig nor Context7 can see that. Its go_vulncheck operation runs a single, on-demand reachability check against the workspace as it stands right now.

  • govulncheck (the standalone CLI, wrapped by the samber/cc-skills-golang@golang-security skill) is the whole-tree audit: it walks the entire module's call graph to confirm which known vulnerabilities are actually reachable, and is the tool of record for CI gates and periodic security sweeps — gopls's go_vulncheck is a lighter-weight, single-shot version of the same analysis for use mid-edit.

Pick by task:

TaskToolHow
Find where a symbol is defined in your own repogoplssamber/cc-skills-golang@golang-gopls — go_search, then go_file_context
Understand a file's intra-package dependenciesgoplssamber/cc-skills-golang@golang-gopls — go_file_context
Jump into a dependency's exact resolved source (incl. forks/replaced versions)goplssamber/cc-skills-golang@golang-gopls — go_package_api, or the native LSP tool's goToDefinition
Find every call site in your own code that references a dependency's symbolgoplssamber/cc-skills-golang@golang-gopls — go_symbol_references — godig's imported-by only lists public packages, not call sites in your repo
Get compiler diagnostics right after an editgoplssamber/cc-skills-golang@golang-gopls — go_diagnostics (MCP), or automatic with the native LSP tool
Check whether your current build can reach a known vulnerability, mid-editgoplssamber/cc-skills-golang@golang-gopls — go_vulncheck
Rename, extract, inline, or otherwise refactor local codegoplssamber/cc-skills-golang@golang-gopls — safe rename, refactor.* code actions
Whole-tree vulnerability audit across the module (CI, periodic sweep)govulnchecksamber/cc-skills-golang@golang-security skill — govulncheck ./...
List available versions of a published packagegodiggodig versions <path>
Check known CVEs for a package/version you haven't added yetgodiggodig vulns <path>
See exported symbols/signatures of a published packagegodiggodig symbols / symbol doc
Get runnable code examples for a symbolgodiggodig symbol examples
Read a package's rendered README/docsgodiggodig module readme / package doc
See who imports a package across the whole public ecosystemgodiggodig imported-by
Search for a package or library candidategodiggodig search
Check a package's or module's licensegodiggodig package licenses / module licenses
Get docs for a non-Go library, or a Go module not indexed on pkg.go.devContext7resolve-library-id / query-docs

See the samber/cc-skills-golang@golang-pkg-go-dev skill for the full godig command reference, and the samber/cc-skills-golang@golang-security skill for the whole-tree govulncheck remediation workflow.

Categories at a glance

Full catalog with "use when" hooks: by-category.md

CategorySkills
Code Qualitygolang-code-style golang-documentation golang-error-handling golang-lint golang-naming golang-safety golang-security golang-structs-interfaces
Architecture & Designgolang-concurrency golang-context golang-data-structures golang-database golang-dependency-injection golang-design-patterns golang-modernize golang-refactoring
QA & Performancegolang-benchmark golang-observability golang-performance golang-testing golang-troubleshooting
Project Setupgolang-cli golang-continuous-integration golang-dependency-management golang-gopls golang-pkg-go-dev golang-popular-libraries golang-project-layout golang-stay-updated
APIsgolang-graphql golang-grpc golang-swagger
Dependency Injectiongolang-dependency-injection golang-google-wire golang-uber-dig golang-uber-fx golang-samber-do
Frameworksgolang-spf13-cobra golang-spf13-viper
samber/*golang-samber-do golang-samber-hot golang-samber-lo golang-samber-mo golang-samber-oops golang-samber-ro golang-samber-slog
Testinggolang-stretchr-testify golang-testing

Competing clusters — boundary lines

Full boundary tables with routing examples: disambiguation.md

Key clusters and their owners:

  • Performance: golang-performance (optimization patterns) · golang-benchmark (measurement) · golang-troubleshooting (root cause) · golang-observability (always-on production)

  • DI: golang-dependency-injection (concepts/decision) · golang-google-wire (compile-time) · golang-uber-dig (runtime reflection) · golang-uber-fx (lifecycle framework) · golang-samber-do (type-safe container)

  • samber/*: golang-samber-lo (finite transforms) · golang-samber-ro (reactive streams) · golang-samber-mo (monadic types)

  • Errors: golang-error-handling (idioms) · golang-samber-oops (structured errors) · golang-safety (prevent panics)

  • Style: golang-code-style · golang-naming · golang-lint · golang-documentation

  • CLI: golang-cli (architecture) · golang-spf13-cobra (command tree) · golang-spf13-viper (config layering)

  • Package lookup: golang-pkg-go-dev (query pkg.go.dev for an existing path: versions/docs/symbols/importers/CVEs) · golang-gopls (navigate/refactor your locally resolved build) · golang-popular-libraries (which library to adopt) · golang-dependency-management (manage go.mod) · golang-security (whole-tree CVE scan)

  • Gap — type vs arch: golang-structs-interfaces (type design) vs golang-design-patterns (architectural patterns)

  • Gap — goroutine vs cancel: golang-concurrency + golang-context — load both when cancelling goroutines via context

  • Gap — correctness vs threat: golang-safety (internal bugs) vs golang-security (external threats)

  • Gap — features vs rules: golang-modernize (language adoption) vs golang-lint (static analysis config)

  • Gap — process vs target rules: golang-refactoring (the safe, staged, at-scale process of changing existing code — planning, ordering, gopls-driven mechanics, staged PRs) vs golang-naming/golang-code-style/golang-project-layout/golang-design-patterns/golang-modernize (what the resulting code should look like) — load golang-refactoring alongside whichever of these owns the target shape

Configure mode

Write an always-load directive for golang-how-to itself to the project's agent-config file (CLAUDE.md, AGENTS.md, GEMINI.md, Cursor rules, or Copilot instructions — whichever the project's harness reads), and optionally force-trigger specific secondary skills too.

samber/cc-skills-golang@golang-project-layout writes the always-load directive automatically at project creation, with no user confirmation needed — it costs one skill description and never imposes project-specific choices. Running /golang-how-to configure writes it too if missing, and additionally lets the user confirm a ## Required Go skills block for skills that must always apply beyond routing. Follow project-config.md.


This skill is not exhaustive. Refer to individual skill files and the official Go documentation for detailed guidance.

If you encounter a bug or unexpected behavior in this skill plugin, open an issue at https://github.com/samber/cc-skills-golang/issues.

Files

references/project-config.md

Configure mode — force-trigger Go skills in a project

This workflow writes two independent things to the project's agent-config file(s) (CLAUDE.md, AGENTS.md, or equivalent):

  1. An always-load directive for golang-how-to itself — a single sentence, unconditional, no user confirmation needed.

  2. An optional ## Required Go skills block that force-triggers a specific, user-confirmed set of secondary skills.

Table of Contents

  • When to use

  • Always-load directive

    • Template

    • When it gets written

    • Insertion point

    • Idempotency

  • Step 1 — Detect the project config file(s)

  • Step 2 — Idempotency check

  • Step 3 — Confirm the skill set with the user

  • Step 4 — Write the block

    • Markdown targets (CLAUDE.md, AGENTS.md, GEMINI.md, copilot-instructions.md)

    • Cursor target (.cursor/rules/*.mdc)

  • Step 5 — Confirm to the user

  • Notes on company overrides (⚙️ skills)

When to use

  • Any new Go project should get the always-load directive (see below) — this is the common case.

  • The project additionally has a hard requirement on specific skills (e.g., golang-security must always apply, not just when the user mentions "security").

  • The team has agreed on a fixed set of Go standards to enforce on every AI interaction.

  • A company skill overrides a community default (⚙️ skills) and must always win.

Always-load directive

Every Go project should carry a one-line directive telling the coding agent to load the samber/cc-skills-golang@golang-how-to orchestrator skill before starting Go work, so it in turn routes to whichever other Go skills the task actually needs. Unlike the ## Required Go skills block below, this directive needs no user confirmation: it costs one skill description (~100 tokens) and is never wrong, since golang-how-to only routes to other skills — it does not impose project-specific choices.

Template
Before any Go coding, review, debugging, troubleshooting, or setup task, load the `samber/cc-skills-golang@golang-how-to` skill first — it routes to whichever other Go skills the task needs.
When it gets written
  • At project creation — the samber/cc-skills-golang@golang-project-layout skill writes this directive automatically as part of its Initialization Checklist, without asking the user.

  • On demand — running /golang-how-to configure writes it too (if missing), in addition to any ## Required Go skills block confirmed in Step 3 below.

Insertion point
  • If a ## Required Go skills block already exists or is being created in the same pass, insert the directive as its own line directly above that heading, separated by a blank line.

  • Otherwise, append it under a ## Go development heading (create the heading if the file has no such section).

Idempotency

Grep for the exact sentence before writing:

grep -n 'load the `samber/cc-skills-golang@golang-how-to` skill first' CLAUDE.md

Skip writing if already present.

Step 1 — Detect the project config file(s)

Every harness reads its own agent-config file or directory. None is more "primary" than another — detect and write to whichever exist, and write to all of them if more than one does:

File / directoryHarness(es)Format
CLAUDE.mdClaude CodeMarkdown, single file, appended to
AGENTS.mdCodex, OpenCode, and other multi-agent harnessesMarkdown, single file, appended to
GEMINI.mdGemini CLI, AntigravityMarkdown, single file, appended to
.cursor/rules/*.mdcCursorDirectory of .mdc files, each with its own YAML frontmatter — not a single markdown file to append to
.github/copilot-instructions.mdGitHub CopilotMarkdown, single file, appended to

Check which of these exist at the project root. If multiple exist, write to all of them — different harnesses read different files, and a project may support several. If none exist, ask the user which one(s) to create.

Step 2 — Idempotency check

For the markdown files (CLAUDE.md, AGENTS.md, GEMINI.md, .github/copilot-instructions.md), grep each one for the always-load directive and an existing ## Required Go skills block before writing:

grep -n 'load the `samber/cc-skills-golang@golang-how-to` skill first' CLAUDE.md
grep -n "## Required Go skills" CLAUDE.md

For Cursor, check whether .cursor/rules/golang-skills.mdc already exists instead — its presence itself is the idempotency signal, since it's a dedicated file rather than a shared section inside a larger document.

Write the always-load directive if it's missing, regardless of what Step 3 decides. If a ## Required Go skills block (or, for Cursor, the rule file) already exists, read it and confirm with the user whether to update it in place (replace the existing list) or skip.

Step 3 — Confirm the skill set with the user

Confirm which skills to always load — one question, one round of confirmation, not a running back-and-forth. Present the ⭐️ recommended skills as the default selection. Remind the user of the token budget (each always-loaded skill adds its description tokens to every session — the 11 recommended skills add ~1,100 tokens at startup).

Recommended ⭐️ set for most projects:

golang-code-style
golang-data-structures
golang-design-patterns
golang-documentation
golang-error-handling
golang-modernize
golang-naming
golang-safety
golang-security
golang-testing
golang-troubleshooting

Additional skills to suggest based on codebase context:

  • Database layer detected (sql, gorm, sqlc) → suggest golang-database

  • CI config detected (.github/workflows/) → suggest golang-continuous-integration

  • Cobra imports detected → suggest golang-spf13-cobra

  • Viper imports detected → suggest golang-spf13-viper

  • samber/lo imports detected → suggest golang-samber-lo

  • Any other library-specific import → suggest the matching library skill

Step 4 — Write the block

Markdown targets (CLAUDE.md, AGENTS.md, GEMINI.md, copilot-instructions.md)

Template:

Before any Go coding, review, debugging, troubleshooting, or setup task, load the `samber/cc-skills-golang@golang-how-to` skill first — it routes to whichever other Go skills the task needs.

## Required Go skills

The following Go skills from `samber/cc-skills-golang` MUST always be applied when working on this project. Load them at the start of every Go-related task, regardless of whether the user explicitly mentions them.

- `samber/cc-skills-golang@golang-error-handling`
- `samber/cc-skills-golang@golang-security`
- `samber/cc-skills-golang@golang-testing`

Replace the skill list with the confirmed set from Step 3. Use the fully-qualified samber/cc-skills-golang@<name> identifier for each skill. If Step 2 found the always-load directive already present elsewhere in the file, don't duplicate it — write only the ## Required Go skills block.

Insertion point:

  • If the file is empty: write the block at the top.

  • If the file has existing content: append after the last section, separated by a blank line.

  • If a ## Required Go skills block already exists: replace only the bullet list inside it, preserving surrounding content.

Edit the file directly, rather than shelling out to a script — that keeps the change reviewable as a normal diff. Perform an idempotency check after writing: re-read the file and verify the block appears exactly once.

Cursor target (.cursor/rules/*.mdc)

.cursor/rules is a directory, not a file — each rule lives in its own .mdc file with YAML frontmatter (description, globs, alwaysApply). Do not try to append to it as if it were a single markdown document; the append-and-replace logic above does not apply here.

Create .cursor/rules/golang-skills.mdc (create the .cursor/rules/ directory first if it doesn't exist) using cursor-go-skills.mdc as the starting template, with alwaysApply: true so it always loads — matching the unconditional behavior of the markdown targets' always-load directive. Replace the placeholder ## Required Go skills list with the confirmed set from Step 3, same as the markdown targets. If the file already exists, replace only the bullet list, preserving its frontmatter and surrounding content.

Step 5 — Confirm to the user

After writing, summarize:

  • Which file(s) or rule(s) were updated

  • Whether the always-load directive for golang-how-to was added or was already present

  • Which skills were added to the always-load list

  • Approximate startup token cost (number of skills × ~100 tokens per description)

  • Note: skills marked ⚙️ (overridable) will be superseded if a company skill explicitly declares the override in its body

Notes on company overrides (⚙️ skills)

Skills marked ⚙️ in the README support company overrides. If the project has a company skill that supersedes a community default (e.g., acme/cc-skills@golang-error-handling-acme supersedes samber/cc-skills-golang@golang-error-handling), use the company skill FQN in the block instead — do NOT list both.

To declare an override in a company skill body, add near the top:

> This skill supersedes `samber/cc-skills-golang@golang-error-handling` for [Company] projects.

Overridable skills: golang-code-style, golang-concurrency, golang-context, golang-database, golang-dependency-injection, golang-design-patterns, golang-documentation, golang-error-handling, golang-naming, golang-observability, golang-structs-interfaces, golang-testing.

Requirements and compatibility

Written for: Claude Code, OpenAI Codex

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Declares allowed tools, Claude Code frontmatter, Needs an MCP server

The author says: Designed for Claude Code, Codex or similar harness. Requires git.

Security

What our scanner noticed· Low risk

  • Phrasing that asks for actions without confirmation

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
samber
Publisher
Samuel Berthe (Community)
Distributed by
Samuel Berthe
Source
samber/cc-skills-golang · skills/golang-how-to · commit bb1d43d
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by samber or Samuel Berthe.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download golang-how-to.zip