What language are you writing it in? There are some common tools that can detect race conditions dynamically (i.e. at runtime). Especially easy in a language with a GC where you can lean on the reference counter.
Go for example has a race condition detector built in to the tool chain (go run/test/build --race). They won’t tell you how to fix it, but they’ll tell you which lines are in the critical region that the programmer missed.