I've been using a tabata timer (used for timing workout intervals and rest periods) for programming for a few months combined with these other elements.

I do 6 sets of 15 minutes each with a 30 second rest in between. This ends up being 90 minutes of coding time per session. Goal is to do at least one session each day first thing in the morning.

Here are the key elements of my current setup:

01 Block distractions

I setup my browser to block all distracting sites - including email.  You can use browser extensions or desktop apps for this. Most allow you  to block certain sites for certain times during the day. So you can set  it up once and forget about it.

When it comes to distractions I keep this principle in mind: don't try to change yourself, change your environment!

02 Visualize a specific physical code change

I start each session with a specific goal in mind that I want to  accomplish. At the beginning of each 15 minutes I visualize making a  specific code change. For example: implement this form such that when I  click 'save' I see these records in the database. During the 30 second  'rest', I ask myself "Am I on track?".  This question has been useful  because there are many times I stray off track by finding something  interesting to think about or explore that is not exactly related to the  task at hand :)

03 Timebox research tasks

In the event I need to look something up and I find myself in a search engine for more than a minute I set a timer to timebox my  'research'. Same goes with decision making. If I am trying to decide whether to use one tool vs. another, timebox that as well. These tend to be the biggest time sinks for me when I don't keep track.

04 Continue the flow through breaks or interruptions

I explicitly write down todo next in the code editor or a notebook when I am taking a break for lunch, get interrupted for other reasons or when I sign-off for the day.

I also try to leave my computer screen on the IDE with the next bit of code highlighted so when I open up my laptop the next day that's the first thing I see.

05 Reward

Doing deep work and paying attention to only one task requires great deal of energy. My current reward for finishing a 90 minutes session is getting to explore one or two things I've bookmarked during the session for deeper understanding (thread pulling I call it). It can also be thinking and planning and organizing and strategizing - all things my brain enjoys and craves. I know these things are not fruitful on their own but work well as a reward.

This flow works well for feature development. Slightly different flow is needed for debugging and designing/planning activities. I am still experimenting.

I wonder what tricks others use to add flow and consistency to their programming routine. I'm always curious about other's programming (and writing) workflows.

What techniques do you use to optimize for flow during your programming sessions? Share your tips, send me a message.