go-concurrency▌
cxuu/golang-skills · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
Normative: When you spawn goroutines, make it clear when or whether they
- ›exit.
Go Concurrency
Goroutine Lifetimes
Normative: When you spawn goroutines, make it clear when or whether they exit.
Goroutines can leak by blocking on channel sends/receives. The GC will not terminate a blocked goroutine even if no other goroutine holds a reference to the channel. Even non-leaking in-flight goroutines cause panics (send on closed channel), data races, memory issues, and resource leaks.
Core Rules
- Every goroutine needs a stop mechanism — a predictable end time, a cancellation signal, or both
- Code must be able to wait for the goroutine to finish
- No goroutines in
init()— expose lifecycle methods (Close,Stop,Shutdown) instead - Keep synchronization scoped — constrain to function scope, factor logic into synchronous functions
// Good: Clear lifetime with WaitGroup
var wg sync.WaitGroup
for item := range queue {
wg.Add(1)
go func() { defer wg.Done(); process(ctx, item) }()
}
wg.Wait()
// Bad: No way to stop or wait
go func() { for { flush(); time.Sleep(delay) } }()
Test for leaks with go.uber.org/goleak.
Principle: Never start a goroutine without knowing how it will stop.
Read references/GOROUTINE-PATTERNS.md when implementing stop/done channel patterns, goroutine waiting strategies, or lifecycle-managed workers.
Share by Communicating
"Do not communicate by sharing memory; instead, share memory by communicating."
This is Go's foundational concurrency design principle. Use channels for ownership transfer and orchestration — when one goroutine produces a value and another consumes it. Use mutexes when multiple goroutines access shared state and channels would add unnecessary complexity.
Default to channels. Fall back to sync.Mutex / sync.RWMutex when the
problem is naturally about protecting a shared data structure (e.g., a cache or
counter) rather than passing data between goroutines.
Synchronous Functions
Normative: Prefer synchronous functions over asynchronous ones.
| Benefit | Why |
|---|---|
| Localized goroutines | Lifetimes easier to reason about |
| Avoids leaks and races | Easier to prevent resource leaks and data races |
| Easier to test | Check input/output without polling |
| Caller flexibility | Caller adds concurrency when needed |
Advisory: It is quite difficult (sometimes impossible) to remove unnecessary concurrency at the caller side. Let the caller add concurrency when needed.
Read references/GOROUTINE-PATTERNS.md when writing synchronous-first APIs that callers may wrap in goroutines.
Zero-value Mutexes
The zero-value of sync.Mutex and sync.RWMutex is valid — almost never need
a pointer to a mutex.
// Good: Zero-value is valid // Bad: Unnecessary pointer
var mu sync.Mutex mu := new(sync.Mutex)
Don't embed mutexes — use a named mu field to keep Lock/Unlock as
implementation details, not exported API.
Read references/SYNC-PRIMITIVES.md when implementing mutex-protected structs or deciding how to structure mutex fields.
Channel Direction
Normative: Specify channel direction where possible.
Direction prevents errors (compiler catches closing a receive-only channel), conveys ownership, and is self-documenting.
func produce(out chan<- int) { /* send-only */ }
func consume(in <-chan int) { /* receive-only */ }
func transform(in <-chan int, out chan<- int) { /* both */ }
Channel Size: One or None
Channels should have size zero (unbuffered) or one. Any other size requires justification for:
- How the size was determined
- What prevents the channel from filling under load
- What happens when writers block
c := make(chan int) // unbuffered — Good
c := make(chan int, 1) // size one — Good
c := make(chan int, 64) // arbitrary — needs justification
Read references/SYNC-PRIMITIVES.md when reviewing detailed channel direction examples with error-prone patterns.
Atomic Operations
Use atomic.Bool, atomic.Int64, etc. (stdlib sync/atomic since Go 1.19, or
go.uber.org/atomic) for type-safe
atomic operations. Raw int32/int64 fields make it easy to forget atomic
access on some code paths.
// Good: Type-safe // Bad: Easy to forget
var running atomic.Bool var running int32 // atomic
running.Store(true) atomic.StoreInt32(&running, 1)
running.Load() running == 1 // race!
Read references/SYNC-PRIMITIVES.md when choosing between sync/atomic and go.uber.org/atomic, or implementing atomic state flags in structs.
Documenting Concurrency
Advisory: Document thread-safety when it's not obvious from the operation type.
Go users assume read-only operations are safe for concurrent use, and mutating operations are not. Document concurrency when:
- Read vs mutating is unclear — e.g., a
Lookupthat mutates LRU state - API provides synchronization — e.g., thread-safe clients
- Interface has concurrency requirements — document in type definition
Context Usage
For context.Context guidance (parameter placement, struct storage, custom types, derivation patterns), see the dedicated go-context skill.
Buffer Pooling with Channels
Use a buffered channel as a free list to reuse allocated buffers. This "leaky
buffer" pattern uses select with default for non-blocking operations.
Read references/BUFFER-POOLING.md when implementing a worker pool with reusable buffers or choosing between channel-based pools and
sync.Pool.
Advanced Patterns
Read references/ADVANCED-PATTERNS.md when implementing request-response multiplexing with channels of channels, or CPU-bound parallel computation across cores.
Related Skills
- Context propagation: See go-context when passing cancellation, deadlines, or request-scoped values through goroutines
- Error handling: See go-error-handling when propagating errors from goroutines or using errgroup
- Defensive hardening: See go-defensive when protecting shared state at API boundaries or using defer for cleanup
- Interface design: See go-interfaces when choosing receiver types for types with sync primitives
External Resources
- Never start a goroutine without knowing how it will stop — Dave Cheney
- Rethinking Classical Concurrency Patterns — Bryan Mills (GopherCon 2018)
- When Go programs end — Go Time podcast
- go.uber.org/goleak — Goroutine leak detector for testing
- go.uber.org/atomic — Type-safe atomic operations
How to use go-concurrency on Cursor
AI-first code editor with Composer
Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add go-concurrency
Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
The skills CLI fetches go-concurrency from GitHub repository cxuu/golang-skills and configures it for Cursor.
Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
Verify installation
Confirm successful installation by checking the skill directory location:
Reload or restart Cursor to activate go-concurrency. Access the skill through slash commands (e.g., /go-concurrency) or your agent's skill management interface.
Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
List & Monetize Your Skill
Submit your Claude Code skill and start earning
Use Cases▌
Task Automation & Efficiency
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Knowledge Enhancement
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Quality Improvement
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client with skill support
- ›Clear understanding of task or problem to solve
- ›Willingness to iterate and refine outputs
Time Estimate
15-45 minutes depending on use case complexity
Installation Steps
- 1.Install skill using provided installation command
- 2.Test with simple use case relevant to your work
- 3.Evaluate output quality and relevance
- 4.Iterate on prompts to improve results
- 5.Integrate into regular workflow if valuable
Common Pitfalls
- ⚠Expecting perfect results without iteration
- ⚠Not providing enough context in prompts
- ⚠Using skill for tasks outside its intended scope
- ⚠Accepting outputs without review and validation
Best Practices▌
✓ Do
- +Start with clear, specific prompts
- +Provide relevant context and constraints
- +Review and refine all outputs before using
- +Iterate to improve output quality
- +Document successful prompt patterns
✗ Don't
- −Don't use without understanding skill limitations
- −Don't skip validation of outputs
- −Don't share sensitive information in prompts
- −Don't expect skill to replace human judgment
💡 Pro Tips
- ★Be specific about desired format and style
- ★Ask for multiple options to choose from
- ★Request explanations to understand reasoning
- ★Combine AI efficiency with human expertise
When to Use This▌
✓ Use When
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid When
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
Learning Path▌
- 1Familiarize yourself with skill capabilities and limitations
- 2Start with low-risk, non-critical tasks
- 3Progress to more complex and valuable use cases
- 4Build expertise through regular use and experimentation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.7★★★★★72 reviews- ★★★★★Henry Park· Dec 28, 2024
Solid pick for teams standardizing on skills: go-concurrency is focused, and the summary matches what you get after install.
- ★★★★★Henry Choi· Dec 24, 2024
go-concurrency is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★Luis Ramirez· Dec 20, 2024
I recommend go-concurrency for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Noah Srinivasan· Dec 12, 2024
Keeps context tight: go-concurrency is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Noah Singh· Dec 8, 2024
go-concurrency is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★Mei Martinez· Dec 8, 2024
go-concurrency fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Aanya Thomas· Dec 4, 2024
Useful defaults in go-concurrency — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Hassan Ghosh· Nov 27, 2024
Solid pick for teams standardizing on skills: go-concurrency is focused, and the summary matches what you get after install.
- ★★★★★Noah Gonzalez· Nov 27, 2024
Registry listing for go-concurrency matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Yash Thakker· Nov 19, 2024
I recommend go-concurrency for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
showing 1-10 of 72