golang-concurrency
Write safe concurrent Go code with goroutines, channels, and context. Use when implementing concurrency with goroutines, channels, or context in Go. (triggers: goroutine, go keyword, channel, mutex, waitgroup, context, errgroup, race condition)
Best use case
golang-concurrency is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Write safe concurrent Go code with goroutines, channels, and context. Use when implementing concurrency with goroutines, channels, or context in Go. (triggers: goroutine, go keyword, channel, mutex, waitgroup, context, errgroup, race condition)
Teams using golang-concurrency should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/golang-concurrency/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How golang-concurrency Compares
| Feature / Agent | golang-concurrency | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Write safe concurrent Go code with goroutines, channels, and context. Use when implementing concurrency with goroutines, channels, or context in Go. (triggers: goroutine, go keyword, channel, mutex, waitgroup, context, errgroup, race condition)
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Golang Concurrency ## **Priority: P0 (CRITICAL)** ## Principles - **Share Memory by Communicating**: Use channels instead of shared memory. - **Context is King**: Always pass `ctx` to manage cancellation/timeouts. - **Prevent Leaks**: Never start a goroutine without knowing how it will stop. - **Race Detection**: Always run tests with `go test -race`. ## Implementation Workflow 1. **Choose primitive** — Channels for data passing, `sync.Mutex` for simple state protection, `errgroup` for parallel tasks with error handling. 2. **Pass context** — Every goroutine that does I/O or long work must accept `context.Context`. 3. **Define exit paths** — Every goroutine must have a clear shutdown mechanism (context cancellation, channel close, or WaitGroup). 4. **Use select for multiplexing** — Handle multiple channels or timeouts with `select`. 5. **Test with race detector** — Run `go test -race` in CI. See [ErrGroup and concurrency patterns](references/concurrency-patterns.md) and [context timeout examples](references/context-usage.md) ## Anti-Patterns - **No goroutine leaks**: Every goroutine must have a known exit path. - **No shared global state**: Use channels or sync primitives across goroutines. - **No bare goroutines**: Use `errgroup` or `WaitGroup` for lifecycle management. ## References - [Concurrency Patterns](references/concurrency-patterns.md) - [Context Usage](references/context-usage.md)
Related Skills
swift-concurrency
Implement async/await, Actors, and structured concurrency in Swift. Use when implementing Swift async/await, Actors, or structured concurrency in iOS/macOS. (triggers: **/*.swift, async, await, actor, Task, MainActor)
php-concurrency
Implement concurrency and non-blocking I/O in modern PHP. Use when implementing concurrent requests, async processing, or non-blocking I/O in PHP. (triggers: **/*.php, Fiber, suspend, resume, non-blocking, async)
java-concurrency
Implement modern concurrency with Virtual Threads and Structured Concurrency in Java. Use when implementing Java Virtual Threads (Java 21), Structured Concurrency with StructuredTaskScope, CompletableFuture pipelines, or debugging race conditions. (triggers: **/*.java, Thread, Executor, synchronized, lock, CompletableFuture, StructuredTaskScope, VirtualThread, AtomicInteger, async, race condition)
golang-tooling
Go developer toolchain — gopls LSP diagnostics, linting, formatting, and vet. Use when setting up Go tooling, running linters, or integrating gopls with Claude Code. (triggers: gopls, golangci-lint, golangci.yml, go vet, goimports, staticcheck, go tooling, go lint)
golang-testing
Write unit tests with table-driven patterns and interface mocking in Go. Use when writing Go unit tests, table-driven tests, or using mock interfaces. (triggers: **/*_test.go, testing, unit tests, go test, mocking, testify)
golang-security
Secure Go backend services against common vulnerabilities. Use when implementing input validation, crypto, or SQL injection prevention in Go. (triggers: crypto/rand, argon2, sanitize, jwt, bcrypt, validation, input validation, sql injection)
golang-logging
Standards for structured logging and observability in Golang. Use when adding structured logging or tracing to Go services. (triggers: go.mod, pkg/logger/**, logging, slog, structured logging, zap)
golang-language
Core idioms, style guides, and best practices for writing idiomatic Go code. Use when writing Go code following official style guides and idiomatic patterns. (triggers: go.mod, golang, go code, idiomatic, gofmt, goimports, iota, golang style)
golang-error-handling
Standards for error wrapping, checking, and definition in Golang. Use when wrapping errors, defining sentinel errors, or handling errors idiomatically in Go. (triggers: fmt.Errorf, errors.Is, errors.As, error wrapping, sentinel error, error handling)
golang-database
Implement database access with connection pooling and repository patterns in Go. Use when building database access, connection pools, or repositories in Go. (triggers: internal/adapter/repository/**, database, sql, postgres, gorm, sqlc, pgx)
golang-configuration
Load and validate application configuration from environment variables and config files. Use when managing Go application config with environment variables or viper. (triggers: configs/**, cmd/**, configuration, env var, viper, koanf)
golang-architecture
Structure Go projects with Clean Architecture and standard layout conventions. Use when structuring Go projects or applying Clean Architecture in Go. (triggers: go.mod, internal/**, architecture, structure, folder layout, clean arch, dependency injection)