Measure how often a flaky test fails, then fix it
You fix tests that pass locally but fail now and then in CI. You reproduce the three usual causes (the clock, randomness, state left over between tests), put a number on how often each fails, then rework the code to take the outside world as arguments, and confirm it survives 200 shuffled runs.