[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6QVE4JEAQ95M63ERG33Z7HW":3,"skill-same:01M6QVE4JEAQ95M63ERG33Z7HW":73},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":6,"ownerHtmlUrl":50,"ownerBlogUrl":51,"ownerDescription":6,"updatedAt":52,"install":53,"resources":66},"01M6QVE4JEAQ95M63ERG33Z7HW","idiomatic-go",null,"Write, review, or refactor Go code against the standard library and masterclass principles. Use when designing a small Go service or package, reviewing a PR for idiomatic Go, refactoring non-idiomatic code (deep hierarchies, premature interfaces, framework imports, leaked goroutines), debating package layout, designing error flow with wrapping and behavioral checks, sizing interfaces on the consumer side, deciding when concurrency is actually needed, or wiring up the Go toolchain (gofmt, go vet, golangci-lint, go test -race -cover, pprof).","maltehedderich\u002Fmaster-class-agents","maltehedderich","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F12952192?v=4","01M6QVCWP46HX90VYH1107TWGD","Malte Hedderich","01M6QVCWTNYVG7SQD18WCYVGAF",6,"MIT","https:\u002F\u002Fgithub.com\u002Fmaltehedderich\u002Fmaster-class-agents\u002Fblob\u002Fmain\u002Fskills\u002Fidiomatic-go\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"idiomatic go","idiomatic","go","flow","Budget","write","refactoring","goal","layout","concurrency","cli","imports","review","wiring","code","up","performance","deep","brief","error","2026-11-10 10:12:30",false,"---\nname: idiomatic-go\ndescription: \"Write, review, or refactor Go code against the standard library and masterclass principles. Use when designing a small Go service or package, reviewing a PR for idiomatic Go, refactoring non-idiomatic code (deep hierarchies, premature interfaces, framework imports, leaked goroutines), debating package layout, designing error flow with wrapping and behavioral checks, sizing interfaces on the consumer side, deciding when concurrency is actually needed, or wiring up the Go toolchain (gofmt, go vet, golangci-lint, go test -race -cover, pprof).\"\nargument-hint: \"Goal (write\u002Freview\u002Frefactor), the Go code or brief, target package boundary, runtime context (CLI, HTTP service, library), and any constraints (Go version, allowed dependencies, performance budget)\"\n---\n\n# Idiomatic Go\n\n## What This Skill Does\n\nTurn a brief, a draft, or a piece of non-idiomatic Go into code that reads like the standard library: small interfaces on the consumer side, explicit error flow, useful zero values, and concurrency only where it earns its keep.\n\nThis skill treats Go as a constrained design target with one controlling rule: simplicity is a feature. Boring Go survives a decade of change in production. Clever Go costs more than it saves.\n\nUse this skill to:\n\n- Write a new package, CLI, or HTTP service in idiomatic Go.\n- Review or critique a Go PR, file, or function against the masterclass principles.\n- Refactor non-idiomatic Go (deep hierarchies, \"manager\" structs, preemptive interfaces, leaked goroutines, framework imports) into something composable.\n- Decide whether a problem actually needs concurrency, generics, or a third-party dependency before reaching for them.\n- Wire up the toolchain (`gofmt`, `go vet`, `golangci-lint`, `go test -race -cover`, `pprof`) so the language's authority is actually applied.\n\nThis skill is for Go craft. It is not for ranking Go against other languages, designing a multi-service architecture, picking a cloud provider, or writing project-specific style guides.\n\n## When to Use\n\n- The user has Go code (a function, file, or PR) and wants it shaped into something idiomatic.\n- The user has a brief (\"build a small ingest service in Go\") and wants the first cut written the way the standard library would write it.\n- An existing Go service feels Java-shaped — deep packages, getters\u002Fsetters, framework configuration, service\u002Fmanager classes — and needs flattening.\n- A user is reaching for goroutines, channels, generics, or a new dependency and wants a sanity check before the code lands.\n- A team is setting up a Go repo and needs the toolchain wired into CI before the second feature.\n\nDo not use this skill for:\n\n- Multi-service architecture, infra design, or cloud provider selection (use the backend or SRE agents).\n- Language comparisons or \"should we use Go\" decisions.\n- Mechanical formatting work that `gofmt` already enforces.\n- Very large refactors that need a real plan and review checkpoints rather than a single skill pass.\n\n## Inputs To Gather\n\nAsk only for what is missing. Do not block on optional inputs.\n\n- `goal` — `write`, `review`, `refactor`, or `toolchain`.\n- `code_or_brief` — the Go code to review or refactor, or a short brief for new code.\n- `runtime_context` — CLI, HTTP service, library, batch job, or test helper. Different shapes have different defaults (handlers, `context` propagation, `io.Reader`\u002F`io.Writer` boundaries).\n- `package_boundary` — what this package is responsible for in one sentence. If you cannot say it, the boundary is wrong.\n- `constraints` — Go version, allowed dependencies, performance budget, target deployment (single static binary, container, library import).\n\nHelpful but optional:\n\n- Existing project layout and naming conventions to align with.\n- Known performance hotspots, profiling output, or `-race` failures.\n- The single user-visible behavior the change is meant to support.\n\nIf the brief is \"make this Go code better,\" ask what the package is for and which behavior matters before touching anything. If the input is a 500-line `manager.go`, ask which one responsibility you may extract first rather than rewriting wholesale.\n\n## Non-Negotiable Constraints\n\nTreat these as defaults unless the user explicitly overrides them.\n\n1. **Clarity over cleverness.** If a function cannot be explained in one sentence, split it. Use `gofmt` formatting, idiomatic short names in narrow scopes (`i`, `r`, `buf`) and full names at package boundaries. The standard library — `io`, `net\u002Fhttp`, `sync`, `encoding\u002Fjson` — is the style reference.\n2. **Errors are values.** Return errors as the last value. Wrap with `fmt.Errorf(\"doing X: %w\", err)` to preserve the chain. Use `errors.Is` \u002F `errors.As` for behavioral checks. Never log-and-return — pick one. Reserve `panic` for impossible states, never for control flow.\n3. **Accept interfaces, return concrete types — and keep interfaces small.** Interfaces belong on the consumer side, defined by what _that_ caller needs (1–3 methods). Do not declare interfaces preemptively \"in case someone needs them.\" Return structs so callers see real capabilities. `io.Reader` \u002F `io.Writer` are the model.\n4. **Reach for goroutines last.** Start synchronous. Add concurrency only when there is a real reason. Every goroutine has a known lifetime, propagated `context.Context`, and a clear exit path. A `sync.Mutex` around a struct is often clearer than channels for shared state. Channels shine for ownership transfer and pipelines. Run tests with `-race`.\n5. **Design for the zero value and for composition.** Pick struct fields and defaults so `var x T` works (`bytes.Buffer{}`, `sync.Mutex{}`). Prefer struct embedding for composition. Build behavior by combining small pieces (`http.Handler`, middleware, `io` interfaces) rather than configuring a giant object.\n6. **The toolchain is part of the language.** `gofmt` is non-negotiable. `go vet` and `golangci-lint` run in CI. `go test -race -cover` is the default test invocation. Profile with `pprof` and the execution tracer before optimizing. Use modules with intentional, pinned versions.\n7. **Be conservative with dependencies.** \"A little copying is better than a little dependency.\" Lean on the standard library first — for an HTTP service often `net\u002Fhttp`, `encoding\u002Fjson`, `database\u002Fsql`, and `log\u002Fslog` are enough. When you do add a dependency, prefer small, focused libraries with clear maintainers.\n8. **Test behavior, not implementation.** Table-driven tests with `t.Run` subtests. Test exported behavior. Use `httptest.Server` and real I\u002FO over fakes when feasible. Keep test data in `testdata\u002F`. The small consumer-side interface (constraint 3) makes substitution trivial without a mocking framework.\n\n## Procedure\n\nFollow the steps in order. Do not skip the package-boundary step.\n\n### Step 1 — Confirm goal, boundary, and runtime context\n\nState, in one sentence each:\n\n- What this code is responsible for.\n- What runtime context it lives in (CLI, HTTP handler, library, batch job).\n- What user-visible behavior the change is meant to enable or protect.\n\nIf any of those is unclear, ask one targeted question rather than designing or reviewing around ambiguity. A package without a one-sentence responsibility is the real bug.\n\n### Step 2 — Read the existing code (or the standard library) before writing\n\nFor `review` or `refactor`:\n\n- Read the whole file or package, not just the diff.\n- Identify the consumer-side interfaces actually used. Note any interface declared on the producer side \"for flexibility.\"\n- Trace error paths from origin to where they are handled or surfaced.\n- Identify every goroutine and ask: what cancels it, and what closes its channels?\n\nFor `write`:\n\n- Skim the most relevant standard library package (`net\u002Fhttp`, `io`, `encoding\u002Fjson`, `database\u002Fsql`, `log\u002Fslog`) for the shape this code should match.\n- Look at one nearby package in the same repo for naming and layout conventions.\n\n### Step 3 — Design the smallest API that does the job\n\nBefore writing or rewriting code:\n\n- List the exported identifiers you intend to add. Justify each one.\n- For each consumer, write the 1–3 method interface they actually need on _their_ side, not on the producing package.\n- Define struct types so the zero value is useful where possible.\n- Decide error types: do callers branch on behavior? If yes, define sentinel errors or typed errors and document them. If no, wrap and propagate.\n\nIf the API has more than ~5 exported identifiers per file, or an interface with more than 3 methods, treat it as a smell and revisit the boundary.\n\n### Step 4 — Implement or refactor in idiomatic shape\n\nWrite or rewrite with these defaults:\n\n- Functions take `context.Context` as the first parameter for anything that does I\u002FO, blocks, or spawns goroutines.\n- Errors are wrapped with `%w` and a short doing-X verb phrase. No stack traces, no log-and-return.\n- Synchronous by default. Goroutines only with a clear lifetime and exit path.\n- Embedding over inheritance-style hierarchies. No `BaseService`, `AbstractFoo`, or \"manager\" coupling.\n- Structured logging via `log\u002Fslog` with stable keys. No `fmt.Println` for ops output.\n- HTTP handlers are small `http.Handler` values, composed via middleware. No framework imports unless the constraints require one.\n- For shared state, prefer a small struct guarded by a `sync.Mutex` over channel choreography.\n\n### Step 5 — Wire up the toolchain checks\n\nBefore declaring code ready:\n\n- `gofmt -l` returns no files. (`goimports -l` if used.)\n- `go vet .\u002F...` passes.\n- `golangci-lint run` passes (or the chosen subset documented in the repo).\n- `go test -race -cover .\u002F...` passes. Coverage is honest — exported behavior, not glue.\n- For performance-sensitive code, capture a `pprof` profile or a benchmark in `testing.B` before making optimization claims.\n\nIf any of these steps are not part of CI yet, add them before adding more features.\n\n### Step 6 — Final pass for Go-specific anti-patterns\n\nBefore delivering, scan for:\n\n- Interfaces declared on the producing side without two concrete implementations behind them.\n- Goroutines started without a `context`, deferred `Close`, or termination signal.\n- `panic` used for control flow, or `recover` outside a top-level boundary.\n- Deep package hierarchies, `internal\u002Futil`, or \"manager\"\u002F\"service\" classes used as namespaces.\n- Configuration frameworks where a struct literal would do.\n- `interface{}` or `any` where a small typed interface or generic would say what is meant.\n- Tests that mock everything and verify implementation rather than behavior.\n\nCut, inline, or rewrite anything that fails this scan.\n\n## Branching Logic\n\n- **Writing a new HTTP service.** Default to `net\u002Fhttp` plus `log\u002Fslog`, `encoding\u002Fjson`, and `database\u002Fsql`. Define handlers as small `http.Handler` values. Compose middleware. Propagate `context.Context`. Resist frameworks unless the constraints require one.\n- **Writing a new library.** Optimize for the caller. Define types whose zero value is useful. Return concrete types. Let consumers declare their own interfaces. Keep the dependency footprint near zero.\n- **Reviewing a PR.** Lead with the structural issues (package boundary, interface placement, goroutine lifetime). Then error flow. Then style. Do not let `gofmt`-level nits crowd out design feedback.\n- **Refactoring \"Java-shaped\" Go.** Do not rewrite wholesale. Pick one responsibility, extract it into a flat package with a useful zero value, route one caller through it, and ship. Repeat.\n- **Concurrency request.** Push back first. Most \"needs concurrency\" problems are I\u002FO or design problems. If real, prefer pipelines with channels for ownership transfer or `sync.Mutex` for shared state. Always require `-race` and a documented exit path.\n- **Generics request.** Confirm there are at least two concrete callers that share a type-parameterized shape. If not, write the concrete version and revisit later.\n- **Dependency request.** Check the standard library first. If a dependency is justified, prefer small, focused libraries with active maintainers and stable APIs. Pin versions intentionally.\n- **Toolchain-only task.** Wire `gofmt`, `go vet`, `golangci-lint`, and `go test -race -cover` into CI before adding linting rules. Add `pprof` and the execution tracer when there is a real performance question.\n\n## Output Format\n\nMatch the deliverable to the task.\n\nFor `write`:\n\n1. The Go code, formatted as `gofmt` would format it, in the file layout you recommend (one fenced block per file, with the path as a header).\n2. A short **Notes** section: package boundary in one sentence, the consumer-side interfaces, what is intentionally _not_ included, and what the next change would be.\n3. A **Toolchain** snippet showing how to run `gofmt`, `go vet`, `golangci-lint`, and `go test -race -cover` for this package.\n\nFor `review`:\n\n1. A prioritized list of findings, grouped: structural \u002F error flow \u002F concurrency \u002F style \u002F tests. Each finding cites the file and rough location and explains the principle it violates.\n2. A \"leave it\" section for things that look unidiomatic but are fine in this context — disagreement is allowed.\n3. A short suggested patch (diff or before\u002Fafter snippet) for the top one or two issues.\n\nFor `refactor`:\n\n1. A one-paragraph summary: what responsibility is being extracted and why.\n2. The refactored Go code in fenced blocks per file.\n3. A migration note: which call sites change, in what order, and how to verify nothing regressed (tests, `-race` run, coverage on the new boundary).\n\nFor `toolchain`:\n\n1. A minimal CI step (or `Makefile`\u002F`justfile` snippet) that runs the standard toolchain.\n2. A `golangci-lint` config that turns on a defensible default set, not everything.\n3. One follow-up suggestion (benchmarks, pprof endpoint, execution tracer) if the project will outgrow the basics soon.\n\n## Quality Checks\n\nThe work is ready only when all of the following are true:\n\n1. The package or change can be described in one sentence, and that sentence matches the code.\n2. Errors are values: wrapped with `%w`, checked with `errors.Is` \u002F `errors.As` where behavior matters, and never both logged and returned.\n3. Interfaces are small, declared on the consumer side, and justified by at least one real caller.\n4. Concrete types are returned. Zero values are useful where reasonable.\n5. Every goroutine has a known lifetime, a propagated `context.Context`, and a clear exit path. Tests pass under `-race`.\n6. Composition is via small pieces (`http.Handler`, middleware, `io` interfaces, struct embedding), not via deep hierarchies or \"manager\" classes.\n7. The standard library does the work it can. Each external dependency has a one-sentence justification.\n8. `gofmt`, `go vet`, `golangci-lint`, and `go test -race -cover` all pass on the affected packages.\n9. Tests exercise behavior, are table-driven where it helps, and use `httptest`\u002Freal I\u002FO where realistic.\n10. The output reads like code from `io`, `net\u002Fhttp`, or `sync` — boring, obvious, and easy to change.\n\n## Failure Modes To Avoid\n\n- Declaring interfaces on the producing side \"in case someone needs them,\" then passing them everywhere.\n- Goroutine and resource leaks: starting goroutines without `context`, deferred `Close`, or a clear termination signal.\n- Java- or Python-shaped Go: deep package hierarchies, getters\u002Fsetters, \"manager\"\u002F\"service\"\u002F\"helper\" classes, configuration frameworks, dependency-injection containers.\n- Wrapping `net\u002Fhttp` in a framework before there is a reason to.\n- Using `panic`\u002F`recover` for control flow.\n- Catching all errors at the top with `fmt.Errorf(\"error: %v\", err)` instead of `%w`, losing the chain.\n- Mocking every collaborator in tests so the test is a mirror of the implementation.\n- Reaching for generics, channels, or new dependencies before two concrete callers justify them.\n- Optimizing without a benchmark or `pprof` profile to point at.\n- Treating `gofmt`\u002F`go vet`\u002F`golangci-lint`\u002F`-race` as optional. They are part of the language.\n\n## Default Stance\n\nBoring Go is the goal. The standard library is the style guide. Small interfaces beat large ones. Useful zero values beat constructors. Synchronous beats concurrent until proven otherwise. One package with a clear sentence beats five with overlapping responsibilities. When in doubt, copy the shape of `io`, `net\u002Fhttp`, or `sync`, run `go test -race -cover`, and ship the simpler version.\n\n## Bundled research\n\nRead only the research relevant to the task; the working instructions above are usable on their own.\n\n- For the research rationale, practitioner guidance, and examples behind these instructions, consult [go-language.md](references\u002Fgo-language.md).\n","# Idiomatic Go\n\n## What This Skill Does\n\nTurn a brief, a draft, or a piece of non-idiomatic Go into code that reads like the standard library: small interfaces on the consumer side, explicit error flow, useful zero values, and concurrency only where it earns its keep.\n\nThis skill treats Go as a constrained design target with one controlling rule: simplicity is a feature. Boring Go survives a decade of change in production. Clever Go costs more than it saves.\n\nUse this skill to:\n\n- Write a new package, CLI, or HTTP service in idiomatic Go.\n- Review or critique a Go PR, file, or function against the masterclass principles.\n- Refactor non-idiomatic Go (deep hierarchies, \"manager\" structs, preemptive interfaces, leaked goroutines, framework imports) into something composable.\n- Decide whether a problem actually needs concurrency, generics, or a third-party dependency before reaching for them.\n- Wire up the toolchain (`gofmt`, `go vet`, `golangci-lint`, `go test -race -cover`, `pprof`) so the language's authority is actually applied.\n\nThis skill is for Go craft. It is not for ranking Go against other languages, designing a multi-service architecture, picking a cloud provider, or writing project-specific style guides.\n\n## When to Use\n\n- The user has Go code (a function, file, or PR) and wants it shaped into something idiomatic.\n- The user has a brief (\"build a small ingest service in Go\") and wants the first cut written the way the standard library would write it.\n- An existing Go service feels Java-shaped — deep packages, getters\u002Fsetters, framework configuration, service\u002Fmanager classes — and needs flattening.\n- A user is reaching for goroutines, channels, generics, or a new dependency and wants a sanity check before the code lands.\n- A team is setting up a Go repo and needs the toolchain wired into CI before the second feature.\n\nDo not use this skill for:\n\n- Multi-service architecture, infra design, or cloud provider selection (use the backend or SRE agents).\n- Language comparisons or \"should we use Go\" decisions.\n- Mechanical formatting work that `gofmt` already enforces.\n- Very large refactors that need a real plan and review checkpoints rather than a single skill pass.\n\n## Inputs To Gather\n\nAsk only for what is missing. Do not block on optional inputs.\n\n- `goal` — `write`, `review`, `refactor`, or `toolchain`.\n- `code_or_brief` — the Go code to review or refactor, or a short brief for new code.\n- `runtime_context` — CLI, HTTP service, library, batch job, or test helper. Different shapes have different defaults (handlers, `context` propagation, `io.Reader`\u002F`io.Writer` boundaries).\n- `package_boundary` — what this package is responsible for in one sentence. If you cannot say it, the boundary is wrong.\n- `constraints` — Go version, allowed dependencies, performance budget, target deployment (single static binary, container, library import).\n\nHelpful but optional:\n\n- Existing project layout and naming conventions to align with.\n- Known performance hotspots, profiling output, or `-race` failures.\n- The single user-visible behavior the change is meant to support.\n\nIf the brief is \"make this Go code better,\" ask what the package is for and which behavior matters before touching anything. If the input is a 500-line `manager.go`, ask which one responsibility you may extract first rather than rewriting wholesale.\n\n## Non-Negotiable Constraints\n\nTreat these as defaults unless the user explicitly overrides them.\n\n1. **Clarity over cleverness.** If a function cannot be explained in one sentence, split it. Use `gofmt` formatting, idiomatic short names in narrow scopes (`i`, `r`, `buf`) and full names at package boundaries. The standard library — `io`, `net\u002Fhttp`, `sync`, `encoding\u002Fjson` — is the style reference.\n2. **Errors are values.** Return errors as the last value. Wrap with `fmt.Errorf(\"doing X: %w\", err)` to preserve the chain. Use `errors.Is` \u002F `errors.As` for behavioral checks. Never log-and-return — pick one. Reserve `panic` for impossible states, never for control flow.\n3. **Accept interfaces, return concrete types — and keep interfaces small.** Interfaces belong on the consumer side, defined by what _that_ caller needs (1–3 methods). Do not declare interfaces preemptively \"in case someone needs them.\" Return structs so callers see real capabilities. `io.Reader` \u002F `io.Writer` are the model.\n4. **Reach for goroutines last.** Start synchronous. Add concurrency only when there is a real reason. Every goroutine has a known lifetime, propagated `context.Context`, and a clear exit path. A `sync.Mutex` around a struct is often clearer than channels for shared state. Channels shine for ownership transfer and pipelines. Run tests with `-race`.\n5. **Design for the zero value and for composition.** Pick struct fields and defaults so `var x T` works (`bytes.Buffer{}`, `sync.Mutex{}`). Prefer struct embedding for composition. Build behavior by combining small pieces (`http.Handler`, middleware, `io` interfaces) rather than configuring a giant object.\n6. **The toolchain is part of the language.** `gofmt` is non-negotiable. `go vet` and `golangci-lint` run in CI. `go test -race -cover` is the default test invocation. Profile with `pprof` and the execution tracer before optimizing. Use modules with intentional, pinned versions.\n7. **Be conservative with dependencies.** \"A little copying is better than a little dependency.\" Lean on the standard library first — for an HTTP service often `net\u002Fhttp`, `encoding\u002Fjson`, `database\u002Fsql`, and `log\u002Fslog` are enough. When you do add a dependency, prefer small, focused libraries with clear maintainers.\n8. **Test behavior, not implementation.** Table-driven tests with `t.Run` subtests. Test exported behavior. Use `httptest.Server` and real I\u002FO over fakes when feasible. Keep test data in `testdata\u002F`. The small consumer-side interface (constraint 3) makes substitution trivial without a mocking framework.\n\n## Procedure\n\nFollow the steps in order. Do not skip the package-boundary step.\n\n### Step 1 — Confirm goal, boundary, and runtime context\n\nState, in one sentence each:\n\n- What this code is responsible for.\n- What runtime context it lives in (CLI, HTTP handler, library, batch job).\n- What user-visible behavior the change is meant to enable or protect.\n\nIf any of those is unclear, ask one targeted question rather than designing or reviewing around ambiguity. A package without a one-sentence responsibility is the real bug.\n\n### Step 2 — Read the existing code (or the standard library) before writing\n\nFor `review` or `refactor`:\n\n- Read the whole file or package, not just the diff.\n- Identify the consumer-side interfaces actually used. Note any interface declared on the producer side \"for flexibility.\"\n- Trace error paths from origin to where they are handled or surfaced.\n- Identify every goroutine and ask: what cancels it, and what closes its channels?\n\nFor `write`:\n\n- Skim the most relevant standard library package (`net\u002Fhttp`, `io`, `encoding\u002Fjson`, `database\u002Fsql`, `log\u002Fslog`) for the shape this code should match.\n- Look at one nearby package in the same repo for naming and layout conventions.\n\n### Step 3 — Design the smallest API that does the job\n\nBefore writing or rewriting code:\n\n- List the exported identifiers you intend to add. Justify each one.\n- For each consumer, write the 1–3 method interface they actually need on _their_ side, not on the producing package.\n- Define struct types so the zero value is useful where possible.\n- Decide error types: do callers branch on behavior? If yes, define sentinel errors or typed errors and document them. If no, wrap and propagate.\n\nIf the API has more than ~5 exported identifiers per file, or an interface with more than 3 methods, treat it as a smell and revisit the boundary.\n\n### Step 4 — Implement or refactor in idiomatic shape\n\nWrite or rewrite with these defaults:\n\n- Functions take `context.Context` as the first parameter for anything that does I\u002FO, blocks, or spawns goroutines.\n- Errors are wrapped with `%w` and a short doing-X verb phrase. No stack traces, no log-and-return.\n- Synchronous by default. Goroutines only with a clear lifetime and exit path.\n- Embedding over inheritance-style hierarchies. No `BaseService`, `AbstractFoo`, or \"manager\" coupling.\n- Structured logging via `log\u002Fslog` with stable keys. No `fmt.Println` for ops output.\n- HTTP handlers are small `http.Handler` values, composed via middleware. No framework imports unless the constraints require one.\n- For shared state, prefer a small struct guarded by a `sync.Mutex` over channel choreography.\n\n### Step 5 — Wire up the toolchain checks\n\nBefore declaring code ready:\n\n- `gofmt -l` returns no files. (`goimports -l` if used.)\n- `go vet .\u002F...` passes.\n- `golangci-lint run` passes (or the chosen subset documented in the repo).\n- `go test -race -cover .\u002F...` passes. Coverage is honest — exported behavior, not glue.\n- For performance-sensitive code, capture a `pprof` profile or a benchmark in `testing.B` before making optimization claims.\n\nIf any of these steps are not part of CI yet, add them before adding more features.\n\n### Step 6 — Final pass for Go-specific anti-patterns\n\nBefore delivering, scan for:\n\n- Interfaces declared on the producing side without two concrete implementations behind them.\n- Goroutines started without a `context`, deferred `Close`, or termination signal.\n- `panic` used for control flow, or `recover` outside a top-level boundary.\n- Deep package hierarchies, `internal\u002Futil`, or \"manager\"\u002F\"service\" classes used as namespaces.\n- Configuration frameworks where a struct literal would do.\n- `interface{}` or `any` where a small typed interface or generic would say what is meant.\n- Tests that mock everything and verify implementation rather than behavior.\n\nCut, inline, or rewrite anything that fails this scan.\n\n## Branching Logic\n\n- **Writing a new HTTP service.** Default to `net\u002Fhttp` plus `log\u002Fslog`, `encoding\u002Fjson`, and `database\u002Fsql`. Define handlers as small `http.Handler` values. Compose middleware. Propagate `context.Context`. Resist frameworks unless the constraints require one.\n- **Writing a new library.** Optimize for the caller. Define types whose zero value is useful. Return concrete types. Let consumers declare their own interfaces. Keep the dependency footprint near zero.\n- **Reviewing a PR.** Lead with the structural issues (package boundary, interface placement, goroutine lifetime). Then error flow. Then style. Do not let `gofmt`-level nits crowd out design feedback.\n- **Refactoring \"Java-shaped\" Go.** Do not rewrite wholesale. Pick one responsibility, extract it into a flat package with a useful zero value, route one caller through it, and ship. Repeat.\n- **Concurrency request.** Push back first. Most \"needs concurrency\" problems are I\u002FO or design problems. If real, prefer pipelines with channels for ownership transfer or `sync.Mutex` for shared state. Always require `-race` and a documented exit path.\n- **Generics request.** Confirm there are at least two concrete callers that share a type-parameterized shape. If not, write the concrete version and revisit later.\n- **Dependency request.** Check the standard library first. If a dependency is justified, prefer small, focused libraries with active maintainers and stable APIs. Pin versions intentionally.\n- **Toolchain-only task.** Wire `gofmt`, `go vet`, `golangci-lint`, and `go test -race -cover` into CI before adding linting rules. Add `pprof` and the execution tracer when there is a real performance question.\n\n## Output Format\n\nMatch the deliverable to the task.\n\nFor `write`:\n\n1. The Go code, formatted as `gofmt` would format it, in the file layout you recommend (one fenced block per file, with the path as a header).\n2. A short **Notes** section: package boundary in one sentence, the consumer-side interfaces, what is intentionally _not_ included, and what the next change would be.\n3. A **Toolchain** snippet showing how to run `gofmt`, `go vet`, `golangci-lint`, and `go test -race -cover` for this package.\n\nFor `review`:\n\n1. A prioritized list of findings, grouped: structural \u002F error flow \u002F concurrency \u002F style \u002F tests. Each finding cites the file and rough location and explains the principle it violates.\n2. A \"leave it\" section for things that look unidiomatic but are fine in this context — disagreement is allowed.\n3. A short suggested patch (diff or before\u002Fafter snippet) for the top one or two issues.\n\nFor `refactor`:\n\n1. A one-paragraph summary: what responsibility is being extracted and why.\n2. The refactored Go code in fenced blocks per file.\n3. A migration note: which call sites change, in what order, and how to verify nothing regressed (tests, `-race` run, coverage on the new boundary).\n\nFor `toolchain`:\n\n1. A minimal CI step (or `Makefile`\u002F`justfile` snippet) that runs the standard toolchain.\n2. A `golangci-lint` config that turns on a defensible default set, not everything.\n3. One follow-up suggestion (benchmarks, pprof endpoint, execution tracer) if the project will outgrow the basics soon.\n\n## Quality Checks\n\nThe work is ready only when all of the following are true:\n\n1. The package or change can be described in one sentence, and that sentence matches the code.\n2. Errors are values: wrapped with `%w`, checked with `errors.Is` \u002F `errors.As` where behavior matters, and never both logged and returned.\n3. Interfaces are small, declared on the consumer side, and justified by at least one real caller.\n4. Concrete types are returned. Zero values are useful where reasonable.\n5. Every goroutine has a known lifetime, a propagated `context.Context`, and a clear exit path. Tests pass under `-race`.\n6. Composition is via small pieces (`http.Handler`, middleware, `io` interfaces, struct embedding), not via deep hierarchies or \"manager\" classes.\n7. The standard library does the work it can. Each external dependency has a one-sentence justification.\n8. `gofmt`, `go vet`, `golangci-lint`, and `go test -race -cover` all pass on the affected packages.\n9. Tests exercise behavior, are table-driven where it helps, and use `httptest`\u002Freal I\u002FO where realistic.\n10. The output reads like code from `io`, `net\u002Fhttp`, or `sync` — boring, obvious, and easy to change.\n\n## Failure Modes To Avoid\n\n- Declaring interfaces on the producing side \"in case someone needs them,\" then passing them everywhere.\n- Goroutine and resource leaks: starting goroutines without `context`, deferred `Close`, or a clear termination signal.\n- Java- or Python-shaped Go: deep package hierarchies, getters\u002Fsetters, \"manager\"\u002F\"service\"\u002F\"helper\" classes, configuration frameworks, dependency-injection containers.\n- Wrapping `net\u002Fhttp` in a framework before there is a reason to.\n- Using `panic`\u002F`recover` for control flow.\n- Catching all errors at the top with `fmt.Errorf(\"error: %v\", err)` instead of `%w`, losing the chain.\n- Mocking every collaborator in tests so the test is a mirror of the implementation.\n- Reaching for generics, channels, or new dependencies before two concrete callers justify them.\n- Optimizing without a benchmark or `pprof` profile to point at.\n- Treating `gofmt`\u002F`go vet`\u002F`golangci-lint`\u002F`-race` as optional. They are part of the language.\n\n## Default Stance\n\nBoring Go is the goal. The standard library is the style guide. Small interfaces beat large ones. Useful zero values beat constructors. Synchronous beats concurrent until proven otherwise. One package with a clear sentence beats five with overlapping responsibilities. When in doubt, copy the shape of `io`, `net\u002Fhttp`, or `sync`, run `go test -race -cover`, and ship the simpler version.\n\n## Bundled research\n\nRead only the research relevant to the task; the working instructions above are usable on their own.\n\n- For the research rationale, practitioner guidance, and examples behind these instructions, consult [go-language.md](references\u002Fgo-language.md).\n",{"name":5,"description":7,"argument-hint":44},"Goal (write\u002Freview\u002Frefactor), the Go code or brief, target package boundary, runtime context (CLI, HTTP service, library), and any constraints (Go version, allowed dependencies, performance budget)","main","8ce32059dd72b0d7bbe85f968f2db65ab868de26","skills\u002Fidiomatic-go",2,"https:\u002F\u002Fgithub.com\u002Fmaltehedderich\u002Fmaster-class-agents","https:\u002F\u002Fgithub.com\u002Fmaltehedderich","hedderich.pro","2026-11-14 22:59:28",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add maltehedderich\u002Fmaster-class-agents --skill idiomatic-go",{"tool":59,"command":60},"bunx","bunx skills add maltehedderich\u002Fmaster-class-agents --skill idiomatic-go",{"tool":62,"command":63},"pnpm","pnpm dlx skills add maltehedderich\u002Fmaster-class-agents --skill idiomatic-go","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmaltehedderich\u002Fmaster-class-agents\u002Fblob\u002Fmain\u002Fskills\u002Fidiomatic-go\u002FSKILL.md",true,[67],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Fgo-language.md","REFERENCE","参考文档",6947,"https:\u002F\u002Fgithub.com\u002Fmaltehedderich\u002Fmaster-class-agents\u002Fblob\u002Fmain\u002Fskills\u002Fidiomatic-go\u002Freferences\u002Fgo-language.md",[74,82,89,96,103,110],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":81},"01M7DVR6394F08C0DBSTSBP83P","ux-designer","UX design with research-driven product judgment. Use when: defining user flows, information architecture, wireframes, interaction patterns, usability testing, onboarding flows, navigation design, form design, error states, empty states, design critique, heuristic evaluation, UX writing, journey mapping, accessibility review, and prioritizing friction in product experiences.","https:\u002F\u002Fgithub.com\u002Fmaltehedderich\u002Fmaster-class-agents\u002Fblob\u002Fmain\u002Fskills\u002Fux-designer\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":81},"01M7DVQXBZZRY03JPR3HS19F7V","ui-designer","UI design with systems-level visual judgment. Use when: defining visual hierarchy, interface layout, typography systems, spacing systems, color systems, component states, design system polish, high-fidelity mockups, interface critique, responsive visual refinement, visual QA, and handoff-ready screen specifications.","https:\u002F\u002Fgithub.com\u002Fmaltehedderich\u002Fmaster-class-agents\u002Fblob\u002Fmain\u002Fskills\u002Fui-designer\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":81},"01M7DVQHSXES02BTVT6KWNZHJZ","terraform-specialist","Terraform-focused DevOps engineering with production-grade judgment. Use when: designing Terraform modules, reviewing HCL, structuring infrastructure as code repositories, isolating remote state, planning safe infra changes, debugging Terraform drift, improving plan and apply workflows, pinning providers or modules, hardening CI for Terraform, reviewing backend configuration, secrets handling, OIDC auth for IaC, blast-radius reduction, Terratest or terraform test strategy, tflint, tfsec, and checkov adoption.","https:\u002F\u002Fgithub.com\u002Fmaltehedderich\u002Fmaster-class-agents\u002Fblob\u002Fmain\u002Fskills\u002Fterraform-specialist\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":81},"01M7DVQ4BCMCJMFV7Q08V95TTM","technical-writer","Technical writing with reader-first craft. Use when: writing or editing READMEs, API documentation, how-to guides, tutorials, reference docs, migration guides, changelogs, architecture decision records, onboarding docs, runbooks, CLI help text, inline code comments rewrite, docs review, fixing stale documentation, restructuring docs using Diátaxis, writing release notes, developer-facing prose.","https:\u002F\u002Fgithub.com\u002Fmaltehedderich\u002Fmaster-class-agents\u002Fblob\u002Fmain\u002Fskills\u002Ftechnical-writer\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":81},"01M7DVPY759QCBHV08QEG5CKRX","technical-educator","Technical education with learner-first clarity. Use when: explaining complex technical concepts, teaching code or systems from first principles, designing tutorials or workshops, creating onboarding learning materials, writing lesson plans, building step-by-step walkthroughs, translating jargon into intuition, diagnosing misconceptions, and turning implementation details into durable mental models.","https:\u002F\u002Fgithub.com\u002Fmaltehedderich\u002Fmaster-class-agents\u002Fblob\u002Fmain\u002Fskills\u002Ftechnical-educator\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":81},"01M7DVPS6YGSCP5JDKM60NCN6T","site-reliability-engineer","Site reliability engineering with production-grade judgment. Use when: defining SLIs and SLOs, setting error budgets, writing or reviewing alerting rules, designing on-call rotations, running or writing blameless postmortems, eliminating toil, capacity planning, load testing, progressive rollout strategy, chaos engineering, incident response, change management, graceful degradation, circuit breakers, load shedding, observability strategy, SLO-based alerting, burn-rate windows, reliability reviews, launch readiness.","https:\u002F\u002Fgithub.com\u002Fmaltehedderich\u002Fmaster-class-agents\u002Fblob\u002Fmain\u002Fskills\u002Fsite-reliability-engineer\u002FSKILL.md",[],[]]