This skill helps you write safe, efficient Go concurrency patterns using goroutines, channels, context, and sync primitives.
npx playbooks add skill jovermier/cc-stack-marketplace --skill go-concurrency
Expert guidance for writing safe, leak-free concurrent Go code.
| Pattern | When to Use | Key Points |
|---------|-------------|------------|
| Goroutine + select | Long-running workers | Always have exit condition |
| context.WithCancel | Cancellable operations | defer cancel() |
| context.WithTimeout | Time-bound operations | Check ctx.Done() |
| sync.Mutex | Mutual exclusion | Lock/defer Unlock |
| sync.RWMutex | Read-heavy locking | Separate RLock/RUnlock |
| sync.WaitGroup | Wait for goroutines | Add before, Done after |
| errgroup.Group | Goroutines with errors | Wait collects first error |
| channel | Signaling/streaming | Close sender side |
Specify a number or describe your concurrent Go code.
| Response | Reference to Read |
|----------|-------------------|
| 1, "goroutine", "worker", "job" | [goroutines.md](./references/goroutines.md) |
| 2, "channel", "buffer", "send", "receive" | [channels.md](./references/channels.md) |
| 3, "context", "cancel", "timeout", "deadline" | [context.md](./references/context.md) |
| 4, "mutex", "lock", "race", "sync" | [sync.md](./references/sync.md) |
| 5, general concurrency | Read all references based on code |
| Pitfall | Severity | Fix |
|---------|----------|-----|
| Goroutine that never exits | Critical | Add ctx.Done() select case |
| Missing defer cancel() | High | Always defer after WithCancel/Timeout |
| Using buffered channel as mutex | High | Use sync.Mutex |
| Not propagating context | High | Add ctx parameter throughout call stack |
| Race conditions | Critical | Use proper sync or eliminate shared state |
| Unbounded goroutine creation | High | Use worker pool pattern |
| Reading from closed channel | Medium | Always check ok value from range |
| File | Topics |
|------|--------|
| [goroutines.md](./references/goroutines.md) | Lifecycle patterns, worker pools, leak prevention |
| [channels.md](./references/channels.md) | Buffered vs unbuffered, closing patterns, select |
| [context.md](./references/context.md) | Propagation, cancellation, timeouts, deadlines |
| [sync.md](./references/sync.md) | Mutex, RWMutex, WaitGroup, Once, Pool |
Code is concurrency-safe when:
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.