cpp-concurrency-review
Installation
SKILL.md
C++ Concurrency Review
Use this skill when C++ code shares mutable state across threads using standard primitives (std::thread, std::jthread, std::mutex, std::atomic, std::condition_variable, std::once_flag, thread_local) or dispatches observers/callbacks across threads, and the question is whether the synchronization is correct, deadlock-free, and shut down deterministically.
The goal is to make every shared access provably ordered: each piece of shared mutable state has a named synchronization regime, and every access happens under it.
UTILITY SKILL. INVOKES: read-only file access for supplied targets; no other tools or skills. FOR SINGLE OPERATIONS: use for focused race/deadlock review, synchronization design, memory-ordering analysis, or test planning.
Scope
- Use this skill for data races, lock granularity and ordering, deadlock and livelock analysis, condition-variable protocols,
std::atomicmemory-ordering correctness, double-checked initialization,thread_locallifecycle,shared_ptrcontrol-block vs pointee thread safety, false sharing, and thread lifecycle (spawn, detach, join, shutdown). For livelock, check unbounded retry loops, contendedcompare_exchangeloops without backoff, and mutual yield-and-retry protocols that can starve each other. - Apply it to raw standard-library threading code, hand-rolled thread pools, lock-free or lock-reduced structures, and producer-consumer queues built on mutexes/CVs/atomics.
- Treat object-destruction races (object destroyed while another thread still uses it) as in scope where the fix is synchronization or lifecycle ordering.
- Treat cross-thread observer/callback dispatch (e.g. Boost.Signals2 signals, hand-rolled callback registries) as in scope when slots/callbacks connect or disconnect on one thread while dispatch fires on another: the callback container, the connect/disconnect race, and slot-captured-object lifetime across the emission each need a regime.