golang-design-patterns

golang-design-patterns is a skill for Claude Code, Codex from saifoelloh/golang-best-practices-skill. It costs 40 tokens per session (1,011 once invoked), scanned A, original, MIT.

A guide for organizing and refactoring Go code using recurring design approaches. It finds code smells such as very large functions, repeated parameter groups, magic constants, and logic placed in the wrong part of the code.

In plain words
What is it for?
Use it when refactoring legacy Go code, simplifying large functions, reducing technical debt, extracting reusable structures, and improving maintainability.
Why use it?
Complex or aging code becomes harder to understand and change safely. The guide points to specific restructuring patterns that can reduce duplication and maintenance work.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is - [golang-clean-architecture](../clean-architecture/SKILL.md) - For usecase complexity patterns.

Good fit Use it when refactoring legacy Go code, simplifying large functions, reducing technical debt, extracting reusable structures, and improving maintainability.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/saifoelloh/golang-best-practices-skill
agentmods
npx agentmods add skills/saifoelloh/golang-best-practices-skill/design-patterns

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for golang-design-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/saifoelloh/golang-best-practices-skill/design-patterns/github.svg)](https://agentmods.dev/skills/saifoelloh/golang-best-practices-skill/design-patterns)
Your own site
<a href="https://agentmods.dev/skills/saifoelloh/golang-best-practices-skill/design-patterns"><img src="https://agentmods.dev/badge/skills/saifoelloh/golang-best-practices-skill/design-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for golang-design-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/saifoelloh/golang-best-practices-skill/design-patterns"><img src="https://agentmods.dev/badge/skills/saifoelloh/golang-best-practices-skill/design-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,011 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00040 $0.01011
Opus 5 $0.00020 $0.00505
Sonnet 5 $0.00008 $0.00202
Haiku 4.5 $0.00004 $0.00101

Measured 12d ago against content hash c8915335c997, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

golang-design-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

design-patterns/SKILL.md · 152 lines

How it starts

The opening of the file, as written. The whole thing — 152 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Golang Design Patterns & Refactoring

Expert-level code refactoring and design pattern application for Go. Detects code smells, suggests refactoring strategies, and applies proven design patterns to improve maintainability.

When to Apply

Use this skill when:

  • Refactoring complex or legacy code
  • Reducing technical debt
  • Extracting reusable patterns
  • Simplifying large functions (God Objects)
  • Improving code maintainability
  • Applying Gang of Four patterns to Go

Rule Categories by Priority

Priority Count Focus
High 2 Critical refactoring needs
Medium 11 Code quality improvements

Rules Covered (13 total)

High-Impact Patterns (2)

  • high-god-object - Extract logic from 300+ line functions
  • high-extract-method - Name complex code blocks with descriptive methods

Medium Improvements (11)

  • medium-primitive-obsession - Replace primitives with value objects
  • medium-long-parameter-list - Use parameter objects for >5 params
  • medium-data-clumps - Extract repeated parameter groups
  • medium-feature-envy - Move logic closer to data
  • medium-magic-constants - Replace magic numbers with named constants
  • medium-builder-pattern - Fluent API for complex construction
  • medium-factory-constructor - Validated object creation
  • medium-introduce-parameter-object - Group related parameters
  • medium-switch-to-strategy - Replace type switches with interfaces
  • medium-middleware-decorator - Decorator pattern for http.Handler
  • medium-law-of-demeter - Reduce coupling, avoid message chains

Common Refactoring Patterns

God Object → Extracted Methods

// ❌ 500 line function
func (u *Usecase) Process() { ... }

// ✅ Extracted methods
func (u *Usecase) Process() {
    u.validate()
    u.transform()
    u.persist()
}

Primitive Obsession → Value Object

// ❌ Primitive types
func CreateUser(email string) { ... }

// ✅ Value object
type Email struct { value string }
func CreateUser(email Email) { ... }

Read the full file on GitHub · 152 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 152 lines · 40 tokens per session scan A c8915335c997

Subscribe to this mod's changes

golang-design-patterns is a skill published in the GitHub repository saifoelloh/golang-best-practices-skill (15 stars, last pushed 6mo ago), licensed MIT. It adds 40 tokens to every session and 1,011 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.