There's a small, dangerous stretch of time between asking your machine to do something and getting the answer back — the compile, the test run, the deploy, the AI agent thinking. It feels too short to use and too long to ignore. That's the wait gap, and it's where focus goes to die.
Distraction rarely strikes when you're deep in a problem. It strikes in the seams — the build compiling, the tests running, the dev server reloading, the CI (continuous integration) pipeline churning. Your brain hits a few seconds of nothing, wants a hit of stimulation, and grabs the fastest one available. A news tab. A feed. A "quick" check.
The trap isn't the ten-second wait. It's that opening that tab is a full context switch, and you don't come back in ten seconds — you come back in twenty minutes, if you remember what you were doing at all.
Here's the loop you're fighting:
Here's what actually works, most of it well-worn advice that survives because it's true.
1. Make the distraction harder to reach than the task
Willpower loses to friction almost every time, so stop relying on it. Put obstacles between you and the off-ramp:
- Block the usual sites during work hours (LeechBlock, Cold Turkey, or a hosts-file entry).
- Log out of them, so a check means re-authenticating.
- Clear the browser autocomplete so the URL doesn't finish itself after one keystroke.
If reaching the distraction takes three deliberate steps instead of one reflex, the impulse usually passes before you finish. This single change tends to outperform every mindset tip combined.
2. Give the wait a default action that isn't a context switch
A wait needs a plan, or it defaults to escape. Decide in advance what your eyes do when something's compiling: they stay on the code. Reread the function you just wrote. Write the name of the next test. Skim the diff you're about to commit. Sit with the ten seconds.
This is an implementation intention — "when X happens, I do Y" — and it works because you're not deciding in the moment, you're executing a rule you already made. Staying visually anchored to your own work keeps you inside the task instead of leaking out of it.
3. Capture the urge to jump instead of obeying it
Mid-task, a thought fires: I should go do that other thing. Most of the time that urge is just the fear you'll forget it. So externalize it. Keep a scratch file (or paper) open and write the thought down in one line, then keep going.
Writing it satisfies the part of your brain that was nagging, and lets you finish what you're on. Come back to the list later — most of those "urgent" jumps look entirely optional an hour on.
4. Shrink the waits themselves
As a developer you have a lever most people don't: many of your distraction windows are just slow feedback loops. Close them.
- Run Vitest in watch mode, scoped to affected tests, so a run is seconds not a minute.
- Keep HMR (hot module replacement) fast — audit heavy imports and barrel files that slow the reload.
- Split or parallelize slow suites; move the genuinely slow, full-run checks to CI where you're not sitting and staring.
Turning a forty-second wait into a three-second one removes the temptation window before it can open. Audit where your longest waits actually are — those are your highest-risk moments, and often your easiest wins.
5. Work in defined blocks
Give focus a container. A Pomodoro-style block (25 minutes on, 5 off) works because it does two things at once: it makes distraction a scheduled thing rather than an impulse — "not now, in twelve minutes" — and it caps how long you have to hold attention, which makes starting feel cheap. Any timer works; the point is that the block, not your mood, decides when you break.
6. Reduce the ambient pull
Attention is easier to hold when fewer things are competing for it.
- Silence notifications, or use Do Not Disturb / Focus modes during blocks.
- Close Slack and email in a background window; batch them to set times.
- Keep your phone out of arm's reach — visible phones tax attention even when dark.
You're not trying to be a monk. You're just lowering the number of small pulls, so the ones that get through are the ones that matter.
The short version
Distraction is an environment problem more than a discipline problem. Add friction to the escape routes, give your waits a default that keeps your eyes on the work, capture stray urges instead of chasing them, and shrink the feedback loops that create the gaps in the first place. Fix the environment and the willpower takes care of itself.
One honest caveat: if none of this moves the needle and it's been that way a long time — the pull feels less like a habit and more like something you genuinely can't steer — it's worth talking to a professional. But try reshaping the environment first, since for most people that's the whole fix.
