concurrency-patterns

concurrency-patterns is a skill for Claude Code, Codex from cass-2003/local-workflow-skill. It costs 168 tokens per session (3,629 once invoked), scanned A, original, MIT.

A guide to running multiple tasks safely at the same time. It explains locks, message passing, asynchronous code, worker pools, and common problems such as race conditions and deadlocks.

In plain words
What is it for?
Use it to build parallel workers and pipelines, handle concurrent requests, or investigate intermittent crashes, races, deadlocks, and stalls.
Why use it?
It helps choose a suitable way to coordinate shared work and prevents timing-related bugs that may appear only occasionally. It also clarifies the difference between tasks progressing together and tasks running at the same time.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to build parallel workers and pipelines, handle concurrent requests, or investigate intermittent crashes, races, deadlocks, and stalls.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cass-2003/local-workflow-skill/concurrency-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add cass-2003/local-workflow-skill --skill concurrency-patterns
Clone the repo
git clone --depth 1 https://github.com/cass-2003/local-workflow-skill

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for concurrency-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/concurrency-patterns/github.svg)](https://agentmods.dev/skills/cass-2003/local-workflow-skill/concurrency-patterns)
Your own site
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/concurrency-patterns"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/concurrency-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for concurrency-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/cass-2003/local-workflow-skill/concurrency-patterns"><img src="https://agentmods.dev/badge/skills/cass-2003/local-workflow-skill/concurrency-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 168 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,629 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00168 $0.03629
Opus 5 $0.00084 $0.01814
Sonnet 5 $0.00034 $0.00726
Haiku 4.5 $0.00017 $0.00363

Measured 6d ago against content hash f9d6658290b4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

concurrency-patterns scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const r = await fetch(url, { signal: ctrl.signal })
skills/engineering-core/ours/concurrency-patterns/SKILL.md · 488 lines

How it starts

The opening of the file, as written. The whole thing — 488 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Concurrency Patterns Skill — 并发原语跨语言

何时使用

  • 设计高并发服务(并行处理 / 流水线 / 扇出扇入)
  • 排查 race condition / deadlock / 偶发崩溃
  • 选择 mutex vs channel vs actor
  • 实现 worker pool / 任务并行
  • 跨语言移植并发代码

一、并发模型分类

模型 代表 哲学
共享内存 + 锁 Java / C++ / Python threading "用锁保护共享数据"
CSP(消息传递) Go / Erlang "Don't communicate by sharing memory; share memory by communicating"
Actor Erlang / Akka / Elixir "每个 actor 自封闭,邮箱接收消息"
Async/Await JS / Python asyncio / Rust / C# "单线程事件循环,IO 等待时让出"
Software Transactional Memory Clojure / Haskell "数据库事务般的内存原子块"
Data Parallel OpenMP / CUDA "同一操作并行作用于数据数组"

不同语言混合使用。Go 主推 CSP 但也有 mutex;Rust 主推无锁但提供完整 sync 库。

二、关键概念区分

并发 vs 并行

并发(concurrency):多个任务交替推进(可单核)
并行(parallelism):多个任务同时执行(多核)

asyncio 是并发单线程;Go runtime / Java 线程池是并行多核。

进程 / 线程 / 协程

切换成本 内存 隔离
进程 高(上下文 + TLB) MB 级 完全
线程 中(寄存器) KB-MB 共享地址空间
协程 / fiber 低(用户态) KB 级 共享地址空间
Goroutine 极低 2KB 起 共享
async task 极低(栈复用) 极小 共享

Goroutine = 用户态调度的轻量线程;async/await = 编译器变换的状态机。

三、Mutex(最基础)

// Go
var mu sync.Mutex
var counter int

func increment() {
    mu.Lock()
    defer mu.Unlock()
    counter++
}
// Rust
use std::sync::Mutex;
let counter = Mutex::new(0);
let mut guard = counter.lock().unwrap();
*guard += 1;
// guard 离开作用域自动释放(RAII)
# Python
lock = threading.Lock()
with lock:
    counter += 1
// JS 单线程,无 mutex;Web Worker 间用 SharedArrayBuffer + Atomics
const sab = new SharedArrayBuffer(4)
const view = new Int32Array(sab)
Atomics.add(view, 0, 1)

RWLock(读多写少)

var mu sync.RWMutex
mu.RLock(); ... mu.RUnlock()      // 多读
mu.Lock();  ... mu.Unlock()        // 独占写

读远多于写时显著快于普通 Mutex。

Atomic

import "sync/atomic"
var counter atomic.Int64
counter.Add(1)
counter.Load()

无锁,单变量级 / CPU 指令直接支持。比 mutex 快 5-10 倍。

四、Go 的 Channel(CSP)

// 无缓冲 — 发送阻塞直到接收
ch := make(chan int)
go func() { ch <- 42 }()
val := <-ch

// 带缓冲
ch := make(chan int, 10)

// 关闭
close(ch)
for val := range ch { ... }   // 收到所有 + close

// select 多路
select {
case v := <-ch1: ...
case ch2 <- val: ...
case <-time.After(5*time.Second): // 超时
case <-ctx.Done():               // 取消
}

Read the full file on GitHub · 488 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 488 lines · 168 tokens per session scan A f9d6658290b4

Subscribe to this mod's changes

concurrency-patterns is a skill published in the GitHub repository cass-2003/local-workflow-skill (12 stars, last pushed 2mo ago), licensed MIT. It adds 168 tokens to every session and 3,629 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

printing-press-amend

Amend a published CLI from one of two input sources: (1) dogfood mode mines the active Claude Code session transcript for friction (missing flags, hand- rolled API payloads, silent-null returns); (2) direct-input mode accepts user-supplied asks (rename a command, add commands or feeds, fix a named bug, optionally…

mvanhorn/cli-printing-press · 222 tokens

convex-performance-audit

Audits Convex performance for reads, subscriptions, write contention, and function limits. Use for slow features, insights findings, OCC conflicts, or read amplification.

openclaw/clawhub · 38 tokens

convex-insights

Query a running Convex app's logs + health in natural language (official MCP): failures, slow/expensive functions, deploy causality — scoped, evidence-backed, with a dashboard deep link.

openclaw/clawhub · 45 tokens

ssl-proxy-troubleshoot

Systematic workflow for troubleshooting SSL/proxy connectivity issues with government websites.

HKUDS/OpenSpace · 20 tokens

diagnose-backend-bug

Diagnose a bounded backend or multi-service failure from GitHub Issues, Jira, Aone, user-provided exports, logs, traces, responses, stack traces, or job records. Use when a service, API, RPC, worker, queue, CLI, or scheduled job bug needs correlation through the project's existing observability route before repair; do…

QoderAI/better-harness · 87 tokens

axiom-networking

Use when implementing or debugging ANY network connection, API call, or socket. Covers URLSession, Network.framework, NetworkConnection, connection diagnostics.

CharlesWiltgen/Axiom · 33 tokens