write-go-code

Writes and refactors Go 1.27 code against language-level conventions for functions, types, naming, and tooling.

Updated Sep 14, 2026
One-click install
npx skills add https://github.com/nakamori-naoya/go-convention-plugins --skill write-go-code-nakamori-naoya
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: write-go-code
Source: https://github.com/nakamori-naoya/go-convention-plugins/tree/main/plugins/go-convention/skills/write-go-code
Command: npx skills add https://github.com/nakamori-naoya/go-convention-plugins --skill write-go-code-nakamori-naoya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Go codebases drift into inconsistent function signatures, naming, error handling, and library usage across layers. This Skill applies one fixed set of Go 1.27 language-level conventions (max two return values, no naked returns, ctx as first argument, value semantics by default, small consumer-defined interfaces, sealed enums, no init, no silent fallbacks) so every layer of a DDD codebase shares the same code shape. ## Core Features & Use Cases - Convention enforcement: Normalizes function signatures, receiver styles, guard clauses, naming (no Get prefixes, no util packages, ID/URL acronyms), and type design (sealed structs for enums, sealed interfaces for sum types, generics only when justified). - Go 1.27 stdlib modernization: Replaces legacy idioms with min/max/clear, range-over-int, slices/maps/iter, strings.Lines/CutLast, math/rand/v2, os.Root, WaitGroup.Go, errgroup, synctest, encoding/json/v2, and errors.AsType. - Toolchain verification: Configures go.mod tool directives, gofmt, goimports, go vet with stdversion, golangci-lint v2 (nakedret, noctx, errorlint, forbidigo, depguard, gochecksumtype, exhaustive), go fix modernizers, and go test -race -shuffle=on -count=1. - Use Case: Given a Go service with inconsistent error handling and old APIs, ask the agent to bring it in line with the conventions; it will rewrite signatures, remove fallbacks and default-value rounding, adopt 1.27 idioms, and stop to ask before adding dependencies or writing fallbacks. ## Quick Start Bring this Go package in line with the Go 1.27 conventions and run gofmt, go vet, golangci-lint, and the race-enabled tests to confirm.

Frequently Asked Questions about write-go-code

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

FAQPage Schema
How do I enforce Go coding conventions across a project?▼

Apply a fixed rule set covering function signatures, naming, and types, then verify mechanically with gofmt, goimports, go vet, and golangci-lint v2. This Skill normalizes code against those rules and runs all five checks before reporting.

How to modernize Go code to Go 1.27 idioms?▼

Run go fix ./... first to let modernizers rewrite old patterns, then manually replace remaining cases: sort.Slice with slices.SortFunc, math/rand v1 with math/rand/v2, encoding/json v1 with encoding/json/v2, and errors.As with errors.AsType.

What golangci-lint linters should a Go project enable?▼

The recommended set is govet with copylocks, staticcheck, errcheck, unused, exhaustive, gochecksumtype, forbidigo, depguard, nakedret, noctx, and errorlint. Configure them in a single .golangci.yml at the repository root with version "2".

Does this convention set work with Go versions below 1.27?▼

No. The conventions target Go 1.27 only and use features like generic methods, encoding/json/v2, and strings.CutLast. If go.mod is below go 1.27 and cannot be upgraded, the Skill stops rather than writing downgrade-compatible code.

When should interfaces be defined in Go packages?▼

Define interfaces in the consuming package with only the methods it calls, and return concrete structs from implementations. The two exceptions are persistence ports and sum types, which the domain package defines.

Why does the Skill refuse to write fallback logic?▼

Fallbacks hide failures by continuing through an alternate path, delaying discovery. The Skill stops and asks the user to approve any fallback with its trigger condition and trade-offs; without approval it returns an error instead.