bobmatnyc avatar

Golang Concurrency Patterns

Teaches Claude about production-ready Go concurrency patterns with explicit goroutine lifetimes, context-based cancellation, and proper state protection. You get practical guidance on errgroup for fan-out/fan-in, bounding concurrency with semaphores, and avoiding the classic failure modes like goroutine leaks and data races. The skill is opinionated in a good way, calling out anti-patterns like fire-and-forget goroutines in handlers and time.After in hot loops. It's passed audits from Gen Agent Trust Hub, Socket, and Snyk. Useful when you're building Go services and want Claude to suggest concurrent designs that won't bite you in production.

skills.sh installs
420
GitHub stars
79
last updated
Aug 21, 2026

Install

$ npx -y skills add bobmatnyc/claude-mpm-skills --skill golang-concurrency-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

Go Concurrency Patterns (Production)

Overview

Go concurrency scales when goroutine lifetimes are explicit, cancellation is propagated with context.Context, and shared state is protected (channels or locks). Apply these patterns to build reliable services and avoid common failure modes: goroutine leaks, deadlocks, and data races.

Quick Start

Default building blocks

  • Use context to drive cancellation and deadlines.
  • Use errgroup.WithContext for fan-out/fan-in with early abort.
  • Bound concurrency (avoid unbounded goroutines) with a semaphore or worker pool.
  • Prefer immutable data; otherwise protect shared state with a mutex or make a single goroutine the owner.

Avoid

  • Fire-and-forget goroutines in request handlers.
  • time.After inside hot loops.
  • Closing channels from the receiver side.
  • Sharing mutable variables across goroutines without synchronization.

Core Concepts

Goroutine lifecycle

Treat goroutines as resources with a clear owner and shutdown condition.

✅ Correct: stop goroutines via context

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Sponsors

Details

Repository
github.com/bobmatnyc/claude-mpm-skills
Categories
Backend & APIs, Go
First seen
Jun 3, 2026

More from bobmatnyc/claude-mpm-skills

All 158
1tencentcloudbase avatarcloudbase-agent-tstencentcloudbase/skillsBuild and deploy AI agents with Cloudbase Agent (TypeScript), a TypeScript SDK implementing the AG-UI protocol. Use when: (1) deploying agent servers with @clou420skills.sh installs
2huggingface avatarhugging-face-model-trainerhuggingface/skillsThis skill should be used when users want to train or fine-tune language models using TRL (Transformer Reinforcement Learning) on Hugging Face Jobs infrastructu418skills.sh installs
3davila7 avatarworkflow-automationdavila7/claude-code-templatesWorkflow automation is the infrastructure that makes AI agents reliable. Without durable execution, a network hiccup during a 10-step payment flow means lost mo416skills.sh installs
4brightdata avatarscraper-builderbrightdata/skillsBuild production-ready web scrapers for any website using Bright Data infrastructure. Guides you through site analysis, API selection, selector extraction, pagi415skills.sh installs
5pproenca avatartddpproenca/dot-skillsTest-Driven Development methodology and red-green-refactor workflow (formerly test-tdd). This skill should be used when practicing TDD, writing tests first, des415skills.sh installs
6bobmatnyc avataropenrouterbobmatnyc/claude-mpm-skillsOpenRouter unified AI API - Access 200+ LLMs through single interface with intelligent routing, streaming, cost optimization, and model fallbacks413skills.sh installs