← ClaudeAtlas

golang-code-stylelisted

Write or review readable, idiomatic Go code with attention to control flow, declarations, comments, file organization, and API clarity. Use for focused style work or project coding conventions; use dedicated naming, lint, documentation, or architecture guidance when those are the main task.
reagin/agent-skills · ★ 0 · Code & Development · score 63
Install: claude install-skill reagin/agent-skills
# Go Code Style Make code easier to understand without turning preferences into universal rules. Preserve behavior, public APIs, and repository conventions unless the user explicitly asks to change them. ## Establish the local style Before editing: 1. Read repository instructions, `go.mod`, formatter and linter configuration, and nearby code. 2. Identify whether the task is implementation, focused review, or project-wide policy design, and keep the change at that scale. 3. Use `gofmt` as the formatting baseline. Use stricter formatters only when the project already configures them. 4. Prefer established local conventions when several idiomatic forms are equally clear. ## Clarity heuristics Apply these with judgment: - Handle exceptional paths early when that makes the main flow flatter. Keep an `else` when it expresses a real two-way decision more clearly. - Give intermediate values names when they reveal domain meaning or make a condition auditable. Do not extract trivial expressions merely to satisfy an operand count. - Keep a value's scope narrow, including `if` initializers when the value is used only by that branch. - Split functions when the extracted operation has a coherent responsibility, invariant, or test boundary—not because of an arbitrary line threshold. - Group parameters into a request or options type when they form a stable concept or evolution point. A long signature alone is not sufficient reason. - Use `switch` when it clarifies one discriminant or