go-code-style

Enforces idiomatic Go naming, struct and interface design, and design patterns in code.

1|2|Updated Nov 25, 2017
One-click install
npx skills add https://github.com/asarchami/dotfiles --skill go-code-style-asarchami
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-code-style
Source: https://github.com/asarchami/dotfiles/tree/main/dot_claude/skills/go-code-style
Command: npx skills add https://github.com/asarchami/dotfiles --skill go-code-style-asarchami

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Go developers often write code that compiles but violates community conventions — stuttering names, premature interfaces, ALL_CAPS constants, or missing graceful shutdown — leading to inconsistent codebases and painful code reviews. This Skill provides a comprehensive, opinionated rulebook for Go style, naming, type design, and idiomatic patterns so AI-assisted code generation and review follow established Go proverbs and standard library conventions. ## Core Features & Use Cases - Naming Conventions: Covers packages, files, constructors, getters/setters, booleans, acronyms, constants, enums, errors, receivers, and test names, with quick-reference tables and common-mistake fixes. - Struct & Interface Design: Guides small interfaces, consumer-side interface definitions, pointer vs value receivers, embedding, type assertions, struct field tags, and compile-time interface checks. - Design Patterns & Idioms: Covers functional options, avoiding init(), enum zero-value sentinels, resource management, graceful shutdown with signal.NotifyContext, and architecture patterns (DDD, Clean, Hexagonal) via reference files. - Use Case: When writing a new Go HTTP service, ask the AI to design the API — it will apply functional options constructors, consumer-defined interfaces, early-return error flow, and proper MixedCaps naming automatically. ## Quick Start Ask the AI to review your Go file or design a new package API following idiomatic Go style and naming conventions.

Frequently Asked Questions about go-code-style

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I name constructors and getters in Go?

Use New() when a package exports a single primary type, or NewTypeName() when multiple types exist. Getters omit the Get prefix — user.Name() not user.GetName() — while boolean predicates keep Is/Has/Can prefixes like IsHealthy().

When should I use functional options vs a builder pattern in Go?

Constructors should use functional options (WithPort, WithLogger) because they scale better as APIs evolve without breaking changes. Reserve the builder pattern only for cases needing complex validation between configuration steps.

Should Go interfaces be defined where they are implemented or consumed?

Interfaces must be defined where they are consumed, not where implemented. This keeps the consumer in control of the contract, avoids importing packages just for interfaces, and interfaces should stay small at 1-3 methods.

Does this skill work with Go linters like golangci-lint?

Yes, it complements linters rather than replacing them. Linters handle raw formatting while this skill covers judgment-based concerns like naming stutter, premature interfaces, architecture choices, and resource lifecycle patterns.

When should I choose pointer vs value receivers in Go?

Use pointer receivers when the method mutates the receiver, the struct contains a sync.Mutex, or the struct is large. Use value receivers for small immutable types, and keep the receiver type consistent across all methods of a type.

Why should Go enums avoid starting at iota 0 with a real value?

A var s Status silently becomes 0, so if 0 maps to a real state like StatusReady, uninitialized values look deliberate. Place an explicit Unknown sentinel at iota 0 or start at iota + 1 to catch uninitialized enums.