I spent 2020 writing a 500-pages book about JavaScript Testing.

In this blog post, I’ll explain my writing routine — or system, whatever you want to call it — and other seemingly unrelated habits that I consider have been crucial for writing such a long book.

If you’re thinking about writing a book or have already started, this blog post may be helpful to you. Besides explaining rules you could adopt, this post can shed some light on how much work it takes to write a book.

I’ve divided this post into two parts. The first describes the writing routine or system itself. The second part describes other seemingly unrelated habits that I consider to have been crucial for writing.

A picture of my hand holding the book I had written, called Testing JavaScript applications.

The first time I saw my book, Testing JavaScript applications, in print.

I'm not a doctor and this content should not be considered medical advice.

Please see this website's health and medical disclaimer before proceeding.

My writing routine

My writing routine can be summarised in a single sentence: consistency beats enthusiasm.

To me, writing is just like running. Getting out of bed early in the morning requires herculean effort. Then, the first mile of your run sucks. Eventually, when you’re already out there running, and you’ve got that first mile in, you’re happy you did it.

The thing with running is that those early mornings or first miles never get easier no matter how many times you do it. Instead, you remember how good it felt yesterday, so you put on your shoes and head outside to seek your reward.

The same principle applies to writing. As time passes, you rely less on motivation and more on discipline.

In this section, I’ll clarify what “ discipline” means to me. I’ll do that by explaining my productivity system’s four rules:

  1. Writing for at least 45 minutes every day.
  2. Always writing at the same time.
  3. Keeping my writing environment consistent.
  4. Setting deadlines and holding myself accountable.

For each of these rules or habits, I’ve written a section detailing it and explaining why it worked for me.

I write for at least 45 minutes every day

From the day I started writing Testing JavaScript Applications, I committed to writing every day for at least 45-minutes. During those 45 minutes, I didn’t care about how many words I committed to paper (or hard drive). I just had to do my best to write as much as I could. If it meant I had to stare at a blinking cursor for 45 minutes, then I did that.

If I couldn’t write anything meaningful in 45 minutes, I probably wouldn’t write anything decent for the next few hours. Therefore, it was better to close up my Mac, walk away, and grab a cup of tea.

In case I did write few great paragraphs, I accepted the blessing from the gods of prose and churned out as much content as I could until I hit a creative block or was too tired to proceed.

I chose to set myself a 45-minute goal because that’s the time it usually takes for me to get “into the zone” and figure out whether I’m going to be productive that day.

In case you’re planning to write regularly too, I’d recommend you do the same: set a time goal, not a word goal. Time goals are more effective because they force you to give yourself the chance of entering into a flow state.

If you can’t get into a flow state in the allotted time, you will most likely produce crappy content, which you’ll delete later anyway.

It’s not worth it to force yourself to be productive when you don’t have the cognitive resources to do so. It’s better not to write a thousand words than to write a thousand words and delete all of them later.

In the past, my therapist used the term “efforting” to describe the act of spending long periods trying to be productive despite not obtaining any meaningful results. Efforting is precisely what you do not want to do.

I always write at the same time

Sticking to a fixed writing schedule helped me be more consistent. Having to write always at the same time has diminished the effort necessary to get started.

All of a sudden, writing for 45 minutes didn’t require any willpower. It was simply something I used to do every day at that particular time. I didn’t have to “choose” writing; I just did it. In other words, I eliminated the “option” of not writing.

When I started writing my book in December 2019, I’d always write after work, just before going to bed.

From Monday to Friday, I’d write from about 7 PM to 8 PM. I’d get home, have my scrambled eggs, sweet potatoes, and vegetables, prepare myself a cup of camomile tea, and sit at my desk to write.

On the weekends, I’d wake up a bit later than usual to exercise and then I’d have lunch. On those days, I started writing at about 2 PM, and I’d usually finish at 6 PM.

Then, when the pandemic hit, my habits had to change. I was pretty upset because I love having a strict routine, but I understood gyms closed for a good reason, so I rebuilt an adapted daily schedule.

I went on to spend about fifteen hundred pounds on gym equipment and built myself a gym in my backyard. It was great, but at that time, I couldn’t work out at five in the morning as I used to. Otherwise, my neighbours would probably be upset.

From then on, my alarm still rang at 5 AM. Not because I had to exercise, but because I had to write.

During the pandemic, I’d wake up at 5, have a shower, write for an hour or so, and start working a bit earlier so that I could finish by 5 PM and go work out.

When I had to change my schedule, I noticed my productivity had dropped. It took about two weeks for it to go back to pre-pandemic levels.

That schedule change showed me that my productivity didn’t change depending on the time I wrote. I just had to always write at the same time.

I keep my writing environment consistent

Whenever I was about to start writing, I’d play some instrumental lo-fi hip-hop and prepare myself a cup of spiced chai with milk.

By always sipping the same flavour of tea and having the same type of music in the background, I could trick my brain into getting into a mental state conducive to writing. It was as if my brain was told “hey, it’s time to write”.

I never listened to instrumental lo-fi hip-hop or had spiced chai with milk if I wasn’t writing. Doing so would cause my brain to stop associating those cues with writing. Thus, it would be harder to get into the zone.

To put it simply, I turned myself into a Pavlov dog.

Guess what, behaviourism is quite applicable.

I set deadlines and hold myself accountable

When it comes to creative endeavours like writing, it’s helpful to set yourself deadlines to prevent overthinking.

If you don’t have any deadlines, you’ll spend a lot of time perfecting your manuscript by making small changes that won’t have a meaningful impact on the final product.

Manning was too lovely and never imposed deadlines, so I had to set deadlines for myself.

Every month, I had to write an entire chapter.

Because I had set myself that monthly goal, I knew how much time to spend self-editing and when to move on.

When combined with the 45-minute rule, these deadlines were a powerful tool because they allowed me to aim at long term goals through short-term action.

Furthermore, to hold myself accountable, I bought myself an old-fashioned wall calendar and hung it right above my desk.

Every single day, I registered in the calendar what I had written that day. Additionally, if I had a good day of writing, I’d add something like “productive day” to that day’s square.

Conversely, if there was a day I didn’t write (which were few), I registered in the calendar that I was lazy that day.

A calendar for April 2020, where each square shows what I did that day.

This is my calendar for April 2020. In it, you can see what I did every single day. On the 10th of April, I couldn't get anything done and gave up, so I wrote "lazy" on that square.

I didn’t allow myself to make up excuses. If I didn’t write, I was lazy, and that was it. I had to accept my weakness and move on.

I try always to be honest with myself and hold my behaviour and work ethic to high standards. For that, one must remain realistic and stick to their self-discipline.

Other helpful habits

Besides the habits that relate directly to writing, a couple of other seemingly unrelated practices were extremely helpful for me to write Testing JavaScript Application’s 500-pages.

These habits include a strict diet, rigorous exercise regimen, non-negotiable sleeping schedule, regular therapy, and nootropics.

Because your physical health seems to impact your psychological health and cognition (as suggested here, here, and here, for example), I consider these habits to be as crucial to writing as the ones mentioned in the previous section.

In this section, I’ll explain each of those seemingly unrelated habits.

Once again, it's worth reminding readers that I'm not a doctor and this content should not be considered medical advice.

Please see this website's health and medical disclaimer before proceeding.

Dieting and supplementation

Besides improving physical performance, being disciplined with regards to my diet supports my productivity in three ways:

  1. It allows me not to ever think about food throughout the week.
  2. It helps to keep my performance consistent week after week.
  3. It allows me to make incremental changes and measure their impact on my productivity.

My dieting rules are simple yet effective: I track all my macronutrients, water, and fibre intake and keep them within pre-determined bounds.

Furthermore, I prepare all my meals in advance. Therefore, I don’t have to spend energy making any food choices throughout the week. Instead, I just grab a plastic container and eat at the scheduled time.

An open fridge with quite a few plastic containers full of food.

These are a few of the meals I'd prepare every week. Even though it took me about two hours to prepare them, this practice saved me a lot of time during the week. Furthermore, as I enjoy cooking, I used that time to listen to podcasts and relax.

Within my “macronutrient budget”, I do my best to have a diverse diet.

Currently, I’m consuming at least two portions of fruit and a minimum of 450 grams of five types of vegetables a day.

My protein sources are also varied. They include red meats, eggs, milk, whey protein, and plant-based protein.

I do not regularly consume fish because I’m concerned about its mercury content, so I supplement with 1650mg of Omega-3 a day (990mg EPA/660mg DHA).

Since I’ve started supplementing with fish oil, I haven’t noticed much difference in cognitive performance myself, but it seems that there could be a causal relationship between Omega-3 supplementation and cognition. I primarily consume Omega-3 for longer-term health reasons.

When it comes to micros, I take 4125 IU of Vitamin D a day and multi-vitamins.

I’m not that convinced about the effectiveness of multi-vitamins, especially at the dosages that most brands use, but, for me, I think it’s worth just covering all bases.


I always sleep at least 8 hours a night.

Sleep time is non-negotiable for me. Even if I can get something done in exchange for an hour of sleep, I’ll delay it to the following day. By then, I’ll be more alert, rested, and will probably be able to produce better results in less time.

To me, sleeping is the best way to get through writers’ block. It allows me to take a step back and rethink what I’m trying to tell readers.

A few years ago, I used to take 3mg of melatonin before bed. However, once I improved my sleep hygiene and tried to cut melatonin, my energy levels throughout the day remained the same. Therefore, I stopped taking melatonin.

As I was doing that test, I used a placebo pill and was careful to do a self-blinded experiment (which was helpful despite _n_ being one given _n_ = myself).

For more information about how important it is to sleep well, I’d recommend Matthew Walker’s “Why We Sleep”.


I exercise 7-days a week. No excuses.

When I was writing my book, I was doing resistance training six times a week and doing low to moderate intensity cardio thrice a week. On my rest day, I’d just increase the cardio time.

Exercise has a massive impact on my mental wellbeing and overall cognitive performance. Since I started exercising regularly, my productivity went through the roof.

Additionally, when I listen to lectures or podcasts as I do cardio, I feel like I can retain the information for longer.

Right after a cardio session, I also notice I can think more clearly. Therefore, I always try to write for at least thirty minutes after having gone for a run.

Exercising regularly has taught me that the best way to achieve your objectives is to take short-term action aiming at a long-term goal. That’s the place my writing rules come from, and I’m thankful for that.


I couldn’t have written a 500-pages book without professional psychological support. In fact, I probably couldn’t have done nearly as much in my career without the assistance of a qualified mental health professional.

Therapy was crucial for me to understand how I think and why I have specific behavioural patterns. This deep understanding of myself has allowed me to figure out what works for me.

Thanks to therapy, instead of blindly following productivity systems out there, I can learn about those systems and adopt whichever methods and principles are in synergy with my unique behavioural patterns and preferences.

Moreover, therapy has made me a more emotionally stable person, which is also conducive to productivity.

I can’t stress enough how vital therapy was for my overall health and productivity.


My nootropic stack is straightforward. It consists of caffeine and l-theanine.

I simply take about 200mg of pure caffeine before working out and an additional 125mg of caffeine and 200mg of l-theanine before writing.

This combo helps me feel alert and focused for longer. Also, adding l-theanine to the mix is helpful to prevent me from getting jittery or anxious.

I try to avoid more potent nootropics (mostly the ones which require a prescription) for two reasons:

  1. I feel pretty good without them, so I don’t want to risk my overall health.
  2. Even caffeine and l-theanine, which are highly effective, don’t yield such a massive benefit for me. Therefore, I’m not willing to pay the price for a slight gain other substances could provide.

For more information on the caffeine and l-theanine combo, studies like this, this, and this might be useful.

Gwern’s notes on nootropics are also interesting.

Personally, I don't see fish-oil, vitamins, creatine, and Vitamin D as nootropics as their effect is not nearly as pronounced as caffeine and L-theanine.

Furthermore, given its impact in my cognitive performance, I believe I'd have to consider all of my nutrition as a nootropic if I were to include more substances in this category.

Again, it's worth reminding readers that I'm not a doctor or dietitian, and that this is not medical advice.

I also do not endorse and am not responsible for any of the other links included in this post.

Please see this website's health and medical disclaimer.