Agent skill

Go Concurrency

by cxuu in cxuu/golang-skills

A skill your agent uses when writing concurrent Go code — goroutines, channels, mutexes, or thread-safety guarantees.

Apache-2.0Auto-check passedDevelopment

Install Go Concurrency

skills CLI
$ npx skills add cxuu/golang-skills --skill go-concurrency -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install cxuu/golang-skills go-concurrency --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/cxuu/golang-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/go-concurrency .claude/skills/go-concurrency && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
go-concurrency
GitHub stars
173
Token cost
~1.8k tokens
SKILL.md length
664 words
Files
5 (incl. references)
Skills in repo
20
Repo updated
First seen
Licence
Apache-2.0

At a glance

A skill your agent uses when writing concurrent Go code — goroutines, channels, mutexes, or thread-safety guarantees.

  • Works in 4 steps: Every goroutine needs a stop mechanism —… → Code must be able to wait for the… → No goroutines in init() — expose… → …
  • Writing concurrent Go code — goroutines
  • SKILL.md covers Resource Routing, Goroutine Lifetimes, Share by Communicating and Synchronous Functions, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Go Concurrency is an agent skill from cxuu/golang-skills. Use when writing concurrent Go code — goroutines, channels, mutexes, or thread-safety guarantees. Also use when parallelizing work, fixing data races, or protecting shared state, even if the user doesn't explicitly mention concurrency primitives. Does not cover context.Context patterns (see go-context).

Its SKILL.md is about 1.8k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including reference files (for example `references/ADVANCED-PATTERNS.md`, `references/BUFFER-POOLING.md` and `references/GOROUTINE-PATTERNS.md`).

It sits in Development, covering Async programming. The repository describes itself as: AI Agent Skills for idiomatic, production-ready Go code, distilled from Google, Uber, Community. The licence is Apache-2.0.

When your agent uses it

  • Writing concurrent Go code — goroutines
  • Thread-safety guarantees
  • Parallelizing work
  • Fixing data races

Example prompts

  • “/go-concurrency”

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Every goroutine needs a stop mechanism — a predictable end time, a
  2. Code must be able to wait for the goroutine to finish
  3. No goroutines in init() — expose lifecycle methods (Close, Stop,
  4. Keep synchronization scoped — constrain to function scope, factor logic

What it can do on your machine

Read from SKILL.md and the folder at commit 91f0c2e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are go).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • pkg.go.dev
    • dave.cheney.net
    • youtube.com
    • changelog.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Go Concurrency loads about 1.8k tokens when it runs, and up to ~4.6k if it reads all its reference files. Until then it costs about 80 tokens; SKILL.md has 664 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~80
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from cxuu/golang-skills at commit 91f0c2e, republished under its Apache-2.0 licence (© cxuu). 664 words, ~1,775 tokens.

Download SKILL.mdSave it as .claude/skills/go-concurrency/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
go-concurrency
description
Use when writing concurrent Go code — goroutines, channels, mutexes, or thread-safety guarantees. Also use when parallelizing work, fixing data races, or protecting shared state, even if the user doesn't explicitly mention concurrency primitives. Does not cover context.Context patterns (see go-context).

Go Concurrency

Compatibility: Atomic examples may use standard-library typed atomics where available or go.uber.org/atomic where a project already depends on it.

Resource Routing

  • references/GOROUTINE-PATTERNS.md - Read when starting, stopping, or waiting for goroutines.
  • references/SYNC-PRIMITIVES.md - Read when choosing between mutexes, atomics, channels, and once-like primitives.
  • references/BUFFER-POOLING.md - Read when considering channel-backed or sync.Pool-style reuse.
  • references/ADVANCED-PATTERNS.md - Read for worker pools, pipelines, errgroup, and cancellation-heavy patterns.

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
  1. Every goroutine needs a stop mechanism — a predictable end time, a cancellation signal, or both
  2. Code must be able to wait for the goroutine to finish
  3. No goroutines in init() — expose lifecycle methods (Close, Stop, Shutdown) instead
  4. Keep synchronization scoped — constrain to function scope, factor logic into synchronous functions
go
// Good: Clear lifetime with WaitGroup.Go (Go 1.25+)
var wg sync.WaitGroup
for item := range queue {
    item := item
    wg.Go(func() { process(ctx, item) })
}
wg.Wait()
go
// 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.


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.

BenefitWhy
Localized goroutinesLifetimes easier to reason about
Avoids leaks and racesEasier to prevent resource leaks and data races
Easier to testCheck input/output without polling
Caller flexibilityCaller 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.


Zero-value Mutexes

The zero-value of sync.Mutex and sync.RWMutex is valid — almost never need a pointer to a mutex.

go
// 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.


Channel Direction

Normative: Specify channel direction where possible.

Direction prevents errors (compiler catches closing a receive-only channel), conveys ownership, and is self-documenting.

go
func produce(out chan<- int) { /* send-only */ }
func consume(in <-chan int)  { /* receive-only */ }
func transform(in <-chan int, out chan<- int) { /* both */ }
Show full SKILL.md (268 more words)Show less
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
go
c := make(chan int)    // unbuffered — Good
c := make(chan int, 1) // size one — Good
c := make(chan int, 64) // arbitrary — needs justification

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.

go
// 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!

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:

  1. Read vs mutating is unclear — e.g., a Lookup that mutates LRU state
  2. API provides synchronization — e.g., thread-safe clients
  3. 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.


  • 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

© cxuu, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (references) in skills/go-concurrency of cxuu/golang-skills.

  • SKILL.md
  • references/ADVANCED-PATTERNS.md
  • references/BUFFER-POOLING.md
  • references/GOROUTINE-PATTERNS.md
  • references/SYNC-PRIMITIVES.md

Open the folder on GitHubat commit 91f0c2e

Compare with similar skills

Go Concurrency next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Go Concurrency compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Go Concurrency this skillcxuu/golang-skills173—~1.8kAutomated safety check: PassApache-2.0
YugabyteDB ASH Instrumentationyugabyte/yugabyte-db11k—~4.5kAutomated safety check: PassCustom licence
Mirage VFS Adapter Authoringstrukto-ai/mirage3.7k—~2.5kAutomated safety check: PassApache-2.0
Golang Patternsantoniopaya22/go-rest-template1729 repos~3.5kAutomated safety check: PassNone
Rust Async Patternsdiodeme/Gold-Band14310 repos~3.1kAutomated safety check: PassAGPL-3.0
Swift Concurrencyhenrypldev/react-native-nitro-mlx1003 repos~3.1kAutomated safety check: PassMIT

Similar skills

  • YugabyteDB ASH Instrumentation

    yugabyte/yugabyte-db

    Procedure for adding or changing YugabyteDB Active Session History wait states in TServer and DocDB C++ code, including the macro to use for sync and async paths.

    11k GitHub stars~4.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Builds or extends a custom Mirage virtual filesystem adapter for an API, database, object store or app data, with a working mount configuration and filesystem tests.

    3.7k GitHub stars~2.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Golang Patterns

    antoniopaya22/go-rest-template

    Idiomatic Go patterns, best practices, and conventions for building robust, efficient, and maintainable Go applications.

    172 GitHub starsUsed in 9 repos~3.5k tokens
    DevelopmentAuto-check passed
  • Rust Async Patterns

    diodeme/Gold-Band

    Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns.

    143 GitHub starsUsed in 10 repos~3.1k tokens
    DevelopmentAuto-check passed
  • Swift Concurrency

    henrypldev/react-native-nitro-mlx

    Diagnose Swift Concurrency issues, refactor callback-based code to async/await, and guide Swift 6 migration when working with tasks, actors, @MainActor, Sendable, data races, thread safety, or…

    100 GitHub starsUsed in 3 repos~3.1k tokens
    DevelopmentAuto-check passed
  • Rust Engineer

    farm-fe/farm

    Writes, reviews, and debugs idiomatic Rust code with memory safety and zero-cost abstractions.

    5.6k GitHub starsUsed in 1 repo~1.5k tokens
    DevelopmentAuto-check passed

More from cxuu/golang-skills

All 20 skills in this repo
  • Go Testing

    cxuu/golang-skills

    A skill your agent uses when writing, reviewing, or improving Go test code — including table-driven tests, subtests, parallel tests, test helpers, test doubles, and assertions with cmp.Diff.

    173 GitHub starsUsed in 1 repo~1.3k tokens
    Auto-check passed
  • Go Code Review

    cxuu/golang-skills

    A skill your agent uses when reviewing Go code or checking code against community style standards.

    173 GitHub stars~2.7k tokensUpdated 3 mo ago
    Auto-check passed
  • Go Performance

    cxuu/golang-skills

    A skill your agent uses when optimizing Go code, investigating slow performance, or writing performance-critical sections.

    173 GitHub starsUsed in 1 repo~1.3k tokens
    Auto-check passed
  • Go Documentation

    cxuu/golang-skills

    A skill your agent uses when writing or reviewing documentation for Go packages, types, functions, or methods.

    173 GitHub stars~1.3k tokensUpdated 3 mo ago
    Auto-check passed
  • Go Error Handling

    cxuu/golang-skills

    A skill your agent uses when writing Go code that returns, wraps, or handles errors — choosing between sentinel errors, custom types, and fmt.Errorf (%w vs %v), structuring error flow, or deciding…

    173 GitHub stars~1.5k tokensUpdated 3 mo ago
    Auto-check passed
  • Go Interfaces

    cxuu/golang-skills

    A skill your agent uses when defining or implementing Go interfaces, designing abstractions, creating mockable boundaries for testing, or composing types through embedding.

    173 GitHub stars~1.4k tokensUpdated 3 mo ago
    Auto-check passed

Categories

Questions about Go Concurrency

What does Go Concurrency do?

A skill your agent uses when writing concurrent Go code — goroutines, channels, mutexes, or thread-safety guarantees. Go Concurrency is an agent skill from cxuu/golang-skills. Use when writing concurrent Go code — goroutines, channels, mutexes, or thread-safety guarantees.

When should I use Go Concurrency?

Go Concurrency fits situations like: writing concurrent Go code — goroutines; thread-safety guarantees; parallelizing work; fixing data races.

How do I install Go Concurrency in Claude Code?

Run `npx skills add cxuu/golang-skills --skill go-concurrency -a claude-code`. Or copy the skill folder (skills/go-concurrency in cxuu/golang-skills) into .claude/skills/go-concurrency in your project. Claude Code loads it when a task matches its description.

How do I install Go Concurrency in Codex?

Run `npx skills add cxuu/golang-skills --skill go-concurrency -a codex`. Or copy the skill folder (skills/go-concurrency in cxuu/golang-skills) into .agents/skills/go-concurrency in your project. Codex loads it when a task matches its description.

Can I use Go Concurrency in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add cxuu/golang-skills --skill go-concurrency -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/go-concurrency, .gemini/skills/go-concurrency, .github/skills/go-concurrency and .opencode/skills/go-concurrency in your project.

What does Go Concurrency need to run?

SKILL.md names no scripts, command-line tools or credentials: Go Concurrency is instructions for the agent only.

Does Go Concurrency access the network?

SKILL.md names 4 domains. As links in the text: pkg.go.dev, dave.cheney.net, youtube.com and changelog.com. This is read from the text; nothing was executed.

Is Go Concurrency safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Go Concurrency use?

Go Concurrency is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Go Concurrency use?

About 1.8k tokens (SKILL.md is roughly 7.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.8k tokens, read only when the agent opens those files.

What are the alternatives to Go Concurrency?

Skills that share tags, products or a category with Go Concurrency: YugabyteDB ASH Instrumentation (yugabyte/yugabyte-db, 11k stars), Mirage VFS Adapter Authoring (strukto-ai/mirage, 3.7k stars), Golang Patterns (antoniopaya22/go-rest-template, 172 stars) and Rust Async Patterns (diodeme/Gold-Band, 143 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Go Concurrency?

cxuu (a GitHub user) maintains it in cxuu/golang-skills, which has 173 GitHub stars. The repository holds 20 skills in this directory. The repository was last updated on June 20, 2026.

Source: cxuu/golang-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.