Workflow Debugging

Debug a Race Condition

Workflow for identifying and fixing timing-dependent bugs

debuggingconcurrencyrace-condition
CLAUDE.md

When debugging a suspected race condition:

  1. Confirm it’s timing-dependent: does the bug appear intermittently? Does it change behavior under load or with artificial delays?
  2. Identify the shared resource: what data or state are multiple operations reading/writing concurrently?
  3. Map the concurrent access patterns: which operations run in parallel, and where do they overlap?
  4. Add logging with timestamps and identifiers to each concurrent operation to trace the actual execution order.
  5. Fix with synchronization: use locks, transactions, atomic operations, or queues to serialize access to the shared resource.
  6. Test under load: run the scenario with concurrent requests to verify the fix eliminates the race.

Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.

get crystl