← ClaudeAtlas

concurrency-and-asynclisted

Use when a ticket involves work happening at the same time — async/await flows, promises and futures, goroutines and channels, threads and locks, parallel requests, races, deadlocks, "sometimes it double-processes" — and the change must be correct under interleaving, not just on the happy sequence. Invoke for any concurrency bug, any new parallelism, any shared mutable state, or any code where two requests, workers or processes can write the same file, row, counter or lock.
tmj-90/gaffer · ★ 1 · AI & Automation · score 70
Install: claude install-skill tmj-90/gaffer
# Write concurrent code that is correct under interleaving Concurrency bugs pass every sequential test. Live builds of the same app twice shipped the same class past review: fixed temp-file names colliding under parallel requests (HTTP 500), unsynchronised read-modify-write losing updates, and a time-only stale-lock lease that dropped an **acknowledged** write when the holder was paused past the threshold. Assume that any code with a shared file, row, counter or lock has one of these until a test that forces the schedule proves otherwise. ## Steps 1. **Inventory shared state and writers.** For every file, row, counter, cache entry or lock file the change touches, list who can write it: concurrent requests in one async process (every `await` is a yield point), threads, other worker processes or instances, and a restarted process after a crash. Call `search_lore` for the repo's lock helper, worker model and transaction rules. Each item must end up immutable, single-owner (one queue/actor/goroutine does all writes), or guarded. 2. **Pick the guard by scope.** In one process: a mutex or per-key async lock, or a single-writer queue. Across processes on one host: an OS lock the kernel releases on death (`flock`/`fcntl`, `LockFileEx`). Across hosts or on database rows: the database (`UPDATE … SET n = n + 1`, `SELECT … FOR UPDATE`, a unique constraint, a version column, `pg_advisory_xact_lock`). An in-memory flag guards nothing once there are two proc