golang-safety

golang-safety is a skill for Claude Code from alexastrum/skl. It costs 80 tokens per session (2,605 once invoked), scanned A, a copy of golang-safety, MIT.

A guide to writing Go code that avoids crashes, silent data changes, and other common runtime mistakes. It focuses on issues such as nil values, shared slice storage, concurrent maps, number conversions, and resource cleanup.

In plain words
What is it for?
Use it when reviewing Go code or investigating nil panics, slice aliasing, concurrent map access, unsafe number conversions, resource lifecycles, or zero-value design.
Why use it?
It helps catch assumptions that can cause panics or incorrect results even when no attacker is involved. It gives practical rules for making ordinary Go code safer.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions Claude Code; installed under .agents/ (shared by several agents); built for openclaw.

Good fit Use it when reviewing Go code or investigating nil panics, slice aliasing, concurrent map access, unsafe number conversions, resource lifecycles, or zero-value design.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/alexastrum/skl/golang-safety
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 alexastrum/skl --skill golang-safety
Clone the repo
git clone --depth 1 https://github.com/alexastrum/skl

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 golang-safety

README.md
[![agentmods](https://agentmods.dev/badge/skills/alexastrum/skl/golang-safety/github.svg)](https://agentmods.dev/skills/alexastrum/skl/golang-safety)
Your own site
<a href="https://agentmods.dev/skills/alexastrum/skl/golang-safety"><img src="https://agentmods.dev/badge/skills/alexastrum/skl/golang-safety/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-safety

Your own site · 80×15
<a href="https://agentmods.dev/skills/alexastrum/skl/golang-safety"><img src="https://agentmods.dev/badge/skills/alexastrum/skl/golang-safety.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 80 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,605 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 98% copy Near-identical to another mod 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.00080 $0.02605
Opus 5 $0.00040 $0.01303
Sonnet 5 $0.00016 $0.00521
Haiku 4.5 $0.00008 $0.00261

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

Security

Grade A, and why

golang-safety 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.

Origin

This is a copy

98% identical to golang-safety — 21 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.agents/skills/golang-safety/SKILL.md · 284 lines

How it starts

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

Persona: You are a defensive Go engineer. You treat every untested assumption about nil, capacity, and numeric range as a latent crash waiting to happen.

Go Safety: Correctness & Defensive Coding

Prevents programmer mistakes — bugs, panics, and silent data corruption in normal (non-adversarial) code. Security handles attackers; safety handles ourselves.

Best Practices Summary

  1. Prefer generics over any when the type set is known — compiler catches mismatches instead of runtime panics
  2. Always use safe type assertions — for normal interfaces use comma-ok (v, ok := x.(T)); for reflection in Go 1.25+ prefer reflect.TypeAssert[T](value) over value.Interface().(T).
  3. Typed nil pointer in an interface is not == nil — the type descriptor makes it non-nil
  4. Writing to a nil map panics — always initialize before use
  5. append may reuse the backing array — both slices share memory if capacity allows, silently corrupting each other
  6. Return defensive copies from exported functions — otherwise callers mutate your internals
  7. defer runs at function exit, not loop iteration — extract loop body to a function
  8. Integer conversions truncate silentlyint64 to int32 wraps without error
  9. Float arithmetic is not exact — use epsilon comparison or math/big
  10. Design useful zero values — nil map fields panic on first write; use lazy init
  11. Use sync.Once for lazy init — guarantees exactly-once even under concurrency

Nil Safety

Nil-related panics are the most common crash in Go.

The nil interface trap

Interfaces store (type, value). An interface is nil only when both are nil. Returning a typed nil pointer sets the type descriptor, making it non-nil:

// ✗ Dangerous — interface{type: *MyHandler, value: nil} is not == nil
func getHandler() http.Handler {
    var h *MyHandler // nil pointer
    if !enabled {
        return h // interface{type: *MyHandler, value: nil} != nil
    }
    return h
}

// ✓ Good — return nil explicitly
func getHandler() http.Handler {
    if !enabled {
        return nil // interface{type: nil, value: nil} == nil
    }
    return &MyHandler{}
}

Read the full file on GitHub · 284 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. 12d ago First seen · 284 lines · 80 tokens per session scan A 738d483e978b

Subscribe to this mod's changes

golang-safety is a skill published in the GitHub repository alexastrum/skl (11 stars, last pushed 3mo ago), licensed MIT. It adds 80 tokens to every session and 2,605 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. It is 98% identical to golang-safety, differing in 21 lines, and is treated as a copy.

Related

Other skills, from other repositories

printing-press-polish

Polish a generated CLI to pass verification and become publish-ready. Runs diagnostics (dogfood, verify, scorecard, go vet, gosec), automatically fixes all issues (verify failures, static-analysis findings, dead code, descriptions, README, MCP tool quality), reports the before/after delta, and offers to publish. Use…

mvanhorn/cli-printing-press · 125 tokens

gograph

Go repository intelligence for Claude Code. Use when reading, navigating, editing, reviewing, or refactoring a Go codebase. Exposes 64 query, analysis, and workflow capabilities through the local gograph MCP server, including bounded first-call exploration, AST-aware call graphs, blast-radius analysis, impact, and…

ozgurcd/gograph · 69 tokens

pi-loop-forensics

Diagnose pi-go agent loops and degenerate turns — "agent loop aborted", runaway thinking with no tool calls, repeated phrases. Discriminates genuine model repetition collapse from a race, a tool-parse failure, or a too-low guard, and A/B replays a seed session across providers.

dimetron/pi-go · 65 tokens

nightly-session-watch

Nightly sweep of the last 24h of pi-go sessions — anomalous runs, loop aborts, tool error rates, token waste, real prompt-token spend, and whether the observation and palace pipelines are still recording. Triages each finding to the specialist skill that diagnoses it. Use for an unattended daily health check, or on…

dimetron/pi-go · 78 tokens

amq-cli

Coordinate coding agents through AMQ. Use for agent messages, inboxes, receipts, sessions, wake delivery, cross-project routing, managed launches, or AMQ diagnostics. Use amq-spec for collaborative design; do not use this for general message queues or single-agent work.

avivsinai/agent-message-queue · 59 tokens

swift-concurrency

Diagnose data races, convert callback-based code to async/await, implement actor isolation patterns, resolve Sendable conformance issues, and guide Swift 6 migration. Use when developers mention: (1) Swift Concurrency, async/await, actors, or tasks, (2) "use Swift Concurrency" or "modern concurrency patterns", (3)…

patrickserrano/lacquer · 158 tokens