golang-how-to
The golang-how-to skill orchestrates Go development by automatically loading multiple relevant skills based on task context. Use it for any Go coding, review, debug, or setup task where the orchestrator identifies the primary skill and all applicable secondary skills to load simultaneously, such as loading golang-grpc plus golang-testing plus golang-error-handling for gRPC service development, or disambiguating overlapping skills when task intent is unclear.
git clone --depth 1 https://github.com/samber/cc-skills-golang /tmp/golang-how-to && cp -r /tmp/golang-how-to/skills/golang-how-to ~/.claude/skills/golang-how-toSKILL.md
**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](references/disambiguation.md). - **Configure** — add a `## Required Go skills` block to the project's `CLAUDE.md` or `AGENTS.md`. Follow [project-config.md](references/project-config.md). ## 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. | Intent | Primary | Also load | | --- | --- | --- | | Design an API, choose a pattern | `golang-design-patterns` | `golang-structs-interfaces`, `golang-naming` | | Name a type, function, or package | `golang-naming` | `golang-code-style` | | Handle errors idiomatically | `golang-error-handling` | `golang-safety` (nil-heavy code) | | Write goroutines, channels, sync | `golang-concurrency` | `golang-context` (if cancellation) | | Pass deadlines / cancel operations | `golang-context` | `golang-concurrency` (if goroutines) | | Design structs, embed, use interfaces | `golang-structs-interfaces` | `golang-design-patterns` | | Database queries and transactions | `golang-database` | `golang-error-handling`, `golang-security` | | Build a gRPC service | `golang-grpc` | `golang-testing`, `golang-error-handling` | | Build a GraphQL API | `golang-graphql` | `golang-testing`, `golang-error-handling` | | Build a CLI command tree | `golang-spf13-cobra` | `golang-cli`, `golang-spf13-viper` (if config) | | Layer config from flags/env/file | `golang-spf13-viper` | `golang-spf13-cobra` | | Write tests | `golang-testing` | `golang-stretchr-testify` (if using testify) | | Apply optimization patterns | `golang-performance` | `golang-benchmark` (measure first) | | Measure with pprof / benchstat | `golang-benchmark` | `golang-performance` (fix), `golang-troubleshooting` (root cause) | | Debug a panic or unexpected behavior | `golang-troubleshooting` | `golang-safety`, `golang-benchmark` (if perf-related) | | Monitor in production | `golang-observability` | `golang-performance` (if SLO breach) | | Audit security vulnerabilities | `golang-security` | `golang-safety`, `golang-lint` | | Review formatting and style | `golang-code-style` | `golang-naming`, `golang-lint` | | Configure golangci-lint | `golang-lint` | `golang-code-style` | | Write godoc / README / CHANGELOG | `golang-documentation` | `golang-naming` | | Set up a new project structure | `golang-project-layout` | `golang-design-patterns`, `golang-dependency-injection`, `golang-lint` | | Set up CI/CD pipeline | `golang-continuous-integration` | `golang-lint`, `golang-security` | | Choose a library | `golang-popular-libraries` | relevant library-specific skill | | Adopt new Go language features | `golang-modernize` | `golang-lint` | | Use samber/lo (slice/map helpers) | `golang-samber-lo` | `golang-data-structures`, `golang-performance` | | Use samber/oops (structured errors) | `golang-samber-oops` | `golang-error-handling` | | Use log/slog | `golang-samber-slog` | `golang-observability`, `golang-error-handling` | | Use dependency injection | `golang-dependency-injection` | `golang-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>`. ## Categories at a glance Full catalog with "use when" hooks: [by-category.md](references/by-category.md) | Category | Skills | | --- | --- | | Code Quality | `golang-code-style` `golang-documentation` `golang-error-handling` `golang-lint` `golang-naming` `golang-safety` `golang-security` `golang-structs-interfaces` | | Architecture & Design | `golang-concurrency` `golang-context` `golang-data-structures` `golang-database` `golang-dependency-injection` `golang-design-patterns` `golang-modernize` | | QA & Performance | `golang-benchmark` `golang-observability` `golang-performance` `golang-testing` `golang-troubleshooting` | | Project Setup | `golang-cli` `golang-continuous-integration` `golang-dependency-management` `golang-popular-libraries` `golang-project-layout` `golang-stay-updated` | | APIs | `golang-graphql` `golang-grpc` `golang-swagger` | | Dependency Injection | `golang-dependency-injection` `golang-google-wire` `golang-uber-dig` `golang-uber-fx` `golang-samber-do` | | Frameworks | `golang-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` | | Testing | `golang-stretchr-testify` `golang-testing` | ## Competing clusters — boundary lines Full boundary tables with routing examples: [disambiguation.md](references/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) - **Gap — type vs arch**: `golang-structs-interfaces` (type design) vs `golang-design-patter
Golang benchmarking, profiling, and performance measurement. Use when writing, running, or comparing Go benchmarks, profiling hot paths with pprof, interpreting CPU/memory/trace profiles, analyzing results with benchstat, setting up CI benchmark regression detection, or investigating production performance with Prometheus runtime metrics. Also use when the developer needs deep analysis on a specific performance indicator - this skill provides the measurement methodology, while `samber/cc-skills-golang@golang-performance` provides the optimization patterns.
Golang CLI application development. Use when building, modifying, or reviewing a Go CLI tool — especially for command structure, flag handling, configuration layering, version embedding, exit codes, I/O patterns, signal handling, shell completion, argument validation, and CLI unit testing. Also triggers when code uses cobra, viper, or urfave/cli. For cobra-specific APIs → See `samber/cc-skills-golang@golang-spf13-cobra` skill; for viper configuration layering → See `samber/cc-skills-golang@golang-spf13-viper` skill.
Golang code style conventions — line length and breaking, variable declarations, control flow clarity, when comments help vs hurt. Use when writing or reviewing Go code, asking about style or clarity, or establishing project coding standards. Not for naming conventions (→ See `samber/cc-skills-golang@golang-naming` skill), linter configuration (→ See `samber/cc-skills-golang@golang-lint` skill), or doc comments (→ See `samber/cc-skills-golang@golang-documentation` skill).
Golang concurrency patterns. Use when writing or reviewing concurrent Go code involving goroutines, channels, select, locks, sync primitives, errgroup, singleflight, worker pools, or fan-out/fan-in pipelines. Also triggers when you detect goroutine leaks, race conditions, channel ownership issues, or need to choose between channels and mutexes.
Idiomatic context.Context usage in Golang — propagation through API boundaries, cancellation, timeouts and deadlines, request-scoped values, context.WithoutCancel for background work outliving requests. Apply when designing context propagation across layers, debugging leaked or unexpired contexts, choosing between context.Background/TODO/WithoutCancel, or storing values in context. Not for code that merely accepts ctx as first parameter.
CI/CD pipeline configuration using GitHub Actions for Golang projects — testing, linting, SAST, security scanning, code coverage, Dependabot, Renovate, GoReleaser, code review automation, and release pipelines. Use when setting up or improving Go project CI, configuring GitHub Actions workflows, adding linters or security scanners, automating dependency updates, or adding quality gates.
Golang data structures — slices (internals, capacity growth, preallocation, slices package), maps (internals, hash buckets, maps package), arrays, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections, pointers (unsafe.Pointer, weak.Pointer), and copy semantics. Use when choosing or optimizing Go data structures, implementing generic containers, using container/ packages, unsafe or weak pointers, or questioning slice/map internals.
Comprehensive guide for Go database access — parameterized queries, struct scanning, NULLable columns, transactions, isolation levels, SELECT FOR UPDATE, connection pool, batch processing, context propagation, and migration tooling. Use when writing, reviewing, or debugging Golang code that interacts with PostgreSQL, MariaDB, MySQL, or SQLite; for database testing; or for questions about database/sql, sqlx, or pgx. Does NOT generate database schemas or migration SQL.