Home   Writing   Archive   Feed

How to sleep

Welcome weary traveler…

This is a collection of slightly-less-than-obvious sleep advice that’s actually worked for me.

I had poor sleep for my entire life until figuring out most of the below—the result of which is that I now feel that I have agency over whether or not I sleep well. Which has been life changing.

The basics

Before trying anything new get the basics down

  • your room is cold, dark, and quiet
  • you don’t eat 3+ hours before bed
  • you don’t drink (much) water 2+ hours before bed
  • you limit intake of alcohol and caffeine

What worked for me

In descending order of effect size.

Cognitive Behavioral Therapy for Insomnia (CBTi)

CBTi is the greatest sleep intervention ever created by mankind. Despite its proven efficacy, it’s not nearly as well known or widespread as it should be. It seems to be normally deployed for moderate to severe cases of insomnia, but I think it could potentially be worth doing for all humans, both as a prophylactic and as a sort of “sleep tune-up”. What’s the expected value of getting 10% better sleep for the rest of your life? Seems astronomical1 to me.

I did Sleep Reset’s CBTi program, which was cheaper than doing it with an actual sleep therapist, but more expensive than some of the other free CBTi programs like Night Owl (which seemed less good). While I think there are actually a lot of ways it could be improved, it was also extremely effective for me and I recommend it highly.

There are three key components of CBTi: sleep hygiene, sleep compression, and various cognitive tools such as CBT, gratitude, visualization, etc, that enable better sleep.

Sleep hygiene is basically all of the things that you know you’re supposed to do in order to sleep well but don’t. The biggest pieces for CBTi are: not getting into bed until you’re tired, only using your bed for sleep, getting out of bed if you wake up/can’t fall asleep and doing something else until you’re tired again, and sticking to a regular sleep schedule.

Sleep compression is exactly what it sounds like: a period of self-induced sleep deprivation in order to reset your relationship with your bed, and to resync your circadian rhythm and homeostatic sleep pressure. For the first two weeks of my CBTi program I was only allowed to be in bed from midnight to 6:30 AM. Which meant that in practice I was getting around 6 hours of sleep a night. For me this was hellish, and I only survived by 2-3xing my daily dose of caffeine. Surprisingly, this didn’t seem to alter the effectiveness of the intervention. I was also supposed to continue for longer than two weeks, and then slowly increase my time in bed until I was back to sleeping ~8 hours/night, but in practice I went back to that immediately after the two week period, because I was basically unable to function at work. Suprisingly, this didn’t seem to alter the effectiveness of the intervention either.

One other thing I’ll say about sleep compression: if you’re going to do it, try to actually commit to it 100% for as long as you can. If you only sort of commit you will got the worst of both worlds: weeks of bad sleep without fixing anything at all in the end. During my program I adhered absolutely to my 12-6:30 AM bed allowance during the two weeks I did it. The effect of this, which I began to notice almost immediately after, was that I began naturally waking up at around (or slightly before) 6:30 AM every day. Which brings me to my next point.

Keeping a consistent wake-up time

This is technically (a big) part of CBTi (sleep hygiene) but I gave it it’s own section here because I think it’s so important not just for CBTi, but also for maintaining good sleep long-term.

I used to believe that I should just try to have a consistent bed time, then wake up whenever my body wanted to get up naturally, but years of experience have convinced me that this doesn’t work. My hand-wavey explanation is that waking up is probably a stronger signal to your circadian rhythm than the time you get in bed.

I now set an alarm for 6:30 AM every week day, but naturally wake up 10-15 minutes before it. On weekends I don’t set an alarm, and sometimes sleep in an hour or so, or sometimes don’t.

One big unlock here is always getting out of bed within a minute or so of waking up. It’s hard in the beginning (although I think CBTi might have made it easier for me), but in the long run, very worth it. I’m also a big believer in never using the snooze button, because sleep after hitting it never actually seems useful. Pro-tip: in iOS you can turn off the snooze button functionality!

Yoga Nidra

I set up an automation to play this specific yoga nidra track in my bedroom starting at 10 PM every night, which has become one of my biggest sleep unlocks. Something about having to get ready for bed early in order to be able to show up for this “event” on time so that I don’t miss any of it has made me much less likely to fail prey to the failure mode of staying up late for dumb reasons. Yoga nidra also does a great job of turning my mind off, which in the past was what often kept me up for hours and hours after getting in to bed.

CBTi (strongly) recommends not getting in to bed until you are tired, but I’ve found this works better for me.


Magnesium definitely seems to help me sleep well. I often take ~200 mg of magnesium citrate2 2x/day (usually once in the morning, once an hour or two before bed, or sometimes just 400 mg two hours before bed).

On a recent trip, some friends3 introduced me to magnesium powder as an alternative by making a “tea” of this for us each night. Low n, but I’ve since found it more effective, and a nice ritual. There’s something wizardy about the steamy hiss and fizzle of liberated carbon dioxide as you pour hot water slowly over the carbonate. I often add an herbal tea or a dash of apple cider vinegar (which others have claimed helps with sleep, and also tastes nice) to the mix as well.

Reduced stimulation two hours before bed

I turn off all the lights in my apartment two hours before bed (8 PM), and do light work or read on my couch while waiting in anticipation of my nightly yoga nidra ritual. I ignore the ‘no screens before bed’ rule for the most part, since I think it’s only a medium-good proxy for the thing that actually needs to be avoided—high stimulation, dopamine-inducing activities. Intimacy is an obvious exception here.

I can sleep good

Other things one could try

Things that sort of help

  • having an Eight Sleep—at the very least the super easy sleep tracking has made me care more about my sleep metrics, which has lead directly to better sleep
  • early morning exercise for resetting my sleep cycle, or just waking me up if I had a night of bad sleep; in the latter case intense exercise is often a stronger stimulant than infinite cups of coffee, and allows me to have a much more productive day than I would otherwise
  • a few supplements like kava, apigenin, and (low dose) melatonin4
  • having a protein shake within 30 minutes of waking up
  • being a slightly hungry before bed—this is a feeling I’m working on calibrating and hitting more squarely in the future
  • ketamine? more on this in a future post
  • warm showers just before bed
  • generally eating light and healthy (esp not having fast carbs)
  • imagining deep darkness, seems to help me fall asleep/back asleep more easily

Things I sometimes do that usually help

  • sleeping somewhere rural, near the beach, or in (low elevation) mountains, especially in temperate places where I can leave the window open at night and hear only nature—this has such a large effect size for me that I’ve strongly considered moving out of the city for this reason alone

Things I still want to try which supposedly help

Things that didn’t work for me

  • supplements like ashwaghanda, glycine, theanine, zinc, most others that people recommend
  • completely cutting out caffeine5 doesn’t do much for me—reducing total amount and afternoon intake definitely helps though
  • getting natural or high intensity light within 30 minutes of waking up
  • getting tested for sleep apnea—could work for you though!
  • saunaing a few hours before bed—slight decrease in sleep quality for me, probably from dehydration
  • exercise—I’ve tried a few short and medium term experiments and have never observed differences in sleep quality based on whether or not I exercised that day (I continue to exercise daily though for other obvious reasons though)

Things I haven’t tried and don’t want to

  • prescription sleep drugs6

In summary

My routine

My room is cold, dark and quiet. I rarely drink alcohol, and I stop consuming caffeine after noon. I eat an early dinner (~5-6 PM), and stop eating by 7 PM (except for a small protein shake a bit later some times). I try to drink a lot of water during the day so that I will still feel hydrated when I stop drinking at 8 PM (nocturia is a real cause of insomnia).

Between 7:30 and 8 PM I turn off all the lights in my apartment, light a few candles throughout, and start winding down the evening with light work or reading. Around 9:15 I make magnesium tea, then take a hot shower (I also use a candle as my only light source for this7) while waiting for the tea to cool down. After my shower I sit on the couch and drink my tea and either read or meditate. My bed has started cooling down at 9 PM, and my AC turns on at 9:45 PM.8 At ~9:55 PM I get in bed, and at 10 PM this yoga nidra track begins playing in my room. After 20 minutes the meditation ends, and I usually fall asleep within another ten minutes or less.

At 5:55 AM my bed starts to gently warm up (except on weekends when I have all alarms turned off). At 6:15 the heat turns on in my room. Around 6:20 I usually wake up naturally, but if I haven’t my bed starts to vibrate gently at 6:25, and at 6:30 an alarm goes off (currently this Jocko Willink clip on gratitude and reframing, which I find very helpful if I happen to have gotten a bad night of sleep9). I always get out of bed within a minute of waking up, immediately walk to a coffee shop to grab a coffee, and start working by 6:45 AM.

My new basics

  • room is cold, dark, and quiet
  • don’t eat 3+ hours before bed
  • hydrate well during the day but don’t drink (much) water 2+ hours before bed
  • start a wind down routine that reduces light and other forms of stimulation and relaxes you (e.g. yoga nidra) 2+ hours before bed
  • take magnesium before bed
  • limit intake of alcohol and caffeine
  • always wake up at the same time every day (some leeway on weekends)
  • always get out of bed within one minute of waking up
  • do CBTi

Tactical advice for staying on track

What’s the best way to get back to a good routine if you fall out of the habit? For me, it’s largely about two key pieces: the last three hours before bed, and being extra vigilant about keeping my normal wake-up time.

If I can get my three hour pre-bed time ritual right—no food, light water consumption, lights off, low stimulation—I can usually guarantee a good night of sleep. Which gives me more energy the next day to continue the habit.

And getting up at the same time every day, no matter how late I went to bed, how poorly I slept, or how tired I am, also makes it much easier to revert to good habits. It keeps my circadian rhythm from shifting significantly, and also acts as a natural pendulum—the worse my sleep is one night, the easier it will be to sleep well the following night.

Happy sleeping! 😴


  1. And multiply this across the population and what do you get? CBTi is safe and easy to adminster. What if every high school and college taught a short course on it? What would our world look like if every was 10% better slept? 

  2. I’m skeptical of the claims that different salt forms of magnesium could have major effects on CNS partitioning as some people say. Much more likely is that certain forms are generally more bioavailable than others, which leads to higher total exposure in the body and thus also the brain. And also to relatively less GI exposure, which likely decreases the laxative effects. Presumably this then allows one to take higher doses of magnesium without having to worry about stomach issues, which is probably helpful. Unless of course the beneficial effects of magnesium on sleep are actually driven through the gut-brain axis, which isn’t a totally unreasonable hypothesis. Biology is complicated. [I have not deeply researched any of the preceding.] 

  3. Cissy Hu and Ryan Trafton! 

  4. I take melatonin infrequently, only when I know I’m going to have a hard time falling asleep for some reason, or when I’m trying to reset after jet lag or a few nights of bad sleep. 

  5. I’m a slow caffeine metabolizer, so I expected this to have some sort of effect at least, but AFAICT, after trying this a few times for 1-2 months at a time, it has no major effect. I do want to try again though now that I’ve fixed some other things. 

  6. As someone who makes drugs for a living. Obviously still worth trying if nothing else works. Also Peter Attia recommends low dose trazodone, which seems slightly less bad than other sleep drugs. 

  7. h/t to Michael Lai for this great tip and starting my candle phase! I really love the vibe of walking around my apartment at night with only a candle for light. 

  8. I’m still trying to figure out what the best combination of temperatures is for sleep if both your room and your bed can cool down. What I’ve currently settled on is keeping the AC at ~68 °F and my bed temp between 75 and 80 °F. 

  9. Didn’t get a good night of sleep? *Jocko voice* good