way-go-style

Guide for writing idiomatic, effective, and standard Go code. Use this skill when writing, refactoring, or reviewing Go code to ensure adherence to established conventions and best practices.

8 stars

Best use case

way-go-style is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Guide for writing idiomatic, effective, and standard Go code. Use this skill when writing, refactoring, or reviewing Go code to ensure adherence to established conventions and best practices.

Teams using way-go-style should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/way-go-style/SKILL.md --create-dirs "https://raw.githubusercontent.com/way-platform/tachograph-go/main/.agents/skills/way-go-style/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/way-go-style/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How way-go-style Compares

Feature / Agentway-go-styleStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Guide for writing idiomatic, effective, and standard Go code. Use this skill when writing, refactoring, or reviewing Go code to ensure adherence to established conventions and best practices.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Way Go Style

## Project Setup (AGENTS.md)

Go projects MUST include this skill's **Way Specific Conventions** in their `AGENTS.md` file to ensure compliance.

1.  **Reference this skill**: Under "Local Skills".
2.  **Copy Conventions**: Copy the **Way Specific Conventions** section below into `AGENTS.md` under "Key Conventions".

## Way Specific Conventions

- **Testing**: Use standard `testing` and `github.com/google/go-cmp/cmp` **only**. No frameworks (Testify, Ginkgo, etc.).
- **Linting**: Run `GolangCI-Lint` v2. Configure via project-specific `.golangci.yml`.
- **Build**: Use `way-magefile` skill.
- **Encore**: Use `encore-go-*` skills. Encore conventions (e.g., globals) take precedence.

## Overview

This skill provides a condensed reference for writing high-quality Go code, synthesizing advice from "Effective Go", Google's "Code Review Comments", and other authoritative sources. It focuses on idiomatic usage, correctness, and maintainability.

## Effective Go Idioms

Critical idioms from [Effective Go](references/effective_go.html).

### Control Flow & Error Handling
- **Defer Evaluation:** Arguments to deferred functions are evaluated **immediately** at the call site (not at execution).
- **Init Scope:** Use `if err := f(); err != nil` to restrict variable scope.
- **Switch:** Use tagless `switch { case condition: ... }` instead of long `if-else` chains.
- **Internal Panic/Recover:** Use `panic` to simplify deep error handling in complex internal code (e.g., parsers), but **always** `recover` at the package boundary to return a standard `error`.

### Types & Interfaces
- **Functional Adapters:** Define methods on function types (e.g., `type MyFunc func()`) to satisfy interfaces. See `http.HandlerFunc`.
- **Interface Verification:** Use a global blank assignment to ensure a type satisfies an interface at compile time: `var _ Interface = (*Type)(nil)`.

## Google Style Decisions & Best Practices

Key decisions from the [Google Go Style Guide](references/google/index.md) and [Code Review Comments](references/CodeReviewComments.md).

### Core Principles
- **Clarity:** "Clear to the reader" is priority #1. Explain *why*, not just *what*.
- **Simplicity:** "Least Mechanism". Prefer core constructs (slices, maps) over complex abstractions.
- **Concision:** High signal-to-noise ratio. Avoid boilerplate.

### Naming & Structure
- **Packages:** Single-word, lowercase (e.g., `task`, not `task_manager`). **Avoid** `util`, `common`.
- **Receivers:** 1-2 letter abbreviations (e.g., `c` for `Client`). **NEVER** use `me`, `this`, `self`.
- **Constants:** Always `MixedCaps` (e.g., `MaxLength`), even if exported. **NEVER** `MAX_LENGTH`.
- **Getters:** `Owner()` (not `GetOwner`).
- **Interfaces:** One-method interfaces -> `Method` + `-er` (e.g., `Reader`). Define in the **consumer** package. Keep them small.

### Functions & Methods
- **Receiver Type:**
  - **Pointer (`*T`):** If mutating, contains `sync.Mutex`, or large struct.
  - **Value (`T`):** Maps, channels, functions, small immutable structs.
  - **Consistency:** Prefer all pointers or all values for a type's methods.
- **Pass Values:** Don't pass pointers to small types (`*string`, `*int`) just to save memory.
- **Synchronous:** Prefer synchronous APIs. Let the caller decide to use goroutines.
- **Must Functions:** `MustXYZ` panic on failure. Use **only** for package-level init or test helpers.

### Error Handling
- **Flow:** Handle errors immediately (`if err != nil { return err }`). Keep "happy path" unindented. Avoid `else`.
- **Structure:** Use `%w` with `fmt.Errorf` to wrap errors for programmatic inspection (`errors.Is`).
- **Panics:** **Never** panic in libraries. Return errors. `log.Fatal` is okay in `main`.
- **Strings:** Lowercase, no punctuation (e.g., `fmt.Errorf("something bad")`) for easy embedding.

### Concurrency
- **Lifetimes:** Never start a goroutine without knowing how it stops.
- **Context:** Always first arg `ctx context.Context`. **Never** store in structs.
- **Copying:** **Do not copy** structs with `sync.Mutex` or `bytes.Buffer`.

### Testing
- **Framework:** Use `testing` package. No assertion libraries (use `cmp` for diffs).
- **Helpers:** Mark setup/teardown functions with `t.Helper()`.
- **Failure Messages:** `YourFunc(%v) = %v, want %v`. (Got before Want).
- **Table-Driven:** Use field names in struct literals for clarity.
- **Subtests:** Use `t.Run()` for clear scope and filtering. Avoid slashes in names.

### Global State & Init
- **Avoid Globals:** Libraries should not rely on package-level vars. Allow clients to instantiate (`New()`).
- **Initialization:** Use `:=` for non-zero values. Use `var t []T` (nil) for empty slices.
- **Imports:** Group order: Stdlib, Project/Vendor, Side-effects (`_`). No `.` imports.

## Practical Go Cheat Sheet

Best practices for maintainable Go from **Dave Cheney's** [Practical Go](references/dave-cheney-practical-go.md).

### Guiding Principles
- **Simplicity, Readability, Productivity:** The core values. Clarity > Brevity.
- **Identifiers:** Choose for clarity. Length proportional to scope/lifespan. Don't include type in name (e.g., `usersMap` -> `users`).

### Design & Structure
- **Package Names:** Name for what it *provides* (e.g., `http`), not what it contains. Avoid `util`, `common`.
- **Project Structure:** Prefer fewer, larger packages. Arrange files by import dependency.
- **API Design:** Hard to misuse. Avoid multiple params of same type. Avoid `nil` params.
- **Interfaces:** Let functions define behavior they require (e.g., take `io.Writer` not `*os.File`).
- **Zero Value:** Make structs useful without explicit initialization (e.g., `sync.Mutex`, `bytes.Buffer`).

### Concurrency & Errors
- **Concurrency:** Leave it to the caller. Never start a goroutine without knowing when/how it stops.
- **Errors:** Eliminate error handling by eliminating errors (e.g., `bufio.Scanner`). Handle errors once (don't log AND return).
- **Return Early:** Use guard clauses. Keep the "happy path" left-aligned.

## Available References

Detailed documentation available in the `references/` directory:

- **[Effective Go](references/effective_go.html):** (HTML) The foundational guide to idiomatic Go.
- **[Code Review Comments](references/CodeReviewComments.md):** Common comments made during Go code reviews at Google.
- **[Google Style Guide](references/google/index.md):** Complete set of Google's Go style documents.
  - [Guide](references/google/guide.md): Core guidelines.
  - [Decisions](references/google/decisions.md): Normative style decisions.
  - [Best Practices](references/google/best-practices.md): Evolving guidance.
- **[Practical Go](references/dave-cheney-practical-go.md):** **Dave Cheney's** advice on writing maintainable Go programs.

Related Skills

way-magefile

8
from way-platform/tachograph-go

Build tool for Go projects. Use when the user wants to create, edit, or understand Way-specific Magefiles, build targets, or automate Go project tasks.

tachograph

8
from way-platform/tachograph-go

specialized knowledge for parsing/marshalling EU tachograph files. Use when needing to understand the .DDD/.V1B file format, TLV/TV protocols, ASN.1 mappings, or EU regulation compliance.

skill-creator

8
from way-platform/tachograph-go

Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.

protobuf

8
from way-platform/tachograph-go

Use when working with Protocol Buffer (.proto) files, buf.yaml, buf.gen.yaml, or buf.lock. Covers proto design, buf CLI, gRPC/Connect services, protovalidate constraints, schema evolution, and troubleshooting lint/breaking errors.

claude-md-improver

8
from way-platform/tachograph-go

Audit and improve CLAUDE.md files in repositories. Use when user asks to check, audit, update, improve, or fix CLAUDE.md files. Scans for all CLAUDE.md files, evaluates quality against templates, outputs quality report, then makes targeted updates. Also use when the user mentions "CLAUDE.md maintenance" or "project memory optimization".

asn1

8
from way-platform/tachograph-go

Reference for ASN.1 notation, BER (Basic Encoding Rules), and DER (Distinguished Encoding Rules). Use when decoding/encoding binary data, debugging ASN.1 structures, or understanding PKCS standards.

gan-style-harness

144923
from affaan-m/everything-claude-code

GAN-inspired Generator-Evaluator agent harness for building high-quality applications autonomously. Based on Anthropic's March 2026 harness design paper.

every-style-editor

13089
from EveryInc/compound-engineering-plugin

This skill should be used when reviewing or editing copy to ensure adherence to Every's style guide. It provides a systematic line-by-line review process for grammar, punctuation, mechanics, and style guide compliance.

dhh-rails-style

13089
from EveryInc/compound-engineering-plugin

This skill should be used when writing Ruby and Rails code in DHH's distinctive 37signals style. It applies when writing Ruby code, Rails applications, creating models, controllers, or any Ruby file. Triggers on Ruby/Rails code generation, refactoring requests, code review, or when the user mentions DHH, 37signals, Basecamp, HEY, or Campfire style. Embodies REST purity, fat models, thin controllers, Current attributes, Hotwire patterns, and the "clarity over cleverness" philosophy.

design-style-skill

9532
from MiniMax-AI/skills

Select a consistent visual design system for PPT slides using radius/spacing style recipes. Use when users ask for overall style direction or component styling consistency. Includes Sharp/Soft/Rounded/Pill recipes, component mappings, typography/spacing rules, and mixing guidance. Triggers: 风格, style, radius, spacing, 圆角, 间距, PPT风格, 视觉风格, design style, component style.

detecting-stuxnet-style-attacks

4032
from mukul975/Anthropic-Cybersecurity-Skills

This skill covers detecting sophisticated cyber-physical attacks that follow the Stuxnet attack pattern of modifying PLC logic while spoofing sensor readings to hide the manipulation from operators. It addresses PLC logic integrity monitoring, physics-based process anomaly detection, engineering workstation compromise indicators, USB-borne attack vectors, and multi-stage attack chain detection spanning IT-to-OT lateral movement through to process manipulation.

code-style

3940
from latitude-dev/latitude-llm

Biome formatting, import style, strict TypeScript, naming (including React file names), or generated files.