go-code-review
Use when reviewing Go code or checking code against community style standards. Also use proactively before submitting a Go PR or…
Use when naming any Go identifier — packages, types, functions, methods, variables, constants, or receivers — to ensure idiomatic, clear names. Also use when a user is creating new types, packages, or exported APIs, even if they don't explicitly ask about naming conventions.
$ npx -y skills add cxuu/golang-skills --skill go-naming --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/go-namingContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when naming any Go identifier — packages, types, functions, methods, variables, constants, or receivers — to ensure idiomatic, clear names. Also use when a user is creating new types, packages, or exported APIs, even if they don't explicitly ask about naming conventions.
name: go-naming description: Use when naming any Go identifier — packages, types, functions, methods, variables, constants, or receivers — to ensure idiomatic, clear names. Also use when a user is creating new types, packages, or exported APIs, even if they don't explicitly ask about naming conventions. Does not cover package organization (see go-packages). allowed-tools: Bash(bash:*)
Names should:
Naming is more art than science—Go names tend to be shorter than in other languages.
---
What are you naming? ├─ Package → Short, lowercase, singular noun (no underscores, no mixedCaps) ├─ Interface → Method name + "-er" suffix when single-method (Reader, Writer) ├─ Receiver → 1-2 letter abbreviation of type (c for Client); consistent across methods ├─ Constant → MixedCaps; use iota for enums; no ALL_CAPS ├─ Exported func → Verb or verb-phrase in MixedCaps; no Get prefix for getters ├─ Variable → Length proportional to scope distance │ ├─ Tiny scope (1-7 lines) → single letter (i, n, r) │ ├─ Medium scope → short word (count, buf) │ └─ Package-level / wide → descriptive (userAccountCount) └─ Any name → Check: does it repeat package name or context? If yes, shorten it
---
> **Normative**: All Go identifiers must use MixedCaps.
Underscores are allowed only in: test functions (`TestFoo_InvalidInput`), generated code, and OS/cgo interop.
---
> **Normative**: Packages must be lowercase with no underscores.
Short, lowercase, singular nouns. Avoid generic names like `util`, `common`, `helper` — prefer specific names: `stringutil`, `httpauth`, `configloader`.
// Good: user, oauth2, tabwriter // Bad: user_service, UserService, count (shadows var)
---
> **Advisory**: One-method interfaces use "-er" suffix.
Name one-method interfaces by the method plus `-er`: `Reader`, `Writer`, `Formatter`. Honor canonical method names (`Read`, `Write`, `Close`, `String`) and their signatures.
---
> **Normative**: Receivers must be short abbreviations, used consistently.
One or two letters abbreviating the type, consistent across all methods: `func (c *Client) Connect()`, `func (c *Client) Send()`. Never use `this` or `self`.
---
> **Normative**: Constants use MixedCaps, never ALL_CAPS or K prefix.
Name constants by role, not value: `MaxRetries` not `Three`, `DefaultPort` not `Port8080`.
const MaxPacketSize = 512 const defaultTimeout = 30 * time.Second
---
> **Normative**: Initialisms maintain consistent case throughout.
Initialisms (URL, ID, HTTP, API) must be all uppercase or all lowercase: `HTTPClient`, `userID`, `ParseURL()` — not `HttpClient`, `orderId`, `ParseUrl()`.
---
> **Advisory**: No `Get` prefix for simple accessors; use verb-like names for actions.
Getter for field `owner` is `Owner()`, not `GetOwner()`. Setter is `SetOwner()`. Use `Compute` or `Fetch` for expensive operations.
When functions differ only by type, include type at the end: `ParseInt()`, `ParseInt64()`.
---
Variable naming balances brevity with clarity. Key principles:
descriptive names for larger scopes
`r`/`w` for reader/writer)
vars/consts to prevent shadowing
for i, v := range items { ... } // small scope
pendingOrders := filterPending(orders) // larger scope
const _defaultPort = 8080 // unexported global---
Go names should not feel repetitive when used. Consider the full context:
---
Never shadow Go's predeclared identifiers (`error`, `string`, `len`, `cap`, `append`, `copy`, `new`, `make`, etc.) as variable, parameter, or type names.
**For detailed guidance**: See `go-declarations` — "Avoid Using Built-In Names" section.
---
| Element | Rule | Example | |---------|------|---------| | Package | lowercase, no underscores | `package httputil` | | Exported | MixedCaps, starts uppercase | `func ParseURL()` | | Unexported | mixedCaps, starts lowercase | `func parseURL()` | | Receiver | 1-2 letter abbreviation | `func (c *Client)` | | Constant | MixedCaps, never ALL_CAPS | `const MaxSize = 100` | | Initialism | consistent case | `userID`, `XMLAPI` | | Variable | length ~ scope size | `i` (small), `userCount` (large) | | Built-in names | Never shadow predeclared identifiers | See `go-declarations` |
> **Validation**: After renaming identifiers, run `bash scripts/check-naming.sh` to verify no naming anti-patterns remain. Then run `go build ./...` to confirm the rename didn't break anything.
AI Agent Skills for writing idiomatic, production-quality Go code. 20 modular skills teach AI coding assistants Go best practices derived from: Google Go Style Guide Effective Go Uber Go Style Guide Go Wiki CodeReviewComments Skills are tuned following
Use when reviewing Go code or checking code against community style standards. Also use proactively before submitting a Go PR or…
Use when writing concurrent Go code — goroutines, channels, mutexes, or thread-safety guarantees. Also use when parallelizing…
Use when working with context.Context in Go — placement in signatures, propagating cancellation and deadlines, and storing values…
Use when writing conditionals, loops, or switch statements in Go — including if with initialization, early returns, for loop…
Use when working with Go slices, maps, or arrays — choosing between new and make, using append, declaring empty slices (nil vs…
Use when declaring or initializing Go variables, constants, structs, or maps — including var vs :=, reducing scope with if-init,…