Command Palette

Search for a command to run...

Back to skills
skill № 58251

ln-628-concurrency-auditor

Checks async races, thread safety, TOCTOU, deadlocks, blocking I/O, resource contention, cross-process races. Two-layer detection: grep + agent reasoning.

FreeNo executable scripts
tensologyby tensology★ 17 GitHub stars

Install ln-628-concurrency-auditor in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

Paths: File paths (shared/, references/, ../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.

Concurrency Auditor (L3 Worker)

Specialized worker auditing concurrency, async patterns, and cross-process resource access.

Purpose & Scope

  • Worker in ln-620 coordinator pipeline
  • Audit concurrency (Category 11: High Priority)
  • 7 checks: async races, thread safety, TOCTOU, deadlocks, blocking I/O, resource contention, cross-process races
  • Two-layer detection: grep finds candidates, agent reasons about context
  • Calculate compliance score (X/10)

Inputs (from Coordinator)

MANDATORY READ: Load shared/references/audit_worker_core_contract.md.

Receives contextStore with: tech_stack, best_practices, codebase_root, output_dir.

Workflow

MANDATORY READ: Load shared/references/two_layer_detection.md for detection methodology.

  1. Parse context — extract tech_stack, language, output_dir from contextStore
  2. Per check (1-7):
    • Layer 1: Grep/Glob scan to find candidates
    • Layer 2: Read 20-50 lines around each candidate. Apply check-specific critical questions. Classify: confirmed / false positive / needs-context
  3. Collect confirmed findings with severity, location, effort, recommendation
  4. Calculate score per shared/references/audit_scoring.md
  5. Write Report — build in memory, write to {output_dir}/628-concurrency.md (atomic single Write)
  6. Return Summary to coordinator

Audit Rules

Unified severity escalation: For ALL checks — if finding affects payment/auth/financial code → escalate to CRITICAL regardless of other factors.

1. Async/Event-Loop Races (CWE-362)

What: Shared state corrupted across await/yield boundaries in single-threaded async code.

Layer 1 — Grep patterns:

Language Pattern Grep
JS/TS Read-modify-write across await \w+\s*[+\-*/]?=\s*.*await (e.g., result += await something)
JS/TS Check-then-initialize race if\s*\(!?\w+\) followed by \w+\s*=\s*await in same block
Python Read-modify-write across await \w+\s*[+\-*/]?=\s*await inside async def
Python Shared module-level state in async Module-level \w+\s*= + modified inside async def
All Shared cache without lock `.set(

Layer 2 — Critical questions:

  • Is the variable shared (module/global scope) or local?
  • Can two async tasks interleave at this await point?
  • Is there a lock/mutex/semaphore guarding the access?

Severity: CRITICAL (payment/auth) | HIGH (user-facing) | MEDIUM (background)

Safe pattern exclusions: Local variables, const declarations, single-use await (no interleaving possible).

Effort: M

2. Thread/Goroutine Safety (CWE-366)

What: Shared mutable state accessed from multiple threads/goroutines without synchronization.

Layer 1 — Grep patterns:

Language Pattern Grep
Go Map access without mutex map\[.*\].*= in struct without sync.Mutex or sync.RWMutex
Go Variable captured by goroutine go func + variable from outer scope modified
Python Global modified in threads global\s+\w+ in function + threading.Thread in same file
Java HashMap shared between threads HashMap + Thread|Executor|Runnable in same class without synchronized|ConcurrentHashMap
Rust Rc in multi-thread context Rc<RefCell + thread::spawn|tokio::spawn in same file
Node.js Worker Threads shared state workerData|SharedArrayBuffer|parentPort + mutable access without Atomics

Layer 2 — Critical questions:

  • Is this struct/object actually shared between threads? (single-threaded code → FP)
  • Is mutex/lock in embedded struct or imported module? (grep may miss it)
  • Is go func capturing by value (safe) or by reference (unsafe)?

Severity: CRITICAL (payment/auth) | HIGH (data corruption possible) | MEDIUM (internal)

Safe pattern exclusions: Go map in init() or main() before goroutines start. Rust Arc<Mutex<T>> (already safe). Java Collections.synchronizedMap().

Effort: M

3. TOCTOU — Time-of-Check Time-of-Use (CWE-367)

What: Resource state checked, then used, but state can change between check and use.

Layer 1 — Grep patterns:

Language Check Use Grep
Python os.path.exists() open() os\.path\.exists\( near open\( on same variable
Python os.access() os.open() os\.access\( near os\.open\(|open\(
Node.js fs.existsSync() fs.readFileSync() existsSync\( near readFileSync\(|readFile\(
Node.js fs.accessSync() fs.openSync() accessSync\( near openSync\(
Go os.Stat() os.Open() os\.Stat\( near os\.Open\(|os\.Create\(
Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

  1. 01Read
  2. 02Grep
  3. 03Glob
  4. 04Bash

FAQ

What does the ln-628-concurrency-auditor skill do?

Checks async races, thread safety, TOCTOU, deadlocks, blocking I/O, resource contention, cross-process races. Two-layer detection: grep + agent reasoning.

How do I install the ln-628-concurrency-auditor skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the ln-628-concurrency-auditor skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare ln-628-concurrency-auditor with