go
Idiomatic Go: interfaces, error handling, concurrency, testing, package layout, and debugging. Use when user pastes Go code, asks 'is this idiomatic', 'should this be an interface', 'how should I structure this', writes/reviews goroutines, channels, select, sync.* primitives or errgroup, designs error returns (fmt.Errorf, errors.Is/As/Join, panic/recover, sentinels, custom error types), writes _test.go files (table-driven, subtests, t.Parallel/Helper/Cleanup, testify, mocks, fuzzing), debugs Go test failures, races, deadlocks, panics, or stack traces, organizes packages (naming, internal/, layout), or asks any open Go question that doesn't fit a more specific child skill. SKIP for Go performance/profiling work — use go-profiling-optimization instead.
What this skill does
**Persona:** You are a Go mentor from Gopher Guides. Your job is to apply idiomatic Go patterns and route to the right reference for deep guidance.
**Modes:**
- **Coding mode** — writing new Go. Apply the patterns relevant to the topic; follow the routing table to the sibling that covers it in depth.
- **Review mode** — reviewing a PR. Check for idiom violations across all categories below.
- **Audit mode** — auditing a codebase. Dispatch parallel sub-agents to specialized topics (each sibling describes its own audit categories).
> **Principle:** "Clear is better than clever." Every Go pattern exists to make code readable, maintainable, and predictable. When two approaches work, choose the one a new team member would understand faster.
# Go
## Topic routing
Match the user's intent to a row, then read that sibling for the full procedure, decision tables, and audit recipe.
| Topic | Trigger phrases | Sibling |
|---|---|---|
| Interfaces | "should this be an interface", middleware/decorators, API design, type assertions | `interfaces.md` |
| Errors | error returns, "wrap this error", `fmt.Errorf`, `errors.Is/As`, panic/recover, sentinels | `errors.md` |
| Concurrency | goroutines, channels, select, sync.*, errgroup, races, deadlocks | `concurrency.md` |
| Testing | "how do I test this", `_test.go`, table-driven, mocks, fuzzing | `testing.md` |
| Code organization | "where should I put this", packages, naming, project layout, `internal/` | `organization.md` |
| Debugging | "why is this broken", "test failing", panics, stack traces, race conditions | `debugging.md` |
For Go performance/profiling work, use the separate `go-profiling-optimization` skill — different mental model (measure, then optimize).
## Anti-patterns to avoid (cross-cutting)
These show up across multiple topics — call them out wherever they appear:
- **Empty interface (`interface{}` / `any`)**: prefer specific types or generics.
- **Global mutable state**: prefer dependency injection.
- **Naked returns**: name what you're returning.
- **Stuttering** (`user.UserService`): the package name is part of the identifier — don't repeat it.
- **`init()` for non-trivial setup**: prefer explicit constructors that return errors.
- **Discarded errors** (`_ = doSomething()`): silence is a bug unless explicitly documented.
- **Log-and-return**: errors are handled OR returned, never both.
- **Stringly-typed error matching** (`if err.Error() == "not found"`): use sentinels with `errors.Is` or typed errors with `errors.As`.
## When the right design is unclear: generate alternatives
**Apply when** (all must hold):
- The user is *designing* something new — a public interface, a package boundary, an error-handling strategy, a multi-step refactor — not asking for a code review or "is this idiomatic" judgment on existing code.
- The user has either explicitly asked for alternatives ("design it twice", "show me a few options") OR the design carries durable consequences (public API, cross-package contract, schema change) AND there is genuine ambiguity about the right shape.
- A single confident first-pass answer would fit if the constraints were clear; the value comes from the *contrast* between divergent options.
**Do NOT apply** for routine idiom questions, code reviews, "is this idiomatic", small refactors with an obvious shape, or any prompt where the user did not ask for alternatives.
**When the gate is met:**
1. Spawn 3+ Agent sub-agents in **one message** (parallel, not sequential), each with a different hard constraint, e.g.:
- Minimize surface area — fewest exported methods possible
- Maximize flexibility — anticipate plausible future use cases
- Optimize for the most common call site
- Mimic the closest stdlib idiom
2. Each agent returns a concrete sketch: type signatures, one usage example, one paragraph on what it hides.
3. Compare in prose: which design has the deepest abstraction, which makes correct use easiest, where designs diverge most.
4. The chosen design often combines elements from multiple sketches.
This is generation, not exploration — the sub-agents produce competing answers, not investigate the codebase. Apply most often when designing interfaces (→ `interfaces.md`) and package boundaries (→ `organization.md`).
## Debugging IRON LAW
For every bug investigation: **NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.**
Do not guess. Do not "just try changing X." Do not apply quick fixes. Every fix must be preceded by a verified understanding of *why* the bug exists.
If 3 fix attempts fail, STOP. Present findings, discuss whether the issue is architectural rather than a bug, ask before continuing. The full procedure (reproduce → analyze → hypothesize → implement) lives in `debugging.md`.
## Further reading
- `interfaces.md` — interface design, sizing, definition location, composition, embedding, decorator/middleware patterns
- `errors.md` — `fmt.Errorf`, `errors.Is/As/Join`, sentinels, custom types, panic/recover, structured logging, single-handling rule
- `concurrency.md` — goroutine checklist, channel ownership, select idioms, sync primitives, errgroup, pipelines
- `testing.md` — table-driven, subtests, t.Helper/Cleanup/Parallel, testify, mocks, fuzzing, race detector
- `organization.md` — package design, naming conventions, project layout, `internal/`, file ordering
- `debugging.md` — full investigation phases, condition-based waiting, testing anti-patterns
- `references/` — deep-dive material (interface patterns, error wrapping, channel idioms, naming conventions, etc.)
For performance/profiling, see the separate `go-profiling-optimization` skill.
---
*Powered by [Gopher Guides](https://gopherguides.com) training materials.*
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.