{"id":"cf8bad32-3c24-4965-873d-938219319f23","shortId":"uGshHr","kind":"skill","title":"go-naming","tagline":"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","description":"# Go Naming Conventions\n\n## Available Scripts\n\n- **`scripts/check-naming.sh`** — Scans Go code for naming anti-patterns: SCREAMING_SNAKE_CASE constants, Get-prefixed getters, bad package names (util/helper/common), and receivers named \"this\"/\"self\". Run `bash scripts/check-naming.sh --help` for options.\n\n## Core Principle\n\nNames should:\n- Not feel repetitive when used\n- Take context into consideration\n- Not repeat concepts that are already clear\n\nNaming is more art than science—Go names tend to be shorter than in other\nlanguages.\n\n---\n\n## Naming Decision Flow\n\n```\nWhat are you naming?\n├─ Package       → Short, lowercase, singular noun (no underscores, no mixedCaps)\n├─ Interface     → Method name + \"-er\" suffix when single-method (Reader, Writer)\n├─ Receiver      → 1-2 letter abbreviation of type (c for Client); consistent across methods\n├─ Constant      → MixedCaps; use iota for enums; no ALL_CAPS\n├─ Exported func → Verb or verb-phrase in MixedCaps; no Get prefix for getters\n├─ Variable      → Length proportional to scope distance\n│                  ├─ Tiny scope (1-7 lines) → single letter (i, n, r)\n│                  ├─ Medium scope           → short word (count, buf)\n│                  └─ Package-level / wide   → descriptive (userAccountCount)\n└─ Any name      → Check: does it repeat package name or context? If yes, shorten it\n```\n\n---\n\n## MixedCaps (Required)\n\n> **Normative**: All Go identifiers must use MixedCaps.\n\nUnderscores are allowed only in: test functions (`TestFoo_InvalidInput`),\ngenerated code, and OS/cgo interop.\n\n---\n\n## Package Names\n\n> **Normative**: Packages must be lowercase with no underscores.\n\nShort, lowercase, singular nouns. Avoid generic names like `util`, `common`,\n`helper` — prefer specific names: `stringutil`, `httpauth`, `configloader`.\n\n```go\n// Good: user, oauth2, tabwriter\n// Bad:  user_service, UserService, count (shadows var)\n```\n\n> Read [references/IDENTIFIERS.md](references/IDENTIFIERS.md) when naming packages, deciding on import aliases, or choosing between generic and specific package names.\n\n---\n\n## Interface Names\n\n> **Advisory**: One-method interfaces use \"-er\" suffix.\n\nName one-method interfaces by the method plus `-er`: `Reader`, `Writer`,\n`Formatter`. Honor canonical method names (`Read`, `Write`, `Close`, `String`)\nand their signatures.\n\n> Read [references/IDENTIFIERS.md](references/IDENTIFIERS.md) when defining new interfaces or implementing well-known method signatures.\n\n---\n\n## Receiver Names\n\n> **Normative**: Receivers must be short abbreviations, used consistently.\n\nOne or two letters abbreviating the type, consistent across all methods:\n`func (c *Client) Connect()`, `func (c *Client) Send()`.\nNever use `this` or `self`.\n\n> Read [references/IDENTIFIERS.md](references/IDENTIFIERS.md) when choosing receiver names or ensuring consistency across methods.\n\n---\n\n## Constant Names\n\n> **Normative**: Constants use MixedCaps, never ALL_CAPS or K prefix.\n\nName constants by role, not value: `MaxRetries` not `Three`,\n`DefaultPort` not `Port8080`.\n\n```go\nconst MaxPacketSize = 512\nconst defaultTimeout = 30 * time.Second\n```\n\n> Read [references/IDENTIFIERS.md](references/IDENTIFIERS.md) when naming constants or choosing between role-based and value-based names.\n\n---\n\n## Initialisms and Acronyms\n\n> **Normative**: Initialisms maintain consistent case throughout.\n\nInitialisms (URL, ID, HTTP, API) must be all uppercase or all lowercase:\n`HTTPClient`, `userID`, `ParseURL()` — not `HttpClient`, `orderId`, `ParseUrl()`.\n\n> Read [references/IDENTIFIERS.md](references/IDENTIFIERS.md) when using initialisms in compound names or for the full case table.\n\n---\n\n## Function and Method Names\n\n> **Advisory**: No `Get` prefix for simple accessors; use verb-like names for actions.\n\nGetter for field `owner` is `Owner()`, not `GetOwner()`. Setter is\n`SetOwner()`. Use `Compute` or `Fetch` for expensive operations.\n\nWhen functions differ only by type, include type at the end:\n`ParseInt()`, `ParseInt64()`.\n\n> Read [references/IDENTIFIERS.md](references/IDENTIFIERS.md) when designing getter/setter APIs or naming function variants.\n\n---\n\n## Variable Names\n\nVariable naming balances brevity with clarity. Key principles:\n\n- **Scope-based length**: Short names (`i`, `v`) for small scopes; longer,\n  descriptive names for larger scopes\n- **Single-letter conventions**: Use familiar patterns (`i` for index,\n  `r`/`w` for reader/writer)\n- **Avoid type in name**: Use `users` not `userSlice`, `name` not `nameString`\n- **Prefix unexported globals**: Use `_` prefix for package-level unexported\n  vars/consts to prevent shadowing\n\n```go\nfor i, v := range items { ... }           // small scope\npendingOrders := filterPending(orders)    // larger scope\nconst _defaultPort = 8080                 // unexported global\n```\n\n> Read [references/VARIABLES.md](references/VARIABLES.md) when naming local variables in functions over 15 lines.\n\n---\n\n## Avoiding Repetition\n\nGo names should not feel repetitive when used. Consider the full context:\n\n- **Package + symbol**: `widget.New()` not `widget.NewWidget()`\n- **Receiver + method**: `p.Name()` not `p.ProjectName()`\n- **Context + type**: In package `sqldb`, use `Connection` not `DBConnection`\n\n> Read [references/REPETITION.md](references/REPETITION.md) when a package name and its exported symbols feel redundant.\n\n---\n\n## Avoid Built-In Names\n\nNever shadow Go's predeclared identifiers (`error`, `string`, `len`, `cap`,\n`append`, `copy`, `new`, `make`, etc.) as variable, parameter, or type names.\n\n**For detailed guidance**: See `go-declarations` — \"Avoid Using Built-In Names\"\nsection.\n\n---\n\n## Quick Reference\n\n| Element | Rule | Example |\n|---------|------|---------|\n| Package | lowercase, no underscores | `package httputil` |\n| Exported | MixedCaps, starts uppercase | `func ParseURL()` |\n| Unexported | mixedCaps, starts lowercase | `func parseURL()` |\n| Receiver | 1-2 letter abbreviation | `func (c *Client)` |\n| Constant | MixedCaps, never ALL_CAPS | `const MaxSize = 100` |\n| Initialism | consistent case | `userID`, `XMLAPI` |\n| Variable | length ~ scope size | `i` (small), `userCount` (large) |\n| Built-in names | Never shadow predeclared identifiers | See `go-declarations` |\n\n> **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.\n\n## Related Skills\n\n- **Interface naming**: See [go-interfaces](../go-interfaces/SKILL.md) when naming interfaces with the `-er` suffix or choosing receiver types\n- **Package naming**: See [go-packages](../go-packages/SKILL.md) when naming packages, avoiding `util`/`common`, or resolving import collisions\n- **Error naming**: See [go-error-handling](../go-error-handling/SKILL.md) when naming sentinel errors (`ErrFoo`) or custom error types\n- **Declaration scope**: See [go-declarations](../go-declarations/SKILL.md) when variable name length depends on scope or when avoiding built-in shadowing\n- **Style principles**: See [go-style-core](../go-style-core/SKILL.md) when balancing clarity vs concision in identifier names","tags":["naming","golang","skills","cxuu","agent-skills","ai-agent","ai-assistant","claude","claude-code","codex","cursor","llm"],"capabilities":["skill","source-cxuu","skill-go-naming","topic-agent-skills","topic-ai-agent","topic-ai-assistant","topic-claude","topic-claude-code","topic-codex","topic-cursor","topic-golang","topic-llm"],"categories":["golang-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/cxuu/golang-skills/go-naming","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add cxuu/golang-skills","source_repo":"https://github.com/cxuu/golang-skills","install_from":"skills.sh"}},"qualityScore":"0.491","qualityRationale":"deterministic score 0.49 from registry signals: · indexed on github topic:agent-skills · 82 github stars · SKILL.md body (7,140 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-02T12:55:18.779Z","embedding":null,"createdAt":"2026-04-18T22:13:18.886Z","updatedAt":"2026-05-02T12:55:18.779Z","lastSeenAt":"2026-05-02T12:55:18.779Z","tsv":"'-2':149,758 '-7':192 '/go-declarations/skill.md':884 '/go-error-handling/skill.md':868 '/go-interfaces/skill.md':832 '/go-packages/skill.md':850 '/go-style-core/skill.md':906 '1':148,191,757 '100':771 '15':645 '30':429 '512':426 '8080':632 'abbrevi':151,360,367,760 'accessor':501 'acronym':450 'across':158,371,397 'action':508 'advisori':307,495 'alias':296 'allow':236 'alreadi':102 'also':23 'anti':59,809 'anti-pattern':58,808 'anyth':823 'api':35,461,546 'append':708 'art':107 'ask':42 'avail':50 'avoid':262,592,647,693,726,854,894 'bad':69,280 'balanc':555,908 'base':442,446,563 'bash':79,802 'break':822 'breviti':556 'buf':204 'build':815 'built':695,729,786,896 'built-in':694,728,785,895 'c':154,375,379,762 'canon':329 'cap':168,407,707,768 'case':63,455,489,774 'check':213 'choos':298,391,438,841 'clariti':558,909 'clear':21,103 'client':156,376,380,763 'close':334 'code':55,244 'collis':860 'common':267,856 'compound':483 'comput':521 'concept':99 'concis':911 'configload':274 'confirm':817 'connect':377,677 'consid':657 'consider':96 'consist':157,362,370,396,454,773 'const':424,427,630,769 'constant':15,64,160,399,402,412,436,764 'context':94,220,660,671 'convent':45,49,581 'copi':709 'core':84,905 'count':203,284 'creat':29 'custom':875 'dbconnect':679 'decid':293 'decis':121 'declar':725,796,878,883 'defaultport':420,631 'defaulttimeout':428 'defin':343 'depend':889 'descript':209,573 'design':544 'detail':720 'didn':820 'differ':529 'distanc':188 'element':735 'end':537 'ensur':19,395 'enum':165 'er':139,313,324,838 'errfoo':873 'error':704,861,866,872,876 'etc':712 'even':36 'exampl':737 'expens':525 'explicit':41 'export':34,169,689,744 'familiar':583 'feel':89,653,691 'fetch':523 'field':511 'filterpend':626 'flow':122 'formatt':327 'full':488,659 'func':170,374,378,748,754,761 'function':12,240,491,528,549,643 'generat':243 'generic':263,300 'get':66,179,497 'get-prefix':65 'getown':516 'getter':68,182,509 'getter/setter':545 'global':605,634 'go':2,8,47,54,110,229,275,423,617,649,700,724,795,814,830,848,865,882,903 'go-declar':723,794,881 'go-error-handl':864 'go-interfac':829 'go-nam':1 'go-packag':847 'go-style-cor':902 'good':276 'guidanc':721 'handl':867 'help':81 'helper':268 'honor':328 'http':460 'httpauth':273 'httpclient':469,473 'httputil':743 'id':459 'identifi':9,230,703,792,800,913 'idiomat':20 'implement':347 'import':295,859 'includ':533 'index':587 'initi':448,452,457,481,772 'interfac':136,305,311,319,345,826,831,835 'interop':247 'invalidinput':242 'iota':163 'item':622 'k':409 'key':559 'known':350 'languag':119 'larg':784 'larger':576,628 'len':706 'length':184,564,778,888 'letter':150,195,366,580,759 'level':207,611 'like':265,505 'line':193,646 'local':640 'longer':572 'lowercas':129,254,259,468,739,753 'maintain':453 'make':711 'maxpackets':425 'maxretri':417 'maxsiz':770 'medium':199 'method':13,137,144,159,310,318,322,330,351,373,398,493,667 'mixedcap':135,161,177,225,233,404,745,751,765 'must':231,252,357,462 'n':197 'name':3,6,22,44,48,57,71,75,86,104,111,120,126,138,212,218,249,264,271,291,304,306,315,331,354,393,400,411,435,447,484,494,506,548,552,554,566,574,595,600,639,650,686,697,718,731,788,807,827,834,845,852,862,870,887,914 'namestr':602 'never':382,405,698,766,789 'new':30,344,710 'normat':227,250,355,401,451 'noun':131,261 'oauth2':278 'one':309,317,363 'one-method':308,316 'oper':526 'option':83 'order':627 'orderid':474 'os/cgo':246 'owner':512,514 'p.name':668 'p.projectname':670 'packag':10,32,70,127,206,217,248,251,292,303,610,661,674,685,738,742,844,849,853 'package-level':205,609 'paramet':715 'parseint':538 'parseint64':539 'parseurl':471,475,749,755 'pattern':60,584,810 'pendingord':625 'phrase':175 'plus':323 'port8080':422 'predeclar':702,791 'prefer':269 'prefix':67,180,410,498,603,607 'prevent':615 'principl':85,560,900 'proport':185 'quick':733 'r':198,588 'rang':621 'read':287,332,339,387,431,476,540,635,680 'reader':145,325 'reader/writer':591 'receiv':17,74,147,353,356,392,666,756,842 'redund':692 'refer':734 'references/identifiers.md':288,289,340,341,388,389,432,433,477,478,541,542 'references/repetition.md':681,682 'references/variables.md':636,637 'relat':824 'remain':811 'renam':799,819 'repeat':98,216 'repetit':90,648,654 'requir':226 'resolv':858 'role':414,441 'role-bas':440 'rule':736 'run':78,801,813 'scan':53 'scienc':109 'scope':187,190,200,562,571,577,624,629,779,879,891 'scope-bas':561 'scream':61 'script':51 'scripts/check-naming.sh':52,80,803 'section':732 'see':722,793,828,846,863,880,901 'self':77,386 'send':381 'sentinel':871 'servic':282 'setown':519 'setter':517 'shadow':285,616,699,790,898 'short':128,201,258,359,565 'shorten':223 'shorter':115 'signatur':338,352 'simpl':500 'singl':143,194,579 'single-lett':578 'single-method':142 'singular':130,260 'size':780 'skill':825 'skill-go-naming' 'small':570,623,782 'snake':62 'source-cxuu' 'specif':270,302 'sqldb':675 'start':746,752 'string':335,705 'stringutil':272 'style':899,904 'suffix':140,314,839 'symbol':662,690 'tabl':490 'tabwrit':279 'take':93 'tend':112 'test':239 'testfoo':241 'three':419 'throughout':456 'time.second':430 'tini':189 'topic-agent-skills' 'topic-ai-agent' 'topic-ai-assistant' 'topic-claude' 'topic-claude-code' 'topic-codex' 'topic-cursor' 'topic-golang' 'topic-llm' 'two':365 'type':11,31,153,369,532,534,593,672,717,843,877 'underscor':133,234,257,741 'unexport':604,612,633,750 'uppercas':465,747 'url':458 'use':4,24,92,162,232,312,361,383,403,480,502,520,582,596,606,656,676,727 'user':27,277,281,597 'useraccountcount':210 'usercount':783 'userid':470,775 'userservic':283 'userslic':599 'util':266,855 'util/helper/common':72 'v':568,620 'valid':797 'valu':416,445 'value-bas':444 'var':286 'variabl':14,183,551,553,641,714,777,886 'variant':550 'vars/consts':613 'verb':171,174,504 'verb-lik':503 'verb-phras':173 'verifi':805 'vs':910 'w':589 'well':349 'well-known':348 'wide':208 'widget.new':663 'widget.newwidget':665 'word':202 'write':333 'writer':146,326 'xmlapi':776 'yes':222","prices":[{"id":"3e672ec9-4237-4930-bcac-2315f3e43fb7","listingId":"cf8bad32-3c24-4965-873d-938219319f23","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"cxuu","category":"golang-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T22:13:18.886Z"}],"sources":[{"listingId":"cf8bad32-3c24-4965-873d-938219319f23","source":"github","sourceId":"cxuu/golang-skills/go-naming","sourceUrl":"https://github.com/cxuu/golang-skills/tree/main/skills/go-naming","isPrimary":false,"firstSeenAt":"2026-04-18T22:13:18.886Z","lastSeenAt":"2026-05-02T12:55:18.779Z"}],"details":{"listingId":"cf8bad32-3c24-4965-873d-938219319f23","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"cxuu","slug":"go-naming","github":{"repo":"cxuu/golang-skills","stars":82,"topics":["agent-skills","ai-agent","ai-assistant","claude","claude-code","codex","cursor","go","golang","llm"],"license":"apache-2.0","html_url":"https://github.com/cxuu/golang-skills","pushed_at":"2026-03-15T19:32:10Z","description":"AI Agent Skills for idiomatic, production-ready Go code, distilled from Google, Uber, Community","skill_md_sha":"ee6255e6b403b3a7a669f135ca9d142195074453","skill_md_path":"skills/go-naming/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/cxuu/golang-skills/tree/main/skills/go-naming"},"layout":"multi","source":"github","category":"golang-skills","frontmatter":{"name":"go-naming","license":"Apache-2.0","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)."},"skills_sh_url":"https://skills.sh/cxuu/golang-skills/go-naming"},"updatedAt":"2026-05-02T12:55:18.779Z"}}