golang-patterns

golang-patterns is a skill for Claude Code, Codex from DVNghiem/FlowDeck. It costs 34 tokens per session (2,628 once invoked), scanned A, original, MIT.

A guide to common, idiomatic patterns for Go, the programming language. It covers errors, interfaces, goroutines, channels, testing, modules, and common mistakes.

In plain words
What is it for?
Writing or reviewing Go packages and services, designing concurrent pipelines, investigating goroutine leaks or race conditions, and configuring Go modules.
Why use it?
It helps developers write Go code that follows the language's usual conventions and avoid problems in error handling or concurrent code.

Skill for Claude CodeCodex

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

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is ./cmd/api.

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/DVNghiem/FlowDeck
agentmods
npx agentmods add skills/dvnghiem/flowdeck/golang-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-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/dvnghiem/flowdeck/golang-patterns.svg)](https://agentmods.dev/skills/dvnghiem/flowdeck/golang-patterns)
Your own site
<a href="https://agentmods.dev/skills/dvnghiem/flowdeck/golang-patterns"><img src="https://agentmods.dev/badge/skills/dvnghiem/flowdeck/golang-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,628 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00034 $0.02628
Opus 5 $0.00017 $0.01314
Sonnet 5 $0.00007 $0.00526
Haiku 4.5 $0.00003 $0.00263

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

Security

Grade A, and why

golang-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 6d 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.

src/skills/golang-patterns/SKILL.md · 512 lines

How it starts

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

Go Patterns Skill

Idiomatic Go for production systems. Focuses on simplicity, explicitness, and composition.

When to Activate

Activate when:

  • Writing new Go packages or services
  • Reviewing Go code for idiom and correctness
  • Designing concurrent processing pipelines
  • Debugging goroutine leaks or race conditions
  • Setting up module structure or build configuration

Error Handling

Go errors are values. Handle them at the point where you have enough context to act.

Wrapping and Unwrapping

import "errors"
import "fmt"

// Wrap with %w to preserve the chain
func loadConfig(path string) (*Config, error) {
    data, err := os.ReadFile(path)
    if err != nil {
        return nil, fmt.Errorf("loadConfig %q: %w", path, err)
    }
    // ...
}

// Inspect with errors.Is (sentinel) and errors.As (type)
var ErrNotFound = errors.New("not found")

if err := loadConfig("app.yaml"); err != nil {
    if errors.Is(err, os.ErrNotExist) {
        // file missing
    }
    var pathErr *os.PathError
    if errors.As(err, &pathErr) {
        log.Printf("path problem: %s", pathErr.Path)
    }
}

Sentinel Errors

// Define at package level, exported when callers need to check
var (
    ErrNotFound   = errors.New("not found")
    ErrPermission = errors.New("permission denied")
)

// Prefer typed errors when you need to attach data
type ValidationError struct {
    Field   string
    Message string
}

func (e *ValidationError) Error() string {
    return fmt.Sprintf("validation: %s %s", e.Field, e.Message)
}

Error String Conventions

// ✅ lowercase, no trailing punctuation
errors.New("connection refused")
fmt.Errorf("user %d not found", id)

// ❌ uppercase or punctuation
errors.New("Connection refused.")

Interface Design

Keep interfaces small. A one-method interface is a feature, not a limitation.

The io.Reader / io.Writer Pattern

// Standard library interfaces — use them where they fit
type Reader interface {
    Read(p []byte) (n int, err error)
}

type Writer interface {
    Write(p []byte) (n int, err error)
}

// Compose for more complex contracts
type ReadWriter interface {
    Reader
    Writer
}

// Accept interfaces, return concrete types
func Process(r io.Reader) ([]byte, error) {
    return io.ReadAll(r)
}

// os.File, bytes.Buffer, http.Response.Body all satisfy io.Reader

Read the full file on GitHub · 512 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. 6d ago First seen · 512 lines · 34 tokens per session scan A b4c097b77739

Subscribe to this mod's changes

golang-patterns is a skill published in the GitHub repository DVNghiem/FlowDeck (24 stars, last pushed 17d ago), licensed MIT. It adds 34 tokens to every session and 2,628 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.