go-code-style

Guide Go code style decisions for formatting, control flow, and declarations.

8|Updated Jun 5, 2026
One-click install
npx skills add https://github.com/muratmirgun/gophers --skill go-code-style-muratmirgun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-code-style
Source: https://github.com/muratmirgun/gophers/tree/main/skills/go-code-style
Command: npx skills add https://github.com/muratmirgun/gophers --skill go-code-style-muratmirgun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you write and review Go code that is clearer, simpler, and easier to maintain by applying Go-native style decisions that go beyond what gofmt can enforce.

Core Features & Use Cases

  • Control Flow Guidance: Prefer early returns, remove unnecessary else branches, and choose switch statements when they communicate intent better than if chains.
  • Data and Function Design: Initialize slices and maps correctly, use named composite literals, choose value or pointer arguments appropriately, and keep function signatures small and readable.
  • Practical Go Review Support: Use it when reviewing production Go, refactoring nested logic, or standardizing code to match common Go community conventions.
  • Use Case: You are cleaning up a service handler with deep nesting, inconsistent declarations, and brittle struct literals; this Skill helps reshape it into idiomatic, review-friendly Go.

Quick Start

Review my Go code for style issues and rewrite it to follow idiomatic control flow, declarations, and function design.

Frequently Asked Questions about go-code-style

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

FAQPage Schema
What is idiomatic Go style beyond what gofmt enforces?

Idiomatic Go style covers formatting-adjacent decisions like early returns, switch usage, and slice initialization that gofmt cannot enforce. It guides control flow simplification, declaration choices, and function design to produce clearer, more maintainable code.

How do I refactor nested Go code with deep if-else chains?

Refactor nested Go code by preferring early returns to remove unnecessary else branches and replacing long if chains with switch statements. This flattens control flow and communicates intent more clearly to reviewers.

When should I use value versus pointer arguments in Go function signatures?

Choose value or pointer arguments based on struct size, mutation requirements, and API consistency. Value arguments prevent unintended side effects for small structs, while pointers are necessary when the function must modify the caller's variable or handle large structures efficiently.

What is the best way to initialize slices and maps in Go?

Initialize slices and maps using named composite literals and correct pre-allocation. Proper initialization prevents nil-map panics and brittle struct literals, ensuring your Go code follows community conventions for safe and readable data structure handling.

Can I use this for Go code review on production services?

Yes, you can use this for Go code review on production services. It helps standardize code to match common Go community conventions by checking early returns, switch usage, composite literals, and function signatures against lintable style rules.

Does this require gofmt-compatible source formatting?

Yes, this requires gofmt-compatible source formatting as a baseline. It operates on formatting-adjacent decisions and control flow simplification that build upon standard gofmt output, verifying your code against lintable style rules and community conventions.