health-sleep-analysis

Analyze Apple HealthKit sleep, SpO2, heart rate, and HRV data into visual reports.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/lsongdev/skills --skill health-sleep-analysis-lsongdev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: health-sleep-analysis
Source: https://github.com/lsongdev/skills/tree/main/health-sleep-analysis
Command: npx skills add https://github.com/lsongdev/skills --skill health-sleep-analysis-lsongdev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires matplotlib, numpy, rsvg-convert, and includes scripts (resource) components.

What problem does it solve? Raw Apple HealthKit exports are hard to interpret, making it difficult to understand sleep quality, blood oxygen dips during sleep, and cardiac trends without manual analysis. ## Core Features & Use Cases - Sleep Stage Analysis: Breaks down Deep, REM, Core, and Awake stages with nightly attribution rules and healthy-range benchmarks. - Visual Report Generation: Renders 7-day weekly report cards, 30-day monthly trends, and half-year/full-year long-term trends as SVG/PNG charts via rsvg-convert or matplotlib, localized in Chinese, English, and Japanese. - Cardiac & SpO2 Monitoring: Analyzes resting heart rate, HRV (SDNN), and nightly minimum blood oxygen with clinical reference thresholds, flagging potential sleep apnea indicators. - Use Case: Ask for a weekly sleep report and receive a rendered chart card showing sleep stages, bedtime patterns, and SpO2 minimums, plus a written health analysis in your language. ## Quick Start Ask the assistant to generate a 7-day sleep report from your Apple HealthKit data and it will fetch the data, render the charts, and summarize the findings.

Frequently Asked Questions about health-sleep-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze Apple HealthKit sleep data?▼

Export sleep and blood oxygen samples using the apple-healthkit CLI into JSON files, then run the provided Python scripts to aggregate nightly sleep stages and render visual reports. The scripts handle night attribution, stage mapping, and chart generation automatically.

How to generate a sleep report chart from HealthKit JSON?▼

Fetch sleep and SpO2 samples with apple-healthkit into /tmp files, run sleep_report_data.py to build a summary JSON, then render it with sleep_report_librsvg.py using rsvg-convert. Pass --lang zh, en, or ja to localize all chart text.

What blood oxygen level during sleep is dangerous?▼

SpO2 at or above 95% is normal, 90-94% is low and worth monitoring, and below 90% is dangerous. Frequent drops below 95% or any reading under 90% may indicate obstructive sleep apnea and warrants medical evaluation.

Why does my sleep chart show stale or missing data?▼

The workspace directory has an iSH to iOS sync delay that causes stale reads. Always write raw HealthKit JSON and script outputs to /tmp first, then copy the final PNG files to the workspace only for display.

Why do Chinese or Japanese characters show as boxes in charts?▼

The rendering environment is missing CJK fonts. Install them with apk add font-noto-cjk before running the rsvg-convert or matplotlib rendering scripts so localized chart text displays correctly.

Can the sleep analysis work without an Apple Watch?▼

Sleep stage and SpO2 data require an Apple Watch worn during sleep. Nights with less than one hour of recorded data are automatically filtered out, so missing nights usually mean the watch was not worn.