sleep

Coaches sleep with quantified protocols: insomnia CBT-I, jet lag light timing, shift work anchors, caffeine and melatonin cutoffs. Use when the user cannot fall asleep or stay asle…

Iván

@ivangdavila

Install

$ openclaw skills install @ivangdavila/sleep

Operational sleep coaching: triage the complaint, run the protocol with numbers, route red flags to a clinician instead of coaching past them. Advise mode only: guide the human, never touch their medication. Diary, trip plans, and preferences persist in ~/Clawic/data/sleep/ (see setup.md on first use, memory-template.md for the file format; created only when the user starts a protocol). If you have data at an old location (~/sleep/ or ~/clawic/sleep/), move it to ~/Clawic/data/sleep/.

When To Use

  • User reports trouble falling asleep, 3am waking, early waking, or daytime tiredness.
  • Trip planning across time zones: build the light and melatonin schedule before departure.
  • Scheduling questions touching sleep: nap timing, caffeine cutoff, workout placement, chronotype.
  • Night shifts or rotating schedules: damage-control plan, not adaptation fantasies.
  • Nightmares, sleep paralysis, sleepwalking, snoring partner, tracker data, or sleep during pregnancy, new parenthood, menopause, or past 65.
  • Not for diagnosing sleep disorders: snoring with gasps, dream enactment, sleep attacks go to a clinician (→ Red Flags). Not for dream journaling (dreams skill).

Quick Reference

SituationPlay
Bad sleep < 3 months, tied to a stressorAcute: hold wake time, ban naps and early bedtimes, wait it out (→ insomnia.md)
Bad sleep ≥ 3 nights/week for ≥ 3 monthsChronic insomnia (ICSD-3): run CBT-I lite (→ insomnia.md)
Loud snoring + witnessed pauses + sleepy daysStop coaching, refer for a sleep study (→ Red Flags)
Cannot fall asleep before 2-3am but sleeps fine when free-runningDelayed phase, not insomnia — restriction is the wrong tool (→ circadian.md)
Waking 4-5am done sleeping, often age 60+Advanced phase vs mood — screen both (→ circadian.md)
Crossing ≥ 3 zones AND ≥ 3 nights thereAdapt: compute Tmin, schedule light by direction (→ jetlag.md)
Crossing < 3 zones OR < 3 nights thereRule of 3: stay on home time, book meetings in the overlap window
Night or rotating shiftsAnchor sleep + commute light control (→ shiftwork.md)
"Should I nap?"10-20 min, finished ≥ 8 h before bedtime; never during an insomnia protocol (→ performance.md)
Big day after a bad night, or an unavoidable all-nighterDamage control: nap math, caffeine timing, no-drive line (→ performance.md)
Tracker score bad, user feels fineTrust daytime function; stage data is noise (→ trackers.md)
"What supplement helps?"Melatonin 0.5 mg timed for phase shift; everything else is weak (→ substances.md)
Nightmares, sleep paralysis, sleepwalking, night terrorsIdentify by timing and recall, treat or refer (→ parasomnias.md)
Teen, pregnant, new parent, menopause, 65+Base protocols carry modifiers (→ populations.md)
Room too hot, bright, loud; partner snores; kids or pets in bedFix the environment before blaming the sleeper (→ environment.md)
Weekend "catch-up" sleepCap wake-time drift at 1 h; 2 h drift = social jet lag and a Monday relapse
Any other sleep complaintStart the 7-day diary in ~/Clawic/data/sleep/diary.md; no intervention before data

Depth on demand: insomnia.md full CBT-I lite, 3am playbook, relapse plan · jetlag.md direction math, worked trip tables, pre-flight shifting · shiftwork.md anchors, rotation design, first-night survival · circadian.md night owls, larks, DSPS, light therapy · environment.md bedroom, noise, partners · substances.md every cutoff and dose · trackers.md what to read, what to ignore · parasomnias.md nightmares to sleepwalking · populations.md life stages · performance.md naps, debt, all-nighters.

Core Rules

  1. Wake Anchor: one fixed wake time ±30 min, 7 days/week; bedtime floats with sleepiness. Highest-leverage single change; check that weekend wake stays within 1 h of weekday wake.
  2. Judge sleep by daytime function, not hours. Adult range is 7-9 h (consensus guidelines), not a universal 8: alert on 6.5 h = that user's number; sleepy in meetings after 8 h = a problem despite the hours.
  3. Triage before advice: every complaint passes the Red Flags table first. Hygiene tips given to an apnea case cost a year of misdirection.
  4. Stimulus control (Bootzin): awake ~20 min by feel (no clock-checking), leave the bed, dim light, boring analog activity, return only when sleepy. Best-evidenced single insomnia technique.
  5. Effort inverts in sleep: "try to sleep more" always backfires. Prescribe the opposite: later bedtime, restricted window, worry scheduled earlier in the evening.
  6. Time substances by half-life, not by feel: caffeine last dose ≥ 8 h before bed, alcohol last drink ≥ 3 h, melatonin 0.5 mg taken 5 h before target bedtime when the goal is shifting the clock.
  7. Light steers the clock and direction depends on timing: light after Tmin advances the clock, before Tmin delays it. Tmin = habitual wake minus 2.5 h (wake 07:00 → Tmin 04:30). Backwards application makes jet lag worse.
  8. One intervention per week, measured against the diary. Stacked changes make results unattributable; the diary is ground truth, not memory of the night.

Red Flags

SignalSuspicionAction
Loud snoring + witnessed breathing pauses or gasp-awakenings + daytime sleepinessObstructive sleep apneaRefer for a sleep study before any protocol
Dozing while driving, or sleep intruding mid-conversationSevere sleepiness (Epworth-range > 10)Refer promptly; advise against driving drowsy now
Acting out dreams: punching, kicking, leaping, mostly age 50+REM behavior disorderNeurologist referral, not urgent but not optional
Evening leg discomfort with urge to move, relieved by movementRestless legsClinician; low ferritin is the common driver
Sudden sleep attacks, knees buckling with laughterNarcolepsy/cataplexySleep specialist
Insomnia + hopeless 3am thoughts, mood collapseDepression presenting as insomniaTreat mood as primary; escalate per user's care setup
New snoring or gasping in pregnancy, morning headaches, rising blood pressurePregnancy apnea / preeclampsia riskPrompt obstetric review, not sleep coaching
Night waking driven by pain, reflux, or breathlessnessMedical driver wearing an insomnia maskTreat the driver first; sleep protocols wait

Anything in this table suspends the protocols in this skill: route to a clinician.

Output Gates

  • Did this complaint pass the Red Flags table before any protocol advice?
  • Does every melatonin mention carry both dose and clock time (0.5 mg, 5 h before target bedtime for phase shifts)?
  • Is prescribed TIB clamped to the floor in insomnia.md and the bedtime phrased as "not before"?
  • Are jet lag light windows derived from Tmin converted to destination clock, not from local sunrise?
  • Am I prescribing exactly one new intervention this week, with the diary as the measure?
  • If the user is a teen, pregnant, postpartum, menopausal, 65+, or on shifts, did I apply the modifiers in populations.md / shiftwork.md?

Configuration

User-dependent variables. Defaults apply until the user states a preference; store them in ~/Clawic/data/sleep/config.yaml.

VariableTypeDefaultEffect
wake_anchortime (HH:MM)noneSeeds every derivation: Tmin = wake_anchor − 2.5 h, earliest bedtime, nap cutoff; unset → derive from a 7-day diary
time_format12h | 24h24hFormats every schedule, worked example, and trip-plan table
unitsmetric | imperialmetricBedroom temperature guidance (16-19 °C vs 60-67 °F) and any other physical figure
trackertext (device name)noneTailors trackers.md guidance to the metrics that device reports; none → coach from the diary only

Preference areas to record as the user reveals them:

  • schedule — work pattern (office hours, shifts, on-call, freelance), fixed commitments; affects anchor placement and every protocol window
  • household — partner schedule, kids, pets, room sharing; affects environment.md plays and stimulus-control feasibility
  • substances — what the user actually uses (caffeine dose and timing, alcohol, THC, prescriptions); affects which cutoffs get surfaced first
  • risk posture — how aggressively to titrate restriction, how firmly to repeat referrals; affects insomnia.md titration and Red Flags delivery
  • reporting — plan format (per-day table vs prose), diary check-in cadence; affects artifacts written to ~/Clawic/data/sleep/

Traps

TrapWhy it failsDo instead
Sleeping in after a bad nightDilutes sleep pressure, delays the clock, seeds the next bad nightSame wake time; earlier sleepiness tonight is the repayment
Earlier bedtime to get more sleepMore time awake in bed conditions bed = frustrationLater bedtime until SE ≥ 90%, then extend by 15 min steps
Weekend catch-up ≥ 2 hSocial jet lag (Roenneberg): Sunday-night insomnia, Monday impairmentCap drift at 1 h; 20-min Saturday nap if needed
Hygiene tips for chronic insomniaHygiene alone shows near-zero effect on chronic cases; it is preventionCBT-I components: restriction + stimulus control
Nightcap for sleepOnset improves, second half fragments≥ 3 h alcohol buffer; treat latency with restriction
10 mg melatonin at lights-out for jet lagWrong dose and wrong hour; sedation misread as adaptation0.5 mg, 5 h before target bedtime, eastward only
Morning sunlight on arrival in Europe from the USLands before body-clock Tmin, delays the clock, worsens the lagSunglasses until converted Tmin, bright light 2-3 h after
Coaching a loud snorer on bedtime routineMisses apnea; months lost while AHI stays highRed Flags first, referral before protocol
Treating a night owl teen as an insomniacDelayed phase + early school start is a clock problem; restriction adds deprivationPhase-advance protocol (circadian.md), not restriction
"Relax and clear your mind"Sleep-effort paradox: monitoring for sleep prevents itStimulus control; paradoxical intention for high performers
Adjudicating tracker deep-sleep deficitsStage data is noise at consumer accuracyRe-anchor on daytime function and the diary

Where Experts Disagree

  • Blue light: photobiology shows real melatonin delay; behavioral trials show content arousal dominates in adults. Teens and severe insomniacs get strict screen cutoffs; average adults get engagement rules (no feeds in bed), not amber glasses.
  • Napping: performance school prescribes it, insomnia school bans it. Sleeps well → nap freely within the ≥ 8 h cutoff; in protocol → no naps until discharged.
  • Melatonin for plain insomnia: trials average ~7 min faster onset; strong effects only for circadian problems. Circadian use yes, nightly-forever use no.
  • Chronotype: performance school schedules life around it, clinical school retrains it. Shift the clock only when the phase conflicts with obligations the user cannot move; otherwise move the obligations (circadian.md).

Related Skills

More Clawic skills, get them at https://clawic.com/skills/sleep (install if the user confirms):

  • fitness — when the lever is training load, overtraining, or workout timing rather than the night itself
  • fasting — when late eating windows or fasting schedules collide with the sleep window
  • plan — when the fix is calendar surgery, moving deep work to the user's alert hours instead of fixing sleep
  • dreams — dream journaling and pattern exploration; nightmare treatment stays here

Feedback

Part of Clawic, the verified skill library. Get this skill: https://clawic.com/skills/sleep.

Related skills

spain

@ivangdavila

Plans Spain travel with local-level picks: named restaurants, regional rules, timing, booking windows, and tourist-trap avoidance. Use when the user plans or books a trip to Spain, builds an itinerary, or asks about Madrid, Barcelona, Sevilla, Granada, Valencia, Bilbao, Málaga, or San Sebastián, the Balearics or Canaries, tapas, paella, pintxos, wine or flamenco, festivals like San Fermín, Fallas, or Semana Santa, walking the Camino de Santiago, beaches, hiking, AVE trains, driving and car rental, SIM cards, safety and pickpockets, or traveling Spain with kids. Not for learning the Spanish language — that is the spanish skill.

0795

Calorie Tracker

@ivangdavila

Tracks calories, macros, and weight trends from meal photos, text logs, and nutrition labels. Use when the user logs a meal or a drink, keeps a food diary, asks how many calories something has, wants a calorie or protein target for a cut, bulk, deficit, or maintenance, asks for their TDEE or maintenance calories, counts macros or carbs, reads a food label, asks whether to eat back exercise calories or workout burn, or asks why the scale is stuck, why they are not losing weight, or why it jumped overnight. Covers TDEE calibration from the user's own logs, restaurant, alcohol, and cheat-day estimates, plateaus and water weight, smart-scale body-fat readings, GLP-1 and medical guardrails, and eating disorder safety. Not for meal planning or recipes.

31.7k

fitness

@ivangdavila

Plans and progresses workout programs — strength, muscle building, cardio, endurance, and general conditioning — with quantified rules. Use when designing a training plan, routine, or split, choosing sets, reps, weights, or heart-rate zones, when a lift, pace, or the scale has plateaued, when sessions were missed or illness, injury, or travel interrupted training, when planning deloads, training at home or with minimal equipment, or reading training logs and wearable readiness data. Not for meal-level nutrition planning or rep-by-rep set logging.

33.3k

Water Tracker

@ivangdavila

Tracks daily water intake from casual mentions and sets hydration targets from weight, exercise, heat, and health context. Use when the user logs a drink ("had a glass", "finished my bottle"), asks how much water they should drink or whether they drink enough, reports thirst, dark urine, dry mouth, cramps, or a headache that could be dehydration, plans fluid or electrolyte replacement for workouts, races, sauna, hiking, flights, or hot weather, or needs rehydration guidance during fever, vomiting, diarrhea, or a hangover, or asks whether tap, bottled, filtered, mineral, or sparkling water is safe or better. Not for meal or calorie logging.

31.5k

bangkok

@ivangdavila

Plans Bangkok trips, relocations, and nomad stays: neighborhoods, visas, costs, transport, street food, and Thai law. Use when choosing where to stay or live in Bangkok, building an itinerary, comparing rents or cost of living, picking a visa (exemption, DTV, retirement, LTR), riding BTS/MRT/Grab or driving, handling Thai taxes on foreign income, avoiding scams and overstay fines, teaching English, finding tech work, setting up a company, buying a condo, choosing schools for kids, or navigating etiquette, festivals, healthcare, nightlife, and shopping. Covers day trips from Bangkok; not for beaches, islands, or other Thai bases — use the thailand skill for those.

0849

Coach Skill

@shiv19

Create personalized triathlon, marathon, and ultra-endurance training plans. Use when athletes ask for training plans, workout schedules, race preparation, or coaching advice. Can sync with Strava to analyze training history, or work from manually provided fitness data. Generates periodized plans with sport-specific workouts, zones, and race-day strategies.

63.3k