Data & analysis

sleep-debt-calculator

Try it

Track sleep vs optimal, calculate accumulated sleep debt, and suggest evidence-based recovery schedules. Chronotype detection, quality-weighted sleep tracking, ASCII charts, and caffeine/alcohol impact monitoring.

What it does

Track sleep vs optimal, calculate accumulated sleep debt, and suggest evidence-based recovery schedules. Chronotype detection, quality-weighted sleep tracking, ASCII charts, and caffeine/alcohol impact monitoring.

The skill document

Sleep Debt Calculator

A standalone command-line tool for tracking sleep, calculating accumulated sleep debt against age-based recommendations, and generating personalized recovery schedules. Pure Python (stdlib only) with a JSON file database.

Quick Start

# Set up your profile (age)
python3 scripts/sleep_debt.py init

# Log last night's sleep: bedtime wake quality notes
python3 scripts/sleep_debt.py log 23:30 07:15 4 "slept well, coffee at 3pm"

# See your debt
python3 scripts/sleep_debt.py debt

# How long to recover at 8.5h/night?
python3 scripts/sleep_debt.py recovery 8.5

Commands

CommandDescription
initCreate your profile (enter age for optimal calculation)
log [quality 1-5] [notes]Record a sleep session
debtShow current accumulated sleep debt
recovery Calculate days to recover at given nightly hours
optimalShow your personal optimal sleep based on age
streakShow your logging consistency streak
report [week|month]Weekly or monthly summary with mini-chart
scheduleSuggest optimal bedtime tonight to minimize debt
chronotypeDetect early bird vs night owl from patterns
chart [days]ASCII chart of sleep duration with optimal line

How It Works

Sleep Debt Calculation

Sleep debt is the cumulative gap between your effective sleep and your age-based optimal sleep. Effective sleep is duration weighted by quality: 6 hours of excellent sleep counts more than 8 hours of poor sleep.

Quality-Weighted Sleep

Each sleep entry is weighted by quality (1-5):

  • 5 (excellent): 100% restorative
  • 4 (good): 92%
  • 3 (average): 80%
  • 2 (poor): 65%
  • 1 (terrible): 45%

Chronotype Detection

Your average bedtime over the past 14 nights determines your chronotype:

  • Before 22:00 → Early Bird
  • 22:00–23:30 → Balanced
  • 23:30–00:30 → Night Owl
  • After 00:30 → Extreme Night Owl

Substance Impact Tracking

Notes mentioning caffeine or alcohol are flagged and correlated with quality in reports.

Database

Sleep data is stored in ~/.sleep_debt.json. To start fresh, delete this file.

References

  • Sleep Science Basics
  • Recovery Strategies

License

MIT © Denis Voronin

Related skills

Help users improve sleep quality through hygiene practices, environment optimization, relaxation techniques, and sleep tracking guidance

15 installs

Predict when a person's brain works best from their sleep, using the WhenPeak performance-intelligence API, and turn it into concrete scheduling advice. Use this skill whenever the user asks when to schedule a meeting, interview, exam, presentation, deep-work block, or any important task; asks about their energy, focus, alertness, productivity timing, "peak hours", post-lunch dip, or chronotype; mentions how last night's sleep will affect today; asks how to prepare for a dated event or shift their body clock for travel or an earlier start; or asks for a daily plan built around their performance curve, even if they never say the word "WhenPeak".

2 installs1 stars

Retired Fulcra sleep-analysis skill. Route new work to fulcra-context and keep all sleep, biometric, calendar, and location reads explicit, bounded, and user...

20 installs6 stars

Smart water intake tracking based on body weight, weather, and activity level. Calculates personalized hydration targets, adjusts for caffeine and alcohol consumption, tracks streaks with gamification, generates hourly drinking schedule, and provides hydration education with urine color chart reference.

Track symptoms over time and generate doctor-ready timelines. Correlates symptoms with food, weather, medication, activity, sleep, and stress. Detects patterns, flare-ups, and produces concise clinical reports.