Claude-skill-registry golang-concurrency-safety
Go concurrency safety review. Use when checking goroutines, channels, race conditions, or synchronization. Detects goroutine leaks, deadlocks, race conditions, and unsafe channel operations.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/concurrency-safety" ~/.claude/skills/majiayu000-claude-skill-registry-golang-concurrency-safety && rm -rf "$T"
manifest:
skills/data/concurrency-safety/SKILL.mdsource content
Golang Concurrency Safety
Expert-level concurrency safety review for Go applications. Detects common concurrency bugs that cause production failures, race conditions, deadlocks, and resource leaks.
When to Apply
Use this skill when:
- Reviewing code with goroutines or channels
- Debugging race conditions or deadlocks
- Auditing concurrent data access
- Investigating goroutine leaks or memory issues
- Writing new concurrent code
- Preparing concurrent code for production
Rule Categories by Priority
| Priority | Count | Focus |
|---|---|---|
| Critical | 5 | Prevents crashes, leaks, deadlocks |
| High | 4 | Correctness and reliability |
| Medium | 3 | Code quality and idioms |
Rules Covered (12 total)
Critical Issues (5)
- Goroutines must have exit conditionscritical-goroutine-leak
- Protect shared state with mutex/channelscritical-race-condition
- Ensure paired send/receive operationscritical-channel-deadlock
- Sender closes channel, not receivercritical-close-panic
- Avoid defer in loops (resource leaks)critical-defer-in-loop
High-Impact Patterns (4)
- Limit concurrent goroutines (worker pool)high-goroutine-unbounded
- Always close channels when donehigh-channel-not-closed
- Avoid closure over loop variableshigh-loop-variable-capture
- Match Add() and Done() callshigh-waitgroup-mismatch
Medium Improvements (3)
- Use send/receive-only channelsmedium-directional-channels
- Choose appropriate buffer sizemedium-buffered-channel-size
- Avoid busy-wait with selectmedium-select-default
How to Use
For Code Review
- Scan code for goroutine launches and channel operations
- Check against rules in priority order (Critical first)
- For each violation found, reference the specific rule file
- Provide exact line numbers and explanation
- Show corrected code example
Accessing Detailed Rules
Each rule file in
rules/ contains:
- Brief explanation of why it matters
- Detection criteria (how to spot the issue)
- Incorrect code example (❌ BAD)
- Correct code example (✅ GOOD)
- Impact assessment
- References
Example:
rules/critical-goroutine-leak.md rules/high-channel-not-closed.md
Trigger Phrases
This skill activates when you say:
- "Check for race conditions"
- "Review concurrency"
- "Find goroutine leaks"
- "Check for deadlocks"
- "Review channel usage"
- "Audit goroutine safety"
- "Check synchronization"
- "Review concurrent code"
Common Patterns
Goroutine leak detection:
Check this code for goroutine leaks
Race condition audit:
Verify this concurrent code is safe
Channel safety review:
Review channel usage for deadlocks
Output Format
When reviewing code, use this format:
## Critical Concurrency Issues: X ### [Rule Name] (Line Y) **Issue**: Brief description **Impact**: Race condition / Deadlock / Goroutine leak **Fix**: Suggested correction **Example**: ```go // Corrected code here
High-Impact Patterns: X
[Similar format for high priority items]
Medium Improvements: X
[Similar format for medium priority items]
## Philosophy Based on Katherine Cox-Buday's "Concurrency in Go": - **Concurrency is not parallelism** - Design for coordination, not just speed - **Channels are for communication** - Use for passing ownership - **Mutexes are for state** - Use for protecting shared memory - **Always have exit conditions** - Every goroutine must be able to stop - **Context is the standard** - Use context.Context for cancellation ## Related Skills - [golang-error-handling](../error-handling/SKILL.md) - For context propagation patterns - [golang-clean-architecture](../clean-architecture/SKILL.md) - For usecase/repository concurrency patterns ## Notes - Rules are evidence-based from authoritative Go concurrency books - All examples are tested and production-ready - Detection patterns help identify issues systematically - Focused exclusively on concurrency safety (not general Go patterns)