agentleFS
h0rn3th0rn3t/golang-skills/skills/go-naming/SKILL.md

go-naming

Skill7 starsChanged 10 days agoApache-2.0View on GitHub

Use when naming Go packages, types, functions, methods, variables, constants, or receiver names, including new types and exported APIs. Package organization belongs to go-packages.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Go Naming Conventions

Resource Routing

  • scripts/check-naming.sh - Run when checking SCREAMING_SNAKE_CASE constants, Get-prefixed methods with no parameters, generic package names, or receivers named this/self.
  • scripts/check-naming-ast.go - Implementation helper built and run by check-naming.sh; not run or read directly.
  • references/IDENTIFIERS.md - Read for the conventions themselves — package, interface, receiver, constant, initialism, getter and type-suffix names — when a choice for an exported identifier or package-level symbol is in doubt.
  • references/REPETITION.md - Read when names repeat package, receiver, type, or local context.
  • references/VARIABLES.md - Read when choosing local variable names, receiver names, or loop identifiers.

Core Principle

A name is read where it is used, never where it is declared: it does not repeat the package, the receiver, or the surrounding context, and its length grows with the distance between declaration and use. Go names are shorter than in most languages. The reader knows the conventions — MixedCaps, lowercase packages, -er interfaces, short consistent receivers, no Get prefix, initialisms in one case — so this skill carries the decisions and references/ the rules. A package name is short, lowercase, and a single word; layer directories take the plural layer names handlers, services, repositories, models.


Error Names

Normative: Sentinel errors are ErrNotFound when exported and errNotFound when not; error types end in Error (NotFoundError), never ErrNotFoundError. errname in the lint baseline enforces the Err/err prefix and the Error suffix; it accepts ErrNotFoundError, so a name with both is a review item.


Where Review Sends Names Back

  • Repetition against context. widget.New() not widget.NewWidget(); p.Name() not p.ProjectName(); in package sqldb, Connection not DBConnection. A generic package name — util, common, helper — is a finding; name the package for what it provides (httpauth, stringutil). REPETITION.md has the cases.
  • _ prefix on unexported globals (Uber only; Google style does not use it): new code writes defaultPort, not _defaultPort, including new code with no neighbor to match. Only a package that already prefixes its globals keeps doing so (VARIABLES.md).
  • Type in the name. users not userSlice, name not nameString; when functions differ only by type, the type goes at the end (ParseInt, ParseInt64).
  • A predeclared identifier as a name. error, string, len, cap, append, copy, new, make as a variable, parameter, or type name compiles and hides the built-in for the rest of the scope (predeclared in the gate reports it); SHADOWING.md owns detection.

Validation

Validation: bash <installed-skill-dir>/scripts/check-naming.sh, run from the project, reports the four patterns its Resource Routing line names. Error names are errname's and package stutter is revive exported's, both in the go-linting gate; the rest of the repetition above has no check. Run the script once at the end of the task, beside that gate, which does not run it.

Related Skills

  • go-interfaces: pointer versus value receivers; their names are IDENTIFIERS.md's Receiver Names.
  • go-packages: splitting packages, import collisions; package names are IDENTIFIERS.md's Package Names.
  • go-style-core: shadowing of built-ins, clarity against concision; name length by scope is VARIABLES.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.