writing-go

writing-go is a skill for Claude Code from julianobarbosa/claude-code-skills. It costs 48 tokens per session (791 once invoked), scanned A, original, MIT.

A guide to writing and reviewing Go 1.25 or later code in a simple, conventional style. It covers error handling, API design, types, composition, and table-driven tests.

In plain words
What is it for?
Use it when building Go services and APIs, choosing standard-library patterns, handling errors, or writing tests with multiple input cases.
Why use it?
It helps developers make consistent Go choices and avoid unnecessary dependencies or complicated designs.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it when building Go services and APIs, choosing standard-library patterns, handling errors, or writing tests with multiple input cases.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/julianobarbosa/claude-code-skills/writing-go
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add julianobarbosa/claude-code-skills --skill writing-go
Clone the repo
git clone --depth 1 https://github.com/julianobarbosa/claude-code-skills

Made for: Claude Code.

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 writing-go

README.md
[![agentmods](https://agentmods.dev/badge/skills/julianobarbosa/claude-code-skills/writing-go/github.svg)](https://agentmods.dev/skills/julianobarbosa/claude-code-skills/writing-go)
Your own site
<a href="https://agentmods.dev/skills/julianobarbosa/claude-code-skills/writing-go"><img src="https://agentmods.dev/badge/skills/julianobarbosa/claude-code-skills/writing-go/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 writing-go

Your own site · 80×15
<a href="https://agentmods.dev/skills/julianobarbosa/claude-code-skills/writing-go"><img src="https://agentmods.dev/badge/skills/julianobarbosa/claude-code-skills/writing-go.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 791 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.00048 $0.00791
Opus 5 $0.00024 $0.00396
Sonnet 5 $0.00010 $0.00158
Haiku 4.5 $0.00005 $0.00079

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

Security

Grade A, and why

writing-go 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 8d 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.

skills/writing-go/SKILL.md · 101 lines

How it starts

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

Go Development (1.25+)

Core Principles

  • Stdlib first: External deps only when justified
  • Concrete types: Define interfaces at consumer, return structs
  • Composition: Over inheritance, always
  • Fail fast: Clear errors with context
  • Simple: The obvious solution is usually correct

Quick Patterns

Error Handling

if err := doThing(); err != nil {
    return fmt.Errorf("do thing: %w", err)
}

Struct with Options

type Server struct {
    addr    string
    timeout time.Duration
}

func NewServer(addr string, opts ...Option) *Server {
    s := &Server{addr: addr, timeout: 30 * time.Second}
    for _, opt := range opts {
        opt(s)
    }
    return s
}

Table-Driven Tests

tests := []struct {
    name    string
    input   string
    want    string
    wantErr bool
}{
    {"valid", "hello", "HELLO", false},
    {"empty", "", "", true},
}
for _, tt := range tests {
    t.Run(tt.name, func(t *testing.T) {
        got, err := Process(tt.input)
        if tt.wantErr {
            require.Error(t, err)
            return
        }
        require.NoError(t, err)
        assert.Equal(t, tt.want, got)
    })
}

Go 1.25 Features

  • testing/synctest: Deterministic concurrent testing with simulated clock
  • encoding/json/v2: Experimental, 3-10x faster (GOEXPERIMENT=jsonv2)
  • runtime/trace.FlightRecorder: Production trace capture on-demand
  • Container-aware GOMAXPROCS: Auto-detects cgroup limits
  • GreenTea GC: Experimental, lower latency (GOEXPERIMENT=greenteagc)

References

Tooling

go build ./...           # Build
go test -race ./...      # Test with race detector
golangci-lint run        # Lint
mockery --all            # Generate mocks

Gotchas

  • nil channel sends/receives block forever; closed channel receives return zero value immediatelyselect with a nil channel case disables that case, useful pattern but easy to do accidentally.
  • defer captures arguments at the call site, not at executiondefer fmt.Println(time.Now()) captures NOW, not the deferred time.
  • Pre-Go 1.22 for-loop variable capture closures over ONE variable across all iterations — the goroutine-in-loop bug. Go 1.22 changed semantics; old habits create subtle bugs in mixed-version code.
  • errors.Is walks Unwrap() chains, BUT if a wrapped error implements Is(target error) bool itself, that custom Is wins over walking — confusing when migrating from xerrors.
  • sync.Pool items can be GC'd between Get and the next Put — never rely on a Pool to retain state.

Read the full file on GitHub · 101 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 8d ago First seen · 101 lines · 48 tokens per session scan A 532e80068687

Subscribe to this mod's changes

writing-go is a skill published in the GitHub repository julianobarbosa/claude-code-skills (10 stars, last pushed 16d ago), licensed MIT. It adds 48 tokens to every session and 791 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-09-03.

Related

Other skills, from other repositories

timeouts-and-async

Make Ginkgo specs interruptible and test asynchronous behavior — SpecContext/context.Context cancellable nodes, NodeTimeout/SpecTimeout/GracePeriod, the --timeout flag, Abort and SIGINT behavior, Gomega Eventually/Consistently (the func(g Gomega) form, .WithContext), and the defer GinkgoRecover() rule for goroutines.…

onsi/ginkgo · 106 tokens

setup

Wire Ginkgo into a Go package — install the ginkgo CLI and Ginkgo+Gomega, ginkgo bootstrap to generate the suitetest.go (TestXxx/RegisterFailHandler(Fail)/RunSpecs), the package xxxtest convention, dot-import alternatives (aliased import, dsl/ subpackages, --nodot), ginkgo generate, and testing.T interop via…

onsi/ginkgo · 118 tokens

golang-testing

Production-ready Golang tests — table-driven tests, testify suites and mocks, parallel tests, fuzzing, fixtures, goroutine leak detection with goleak, snapshot testing, code coverage, integration tests, idiomatic test naming. Use when writing or reviewing Go tests, choosing a testing approach, setting up Go test CI…

samber/cc-skills-golang · 115 tokens

overview

The Ginkgo mental model for writing Go tests — the one idea that explains everything (Ginkgo builds a spec tree at construction time, then runs it) and its consequences for how you write specs, plus spec independence and the node taxonomy. Use this first when you start working with Ginkgo in a project, or to decide…

onsi/ginkgo · 84 tokens

golang-stretchr-testify

Comprehensive guide to stretchr/testify for Golang testing. Covers assert, require, mock, and suite packages in depth. Use when writing tests with testify, creating mocks, setting up test suites, or choosing between assert and require. Covers testify assertions, mock expectations, argument matchers, call verification…

samber/cc-skills-golang · 97 tokens

assertions

Write correct synchronous Gomega assertions — Expect/Ω notation, the To/NotTo/ToNot/Should/ShouldNot equivalences, the multi-return error idiom, Succeed vs HaveOccurred, the .Error() chaining form, annotating assertions (format-string and func()string), tuning failure output via the format subpackage…

onsi/gomega · 145 tokens