
Description
golang-safety is an agent skill from the samber cc-skills-golang collection that guides a coding agent to write defensive Go code that avoids accidental bugs in normal, non-adversarial code. The skill distinguishes safety from security: security handles attackers, while safety protects against the programmer's own mistakes, such as panics, silent data corruption and surprising behaviour. Its practical rules include preferring generics over any when the set of types is known, using comma-ok type assertions, and knowing that a typed nil pointer stored in an interface is not equal to nil. It warns that writing to a nil map panics, so maps must be initialised before use, and that append can reuse a backing array, so two slices may silently share memory. It advises returning defensive copies from exported functions, extracting loop bodies that use defer into their own functions, and checking integer conversions, since int64 values wrap silently when converted to int32. It also notes that float arithmetic is not exact, so comparisons should use an epsilon or math/big, that zero values should be useful, and that sync.Once guarantees one-time initialisation under concurrency. The skill is listed on skills.sh, where the page shows install counts, GitHub stars and security audit results, all passing. Install it with npx skills add https://github.com/samber/cc-skills-golang --skill golang-safety.…
Highlights
- Guards against nil panics and nil maps
- Typed nil interface pitfalls
- append aliasing and defensive copies
- Integer truncation and float comparison
- Useful zero values and sync.Once
- Installs from skills.sh
Ratings & Reviews
No ratings yet
Be the first to rate golang-safety.
People also visit

go-concurrency-patterns
Master Go concurrency with goroutines, channels, sync primitives, and context
golang-safety FAQ
What does this skill cover?
Defensive Go coding against accidental bugs: nil panics, typed nil interfaces, append aliasing, integer truncation and float comparisons.
How is safety different from security?
The skill says security handles attackers, and safety handles programmer mistakes in normal code.
Why does a nil map panic?
Writing to a nil map panics, so the skill says to initialise maps before use.
What is the append problem?
append may reuse the backing array, so two slices can share memory and silently overwrite each other.
How do I install it?
Run npx skills add https://github.com/samber/cc-skills-golang --skill golang-safety.
What are the security audit results?
skills.sh lists three audits: Gen Agent Trust Hub Pass, Socket Pass and Snyk Pass.
What are the best golang-safety alternatives?
Popular alternatives to golang-safety include go-concurrency-patterns, golang-code-style and golang-error-handling. See all golang-safety alternatives