Why I Stopped Chasing Perfect Sleep
I build weird web things by day, coach baseball in the evenings, and pretend I am a disciplined biohacker somewhere in the cracks between.
For a while I tried to optimise everything about my sleep. HRV, resting heart rate, latency, respiratory rate, temperature, chronotype quizzes. All the toys. All the charts.
The result was not high performance. The result was me, at 01:37, lying awake wondering if blue light from the fridge was destroying my REM.
So I nuked most of it.
These days I track one thing obsessively: REM density before 03:00.
Not total REM. Not total sleep. Specifically: how much REM I can stack in the first half of the night, and whether my sleep architecture has that early REM "hump" that shows up when my brain is actually recovering from deep creative work.
This single metric predicts my deep work output way better than any other number I have tried.
Quick Context: Sleep Architecture Without The Textbook
I am not a sleep scientist. I am a guy with a wearable and an unhealthy interest in my own brain.
Here is the minimal model I actually use as a builder:
- N1/N2: Light sleep. Transition stages. Feels like fake sleep. Necessary, but I do not care about the numbers.
- N3: Deep sleep. Physical repair, glymphatic clean-up, the stuff biohackers write threads about.
- REM: Brain integration time. Emotional processing, memory consolidation, creative problem solving.
Most charts show cycles of ~90 minutes, rotating through light, deep, then REM. That is the textbook story, but real life looks messier. Coffee, stress, late commits, blue light, and my catcher complaining about his hip mobility do not care about sleep textbooks.
So rather than trying to optimise the textbook distribution, I asked a simpler question:
What part of my sleep architecture actually tracks with my ability to think clearly and build hard things?
The One Metric That Actually Mattered
I started exporting data from my wearable into a spreadsheet. Nothing fancy. Just date, total sleep, deep, REM, wake time, and a manual 1–5 rating of how "sharp" I felt for deep work between 09:00 and 12:00.
Then I added one extra column: REM minutes before 03:00.
Why 03:00? Two reasons:
- That is about the midpoint of my normal sleep window if I am in bed at 23:00.
- I noticed my worst coding days usually followed nights where my REM was back-loaded into the second half of the night.
So I ran a basic correlation check. Nothing scientific. Just "eyeball the sheet and see what jumps off the page" level.
This is what happened:
- Total sleep: low correlation with how sharp I felt.
- Total REM: better, but still noisy.
- Deep sleep: mattered for physical fatigue and mood, but not directly for code quality.
- REM before 03:00: scarily tight correlation with my 09:00–12:00 deep work rating.
If I had at least 45 minutes of REM before 03:00, there was about an 80% chance I would give the next morning a 4 or 5 for focus. Below 30 minutes, my odds tanked.
The number that mattered was not "did you sleep 8 hours". It was "did your brain get into a restorative rhythm early, or did you spend the first half of the night tossing in light sleep and fighting cortisol".
Why This Matters For Builders
Developers love the meme that we are night creatures. Code at 02:00. Sleep at 04:00. Fix it with caffeine.
I have done that season. It works when you are 20 and your recovery buffer is infinite. Once you stack responsibilities, deep work becomes fragile.
Most of my real output now comes from a three-hour morning block. No Slack. No meetings. Headphones. Text editor. That block is sacred.
REM before 03:00 is the best early warning signal I have found for whether that block will be worth anything.
If my REM is late and compressed, the morning feels like I am typing through syrup. Git history proves it. More reverts. More "what idiot wrote this" moments, where the idiot was yesterday-me.
When REM loads early, the morning feels like I already processed half the design decisions in my sleep. I sit down and the right abstractions just surface. Fewer tabs. Less thrashing.
How I Actually Track This
Tools matter less than consistency, but specifics help, so here is my actual setup.
Hardware
I use a ring that tracks HR, temperature, and sleep staging. You can use a watch if you prefer. I do not care if it is 100% accurate. I care that the errors are consistent.
The important part is that it gives you a time series of sleep stages, not just "you slept 7h 43m".
Data Flow
- Each morning, the app syncs automatically.
- Once a week, on Sunday, I export the raw CSV for the previous 7 days.
- I load it into a basic spreadsheet in Notion or Google Sheets.
I wrote a tiny script that takes the sleep stage timeline and sums up all REM chunks that fall between sleep onset and 03:00 local time. If you do not want to script, you can approximate this by using the app's hypnogram view and just eyeballing where REM shows up.
Then I log two things:
- REM_pre_3h: Minutes of REM before 03:00.
- Focus_score: 1–5, how usable my 09:00–12:00 block felt the next day.
Takes about 3 minutes per week. I do it with coffee on Sunday while pretending I am not checking GitHub issues.
What Actually Moves Early REM For Me
Here is where this gets practical. Once I had a metric I trusted, I started running simple tests. One variable at a time. One week at a time.
Some things everyone talks about did almost nothing for my REM timing. Other things I thought were harmless completely wrecked it.
1. Late-night coding vs late-night social media
If I am pairing or doing deep coding after 22:00, my early REM usually survives. My brain is tired but "clean". The transition to sleep is slower, but the first REM cycle still shows up where it should.
If I am scrolling social or email after 22:00, my early REM evaporates. Light sleep dominates until 03:00 and REM gets dumped into the morning.
I did not want this to be true. It was annoyingly consistent.
So my rule now is simple: If I am up late, it better be for real work or real humans. No "just checking" anything.
2. Training timing
As a coach, evenings are usually on the field. There are two patterns here:
- Hard training ending at 20:30: early REM intact, sometimes even boosted. I fall asleep a bit faster and see a solid first REM cycle around 90 minutes after sleep onset.
- Hard training ending at 22:30: early REM heavily delayed, especially if I eat a big meal after.
Adjusting everything is not realistic, but I can choose what kind of work I do the morning after late sessions. I do "shallow building" on those days: refactors, tests, docs, content. I avoid greenfield architecture and API design.
3. Last caffeine time
This one is boring, but it mattered.
I moved my caffeine cutoff from 16:00 to 13:00. Nothing fancy, just no coffee after lunch. Within a week, my average REM_pre_3h went from ~32 minutes to ~51 minutes.
The interesting detail: total sleep duration barely changed. Bedtime and wake time were similar. It was the composition of the first half that shifted.
4. Late commits and unresolved problems
I like pushing things to done. That is not always helpful at 23:45.
Nights where I go to bed with a live bug, unresolved deployment, or "just one endpoint left" tend to wreck my early REM. Sleep onset is fine. I feel tired. But my brain keeps chewing on the incomplete task, and REM clusters hard around 05:00 instead of 01:00.
The fix was not "stop working early". That is ideal, but not always realistic.
The fix was a hard shutdown ritual that takes 7–10 minutes:
- Write a tiny devlog entry: what I did, where the code is at, what I will do first tomorrow.
- Leave one very obvious TODO comment in the codebase at the re-entry point.
- Commit if possible, even if the branch is not ready to merge.
Once my brain believes the work is parked, early REM recovers. It is almost comical how sensitive the pattern is to unfinished threads.
What I Ignore Now
Once you pick a primary metric, you also get permission to ignore a lot of noise. Here is what I mostly stopped caring about.
1. Total sleep duration perfection
Do I like 7.5–8 hours? Yes. Do I obsess if I get 6.7? Not anymore.
If REM_pre_3h is healthy, I can have a strong morning on 6.5 hours and a weak one on 8.5 hours. Duration is a constraint, not a performance metric.
2. Deep sleep optimization
Biohackers love deep sleep screenshots. I get it. It is the prettiest metric.
For me as a developer, deep sleep tracks more with body than brain. Great for lifting, running, and not feeling wrecked after practice. Not the best predictor of whether my pull requests will be coherent.
I care about deep sleep, but I do not change my work schedule based on it.
3. Fancy readiness scores
Most wearables give you a single score for "readiness" or "recovery". I think those are fine for athletes or general "how cooked am I" checks.
As a builder, that one number was too blunt. I would have mornings where the app told me I was at 92/100 and I still felt useless at the keyboard, because the early REM block was trash.
I stopped looking. If I wake up and REM_pre_3h is above my personal threshold, it is a green-light day for deep work. Otherwise I throttle scope.
How This Changes My Week As A Developer
I do not schedule work purely based on sleep data, but I use it to avoid stupid mismatches.
1. Planning deep work windows
On Sunday, when I review the last week, I tag days in my calendar as:
- High REM early: good candidate days for heavy thinking tasks.
- Low REM early: better for implementation, polish, and meetings.
I cannot retroactively move meetings, but I can absolutely choose which tasks go into which morning for the upcoming week.
This is how I avoid "wasting" a great brain day on email and a compromised brain day on designing a state machine.
2. Matching side projects to sleep reality
As someone who ships side projects, the temptation is always to treat evenings as bonus time and mornings as recovery.
After tracking REM_pre_3h, I flipped that. Mornings are for new features and hard decisions. Evenings are for CSS tweaks, docs, sending updates, and drilling fundamentals with players.
When I break that rule for multiple days, my early REM collapses and my whole week feels like I am pushing a rock uphill.
How To Steal This Without Becoming A Nerd About It
If you want to try this without turning your life into a quantified-self project, you can copy the basic pattern:
- Use any device that shows sleep stages over time.
- For 2 weeks, each morning, quickly note: "Did I get a REM block in the first half of the night or did it cluster late". Do not overthink it.
- Also rate your first 3–4 hours of work on a 1–5 scale.
If you see the same pattern I did, formalise it into a threshold. Mine is simple: REM before 03:00 < 30 minutes = no ambitious architecture work.
That one rule protects me from my own optimism more than any to-do app I have used.
Why This Works For My Builder Brain
The best thing about tracking a single metric is that it simplifies decisions.
I am not trying to micromanage my biology. I am treating REM_pre_3h as a signal from future-me. "Please do not assign me graph algorithms on this brain."
Developers love to optimise everything except the thing their entire output depends on: whether their brain is actually in shape to think.
I still ship on tired days. Life is not that neat. But I stopped pretending I can brute-force deep work on a scrambled REM pattern.
I treat early REM as part of my architecture, the same way I treat my build pipeline or deployment setup. If the foundations are wrong, everything on top is harder than it needs to be.
So I track it. Obsessively. Then I let it quietly steer what I put on my plate each day.
The result is not perfect sleep. It is fewer stupid coding days. That is enough for me.
Subscribe to my newsletter to get the latest updates and news
Member discussion