Agent Skill
Golang Safety skill
golang-safetysamber/cc-skills-golangskills/golang-safety/SKILL.md
Defensive Golang coding against accidental bugs — nil panics, typed-nil interfaces, `append` backing-array aliasing, silent int64-to-int32 truncation, float `==` comparison, `defer` inside loops, defensive copies of slices and maps, and usable zero values. Use when a Go program panics on a nil map write or nil pointer dereference, when reviewing code for nil-safety, numeric conversion overflow, or resource lifecycle, or when designing a type whose zero value must be safe. Not for designing concurrent access with goroutines, channels, or sync primitives (→ See `samber/cc-skills-golang@golang-concurrency` skill), not for exploitable vulnerabilities such as injection, weak crypto, or leaked secrets (→ See `samber/cc-skills-golang@golang-security` skill), and not for debugging an already-failing program (→ See `samber/cc-skills-golang@golang-troubleshooting` skill).
always on
205 tokname + description
once used
2,392 tokSKILL.md body
bundled files
359 KB
repo stars
3.6kGitHub
Install the Golang Safety skill
Skills CLI (Claude Code, Codex, Cursor and others)
npx skills add https://github.com/samber/cc-skills-golang --skill golang-safety
Claude Code, by hand (all projects)
git clone --depth 1 https://github.com/samber/cc-skills-golang.git /tmp/cc-skills-golang mkdir -p ~/.claude/skills cp -R /tmp/cc-skills-golang/skills/golang-safety ~/.claude/skills/golang-safety
For one project only, copy the folder into .claude/skills/ in that project instead. The agent picks it up when a task matches its description.
What it costs your context
Agent Skills load in three steps. Tokens counted with the o200k tokenizer; your model's count will differ a little.
| When | What loads | Cost |
|---|---|---|
| Every session | Name and description | 205 tok |
| When the agent uses it | The SKILL.md instructions | 2,392 tok |
| Only if opened | 3 bundled files (59 KB) | varies |
Until it is used, golang-safety costs about 6.6× less than the median MCP server we measured (1,363 tokens on every turn). Installing all 46 skills from samber/cc-skills-golang would load 6,483 tokens of descriptions. Skills vs MCP study
Checks
Our checks found nothing to flag: it follows the Agent Skills specification's naming and size guidelines and doesn't pipe downloads into a shell.
Pre-approved tools (allowed-tools): Read, Edit, Write, Glob, Grep, Bash(go:*), Bash(golangci-lint:*), Bash(git:*), Agent. The agent can use these without asking while the skill is active.
Checked 2026-10-22 · method
What's inside
The headings of its SKILL.md. Read the full file on GitHub.
- Go Safety: Correctness & Defensive Coding
- Best Practices Summary
- Nil Safety
- The nil interface trap
- Nil map, slice, and channel behavior
- Slice & Map Safety
- Slice aliasing — the append trap
- Map concurrent access
- Numeric Safety
- Implicit type conversions truncate silently
- Float comparison
- Division by zero
- Resource Safety
- defer in loops — resource accumulation
- Goroutine leaks
- Immutability & Defensive Copying
- Protecting struct internals
- Initialization Safety
- Zero-value design
- sync.Once for lazy initialization
- init() function pitfalls
- Enforce with Linters
- Go 1.25+ reflection type assertions
- Common Mistakes
More skills from samber/cc-skills-golang
- golang-benchmarksamber/cc-skills-golang
Golang benchmarking, profiling, and performance measurement. Use when writing, running, or comparing Go benchmarks, profiling hot paths with pprof, interpreting CPU/memory/trace profiles, analyzing results with benchstat, setting up CI benchmark regression detection, or investigating production performance with Prometheus runtime metrics. Also use when the developer needs deep analysis on a specific performance indicator - this skill provides the measurement methodology, while `samber/cc-skills-golang@golang-performance` provides the optimization patterns.
3.6k104 tok idle · 2,819 in use - golang-clisamber/cc-skills-golang
Golang CLI application development. Use when building, modifying, or reviewing a Go CLI tool — especially for command structure, flag handling, configuration layering, version embedding, exit codes, I/O patterns, signal handling, shell completion, argument validation, and CLI unit testing. Also triggers when code uses cobra, viper, or urfave/cli. For cobra-specific APIs → See `samber/cc-skills-golang@golang-spf13-cobra` skill; for viper configuration layering → See `samber/cc-skills-golang@golang-spf13-viper` skill.
3.6k12126 tok idle · 2,074 in use - golang-code-stylesamber/cc-skills-golang
Golang code style conventions — line length and breaking, variable declarations, control flow clarity, when comments help vs hurt. Use when writing or reviewing Go code, asking about style or clarity, or establishing project coding standards. Not for naming conventions (→ See `samber/cc-skills-golang@golang-naming` skill), linter configuration (→ See `samber/cc-skills-golang@golang-lint` skill), or doc comments (→ See `samber/cc-skills-golang@golang-documentation` skill).
3.6k116 tok idle · 2,105 in use - golang-concurrencysamber/cc-skills-golang
Golang concurrency design — goroutine lifecycle and leak prevention, channels and `select`, channel ownership and direction, `sync.Mutex`/`RWMutex`/`sync.Map`/`sync.Once`/atomics, `errgroup`, `singleflight`, worker pools, and fan-out/fan-in pipelines. Use when writing or reviewing concurrent Go code, when choosing between channels and mutexes, when protecting a shared map or counter, or when a goroutine has no clear exit. Not for defensive coding unrelated to concurrency such as nil panics, slice aliasing, or numeric overflow (→ See `samber/cc-skills-golang@golang-safety` skill), and not for debugging a specific hung, crashing, or racing program after the fact (→ See `samber/cc-skills-golang@golang-troubleshooting` skill).
3.6k180 tok idle · 1,984 in use - golang-contextsamber/cc-skills-golang
Idiomatic context.Context usage in Golang — propagation through API boundaries, cancellation, timeouts and deadlines, request-scoped values, context.WithoutCancel for background work outliving requests. Apply when designing context propagation across layers, debugging leaked or unexpired contexts, choosing between context.Background/TODO/WithoutCancel, or storing values in context. Not for code that merely accepts ctx as first parameter.
3.6k83 tok idle · 1,169 in use - golang-continuous-integrationsamber/cc-skills-golang
GitHub Actions CI/CD pipeline configuration for Golang projects — workflow files for test, lint, SAST, coverage and vulnerability-scan jobs, Dependabot and Renovate config files, GoReleaser release pipelines, Docker build/push, repository security settings, and AI-driven PR review. Use when setting up or improving Go project CI, writing or fixing `.github/workflows/*.yml`, adding a linter or security scanner as a pipeline job, wiring automated dependency-update bots, or adding quality gates. Covers wiring tools into a pipeline, not the analysis they perform: do NOT use for choosing or interpreting security findings (→ See `samber/cc-skills-golang@golang-security` skill) or for choosing, upgrading, or auditing dependency versions (→ See `samber/cc-skills-golang@golang-dependency-management` skill).
3.6k181 tok idle · 3,151 in use - golang-data-structuressamber/cc-skills-golang
Golang data structures — slices (internals, capacity growth, preallocation, slices package), maps (internals, hash buckets, maps package), arrays, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections, pointers (unsafe.Pointer, weak.Pointer), and copy semantics. Use when choosing or optimizing Go data structures, implementing generic containers, using container/ packages, unsafe or weak pointers, or questioning slice/map internals. Not for applying optimization patterns once profiling has identified a bottleneck (→ See `samber/cc-skills-golang@golang-performance` skill).
3.6k126 tok idle · 2,343 in use - golang-databasesamber/cc-skills-golang
Comprehensive guide for Go database access — parameterized queries, struct scanning, NULLable columns, transactions, isolation levels, SELECT FOR UPDATE, connection pool, batch processing, context propagation, and migration tooling. Use when writing, reviewing, or debugging Golang code that interacts with PostgreSQL, MariaDB, MySQL, or SQLite; for database testing; or for questions about database/sql, sqlx, or pgx. Does NOT generate database schemas or migration SQL.
3.6k98 tok idle · 2,483 in use