Spot Patterns in Your Health Data
Build a local dashboard that spots changes in your daily health trends.
Introduction
30 Second Summary
Ian has episodic Graves' disease. After Claude Code tried many models on his Apple Health and WHOOP data, it found that signals treated as false alarms came before his flares.
In this project, you will turn your own health export or an included sample year into a local interactive dashboard. On a year Ian held back, his system would have warned him 3 to 4 weeks earlier.
What You'll Build
The finished dashboard.html lets you check three trends against your normal each day, just as Ian now checks his own app.
By the end of this project, you'll have:
- An interactive health dashboard showing daily dots, a 7-day line, a shaded normal band, and red drift markers for resting heart rate, HRV, or sleep. Its status says All is well or names the drifted number with its start date. This dashboard is not a medical device. A flag means look at this, never you are ill.
- A one-row-per-day table in daily.csv that rebuilds after you replace the export.
- A protected raw-data folder that keeps the export inside health-export/ on your computer. Claude Code's built-in read tools cannot access it directly. Local Python scripts can still process it. Those scripts print only counts, dates, and daily averages.
- Secret Mission: Test alerts against held-back event dates and compare three thresholds.
What do you need?
You need a Claude plan that includes Claude Code, a Mac or Windows PC, and either your own health export or the included 365-day sample year.
Experience running a terminal command is enough. You do not need previous Python or statistics knowledge.
Claude Code sends prompts, model outputs, anything it reads, and anything a script prints to Anthropic.
Before We Start
This checkpoint locks in the purpose of your local personal trend dashboard before any sensitive health data is handled. You are inspecting daily trends to spot changes worth a closer look, without using the dashboard to diagnose a condition.
Install Python and Claude Code
This project needs one verified Python runtime plus one working Claude Code session before any health data enters the workflow.
You will prepare both tools before creating the workspace that holds your local dashboard files. This gives every later script a known environment.
In this step, get ready to:
- Install Python 3.11 or later.
- Set up Claude Code with an eligible Claude plan.
- Prepare the my-health-trends workspace with its required libraries.
Install and verify Python
The scripts in this project require Python 3.11 or later. Checking the installed version now prevents package compatibility problems later.
- Go to the Python downloads page.
macOS
- Run the current macOS installer for Python 3.15.2.
- Select the macOS installer listed for Python 3.15.2 on the downloads page.
- Run the downloaded installer to completion.
- Run Install Certificates.command from /Applications/Python 3.15/.
- Navigate to /Applications/Python 3.15/ in Finder.
- Double-click Install Certificates.command.
- Check the installed Python version in Terminal by running this command:
python3 --version
What does this command do?
The command asks the Python runtime named python3 to print its installed version. The number confirms which runtime later package commands use.
You should see Python 3.11 or later in the output.
Windows
- Install Python 3.15.2 with the Python install manager from python.org or the Microsoft Store.
- Select the Python install manager route for Windows on the downloads page.
- Complete the installation using the default runtime.
- Check the installed Python version in PowerShell by running this command:
python --version
What does this command do?
The command asks the default Windows Python runtime to print its installed version. The number confirms which runtime later package commands use.
You should see Python 3.11 or later in the output.
✔️ I see version 3.11 or higher
Your Python runtime meets the minimum required by pandas 3.1.2.
ⓧ I see an older version
The older runtime cannot support the pinned pandas release used in this project.
- Return to the Python downloads page from above.
- Install Python 3.15.2 using your platform route.
- Repeat your platform's version check above.
ⓧ Command not found
Your command line cannot find a Python runtime yet.
- Return to the Python downloads page from above.
- Install Python 3.15.2 using your platform route.
- Open a new Terminal window on Mac or PowerShell window on Windows.
- Repeat your platform's version check above.
Install and verify Claude Code
Claude Code handles the script-writing work from your command line. Its native installer adds the command that starts an interactive session.
macOS
- Install Claude Code in Terminal by running this command:
curl -fsSL https://claude.ai/install.sh | bash
What does this command do?
This command downloads the official Claude Code installer over HTTPS. It passes the installer to your shell so Claude Code can be added to your account.
You should see the installer complete without an error.
Windows
- Install Claude Code in PowerShell by running this command:
irm https://claude.ai/install.ps1 | iex
What does this command do?
This command downloads the official Claude Code installation script. PowerShell executes that script so Claude Code can be added to your account.
You should see the installer complete without an error.
- Open a new Terminal window on Mac or PowerShell window on Windows so the installation path reloads.
- Use your operating system's search bar to find Terminal on Mac or PowerShell on Windows.
- Start the matching app from the search results.
- Check the Claude Code installation by running this command:
claude --version
What does this command do?
The command asks the installed Claude Code executable to print its version. A version number proves the new command-line window can find it.
You should see a Claude Code version in the output.
Claude Code command not found?
- Confirm that you opened a new Terminal or PowerShell window after the installation finished.
- Run the read-only installation diagnostics with this command:
claude doctor
The diagnostic checks the installation plus its settings without changing them.
Ask for help with the diagnostic output using Help me fix my Claude Code installation.
Create the workspace and install the libraries
The project workspace keeps generated files separate from everything else on your computer. The raw export gets its own folder before any sensitive data arrives.
The analysis scripts use pandas for daily calculations. The interactive dashboard uses Plotly to produce a local HTML file.
macOS
- Create the project folder structure on your Desktop by running these commands in Terminal:
cd ~/Desktop
mkdir my-health-trends
cd my-health-trends
mkdir health-export
ls
What do these commands do?
- The first command moves your Terminal session to the Desktop.
- The next commands create my-health-trends before moving into it.
- The final commands create health-export before listing the folder contents.
You should see health-export in the output. Terminal remains inside my-health-trends.
Windows
- Create the project folder structure on your Desktop by running these commands in PowerShell:
cd ~/Desktop
mkdir my-health-trends
cd my-health-trends
mkdir health-export
ls
What do these commands do?
- The first command moves your PowerShell session to the Desktop.
- The next commands create my-health-trends before moving into it.
- The final commands create health-export before listing the folder contents.
You should see health-export in the output. PowerShell remains inside my-health-trends.
The next command starts an interactive Claude Code session. It may move to the browser that is already open so you can complete sign-in.
macOS
- Start Claude Code from my-health-trends by running this command in Terminal:
claude
What does this command do?
The command starts Claude Code in the folder where Terminal is currently located. This gives the session project-level context for later file operations.
Windows
- Start Claude Code from my-health-trends by running this command in PowerShell:
claude
What does this command do?
The command starts Claude Code in the folder where PowerShell is currently located. This gives the session project-level context for later file operations.
- Sign in with a Pro, Max, Ultra, Team, Enterprise, or Console account.
- Follow the sign-in prompts shown in the browser that is already open.
- Return to the Claude Code session after authentication completes.
You should see an active Claude Code session for my-health-trends.
Before you send the installation request, do you expect Claude Code to use the same Python runtime that you verified earlier?
- Ask Claude Code to install the pinned libraries by pasting this message:
Install pandas and plotly for the Python on this computer, then tell me the Python, pandas and plotly versions.
What does this prompt do?
Claude Code identifies the Python runtime on your computer before proposing a package-install command. It then checks the three installed versions so you can verify the result.
macOS
- Approve the package-install command only when it targets python3.
- Confirm that the proposed command pins pandas==3.1.2.
- Confirm that the proposed command pins plotly==7.2.0.
- Read the complete proposed command in Claude Code before using the approval choice shown in Terminal.
Windows
- Approve the package-install command only when it targets python.
- Confirm that the proposed command pins pandas==3.1.2.
- Confirm that the proposed command pins plotly==7.2.0.
- Read the complete proposed command in Claude Code before using the approval choice shown in PowerShell.
Claude Code should report Python 3.11 or later. It should also report pandas 3.1.2 plus plotly 7.2.0.
That is the setup locked in. Claude Code is now running inside the workspace with the exact libraries your dashboard needs.
Your tools plus project workspace are ready. Next, you will place one export in health-export/ before blocking Claude Code from reading it directly.
Export Your Data and Lock the Folder
Your analysis tools are ready inside my-health-trends.
This step places realistic input behind a permission boundary that makes Claude Code fail when it tries to read the raw export directly.
You will apply data minimization before any analysis begins. The raw export stays in health-export/ on your computer.
Anything Claude reads or a script prints can be sent to Anthropic. You will keep raw rows out of Claude's direct file reads.
In this step, get ready to:
- Put one real or synthetic export in health-export/.
- Create the project permission rule for the raw export.
- Verify that Claude Code cannot read the raw export directly.
Put one export in the protected folder
Apple Health, WHOOP, Health Connect, plus an existing CSV are alternative routes. Follow one route that matches the data available to you.
This is the point where sensitive data enters the project. You will keep it inside health-export/ without asking Claude to inspect its raw rows.
Apple Health
- Create an Apple Health XML export from the Health app.
- Select Summary in the Health app.
- Tap your picture or initials.
- Tap Export All Health Data.
You should receive an export.zip archive containing health data in XML format.
- Move export.zip to your computer.
- Unzip export.zip on your computer.
You should see apple_health_export/export.xml. This layout comes from user reports.
- Copy export.xml into health-export/.
You should now have health-export/export.xml inside the project.
- Search the extracted folder locally for export.xml if the reported path is different.
- Copy the export.xml file you find into health-export/.
WHOOP
- Create a WHOOP data export.
- Select More in the WHOOP app.
- Select App Settings on iOS.
- Select Data Export.
- Confirm the email address for the export.
- Select Create Export.
The email can take up to 24 hours to arrive, so a wait here does not mean the export failed. Its download link expires after 7 days.
- Download the export from the email within 7 days.
- Copy its CSV files into health-export/.
You should see a CSV named for Physiological Cycles. Keep its exact column names unchanged.
Health Connect or CSV
Health Connect
- Create a scheduled Health Connect export on a device running Android 14 or later.
- Search the device settings for Health Connect.
- Select Manage data.
- Select Backup and restore.
- Select Scheduled export.
- Save Health Connect.zip to a cloud storage provider.
- Copy Health Connect.zip into health-export/.
You should see health-export/Health Connect.zip.
- Use the sample route below if the archive does not contain an obvious CSV.
Any CSV
- Copy one CSV with a date column into health-export/.
You should see the CSV inside health-export/.
- Inspect only the CSV header locally.
Keep the exact header names for the parser prompt in the next step. Do not send raw rows to Claude.
- Use the sample route if you do not have an export by sending this message to Claude Code:
Write make_sample.py. It saves health-export/sample.csv: 365 days from 2026-01-01 with date, resting_hr, hrv_ms and sleep_hours. Resting heart rate around 58, HRV around 55 ms, sleep around 7.2 hours, with normal day-to-day noise. From 2026-10-28 to 2026-11-17 make resting heart rate 8 higher, HRV 15 lower and sleep 1 hour shorter. Run it.
What does this prompt do?
Claude writes a local Python script named make_sample.py. The script generates a fixed year of synthetic daily measurements.
The changed period gives the later dashboard a visible stretch to detect. The script prints only counts plus its first and last dates.
- Approve the write to make_sample.py after confirming that its output path is health-export/sample.csv.
- Review the proposed file preview in Claude Code.
- Use the on-screen option that grants the requested file write.
- Approve the script run after confirming that its print statements contain only counts plus dates.
- Review the proposed Python command in Claude Code.
- Use the on-screen option that grants this run.
You should see Days: 365, First date: 2026-01-01, plus Last date: 2026-12-31.
The sample route now has make_sample.py plus health-export/sample.csv.
If you used the sample route, compare the generated script with the reference when you want a line-by-line check.
✔️ Awesome, I've got everything!
Your sample covers 365 days from 2026-01-01 through 2026-12-31.
ⓧ I'd like to double check the full code
Compare your generated make_sample.py with this sample-route reference.
import csv
import math
from datetime import date, timedelta
from pathlib import Path
OUTPUT = Path("health-export/sample.csv")
START = date(2026, 1, 1)
END = date(2026, 12, 31)
DRIFT_START = date(2026, 10, 28)
DRIFT_END = date(2026, 11, 17)
OUTPUT.parent.mkdir(parents=True, exist_ok=True)
rows = []
current = START
index = 0
while current <= END:
resting_hr = 58 + 0.7 * math.sin(2 * math.pi * index / 9) + 0.4 * math.cos(2 * math.pi * index / 17)
hrv_ms = 55 + 1.6 * math.sin(2 * math.pi * index / 11) + 0.8 * math.cos(2 * math.pi * index / 23)
sleep_hours = 7.2 + 0.18 * math.sin(2 * math.pi * index / 8) + 0.12 * math.cos(2 * math.pi * index / 19)
if DRIFT_START <= current <= DRIFT_END:
resting_hr += 8
hrv_ms -= 15
sleep_hours -= 1
rows.append(
{
"date": current.isoformat(),
"resting_hr": round(resting_hr, 2),
"hrv_ms": round(hrv_ms, 2),
"sleep_hours": round(sleep_hours, 2),
}
)
current += timedelta(days=1)
index += 1
with OUTPUT.open("w", newline="", encoding="utf-8") as file:
writer = csv.DictWriter(file, fieldnames=["date", "resting_hr", "hrv_ms", "sleep_hours"])
writer.writeheader()
writer.writerows(rows)
print(f"Days: {len(rows)}")
print(f"First date: {rows[0]['date']}")
print(f"Last date: {rows[-1]['date']}")
Add the project permission rule
Claude Code checks project deny rules before its other permission rules. The raw folder rule blocks Claude's built-in file reader while leaving the local source file available to your later scripts.
- Ask Claude Code to create the permission file by sending this message:
Create .claude/settings.json in this folder with a permissions deny rule for Read(./health-export/**).
What does this prompt do?
Claude creates .claude/settings.json inside my-health-trends. The deny array targets every path beneath health-export/.
The rule applies to Claude Code's built-in Read tool. It does not create an operating-system sandbox around the folder.
- Approve the write to .claude/settings.json after confirming that its deny array contains Read(./health-export/**).
- Review the proposed settings file in Claude Code.
- Use the on-screen option that grants the requested settings-file write.
You should now have .claude/settings.json inside my-health-trends.
Compare the permission file with the complete reference before loading it.
✔️ Awesome, I've got everything!
Your deny array contains the exact raw-export rule.
ⓧ I'd like to double check the full code
Your complete .claude/settings.json file should match this reference.
{
"permissions": {
"deny": [
"Read(./health-export/**)"
]
}
}
The project rule loads when Claude Code starts. Restarting the session gives the next test a clean permission state.
- Leave the current Claude Code session by entering:
/exit
What does this command do?
The command closes the current interactive Claude Code session. Your terminal remains inside my-health-trends.
You should return to the Terminal prompt on Mac or the PowerShell prompt on Windows.
- Restart Claude Code from my-health-trends by running this command:
claude
What does this command do?
The command starts a new interactive Claude Code session from the current folder. The new session loads the project permission rule.
You should see a fresh Claude Code session running from my-health-trends.
Trigger the blocked read
The final check asks Claude to use its own file-reading capability against the protected folder. A blocked response proves the project rule is active.
Before you send the next message, do you think Claude Code can show a raw line after the project rule has loaded?
- Test the permission boundary by sending this exact message:
Show me the first 5 lines of any file in health-export.
What does this prompt do?
The request directly tests whether Claude's built-in Read tool can reach health-export/. It does not ask a local script to open the file.
Claude Code should report that it does not have permission to read the file. You should not see any raw export lines.
That blocked read is the result you wanted. Your raw input is present while Claude's direct file access stops at the folder boundary.
Claude showed raw lines?
- Ask Claude Code to inspect only the project permission file with this message:
Show me .claude/settings.json. If its deny rule is not exactly Read(./health-export/**), correct it to that exact rule.
This checks the non-sensitive settings file. It corrects only the raw-folder rule when the stored path is wrong.
- Approve the settings correction only if the proposed rule is Read(./health-export/**).
- Repeat the exit plus restart actions above after a correction.
- Retry the permission test by sending this exact message:
Show me the first 5 lines of any file in health-export.
This repeats the direct-read test after the corrected rule has loaded.
Use this guided check if the folder still opens:
Your export is in place behind a tested permission rule. Next up, you will transform it locally into one safe row per day.
Turn Your Export Into One Row Per Day
Your raw export is now protected from Claude Code's built-in Read tool. The next job is to turn its useful signals into a smaller table that the dashboard can use.
This step applies Daily Aggregation through a local Python parser. The parser prints only counts, dates, and daily averages.
In this step, get ready to:
- Create a route-specific parser named make_daily.py.
- Run the parser to create daily.csv.
- Review the last seven daily averages.
Ask Claude to write make_daily.py
Each export route stores the same health measures in a different structure. Your route-specific prompt tells Claude which local format the parser must handle.
- Use the tab that matches the export already stored in health-export/.
Apple Health
The Apple Health route processes the XML file incrementally because the export can be large.
- Send Claude Code this message:
Write make_daily.py. It reads health-export/export.xml with xml.etree.ElementTree.iterparse, because the file can be very large. Keep HKQuantityTypeIdentifierRestingHeartRate, HKQuantityTypeIdentifierHeartRateVariabilitySDNN and HKCategoryTypeIdentifierSleepAnalysis asleep records, and save daily.csv with date, resting_hr (daily mean), hrv_ms (daily mean) and sleep_hours (sleep ending that morning). Print only the number of days, the first and last date, and how many days have each value. Never print raw rows.
What does this prompt do?
Claude writes an incremental XML parser for the three named health records. The parser aggregates the records before saving daily.csv.
Its output reveals only counts and date summaries. Raw health rows stay out of the terminal output.
- Approve the write to make_daily.py after confirming that its print statements contain only counts and date summaries.
Claude should report that it created make_daily.py in my-health-trends.
WHOOP
The WHOOP route depends on the exact headers you inspected locally. Claude must not guess those headers.
- Replace each bracketed item in the message below with its matching header from your local CSV.
- Send Claude Code the completed message:
Write make_daily.py. It reads the Physiological Cycles CSV in health-export. Use [date column] for date, [resting heart rate column] for resting_hr, [HRV column] for hrv_ms and [sleep column] for sleep_hours. Do not guess or print column names. Save daily.csv with one row per day. Print only the number of days, the first and last date, and how many days have each value. Never print raw rows.
What does this prompt do?
Claude maps your locally inspected headers to the four required fields. It then writes one daily record for each date.
The parser prints counts and dates after processing. It never prints the source rows.
- Approve the write to make_daily.py after confirming that its print statements contain only counts and date summaries.
Claude should report that it created make_daily.py with your exact header mapping.
CSV or Sample
Sample
The sample route copies the four fixed fields into a one-row-per-day table. This route produces the reference implementation for this project.
- Send Claude Code this message:
Write make_daily.py. It reads health-export/sample.csv and saves daily.csv with one row per day: date, resting_hr, hrv_ms and sleep_hours. Print only the number of days, the first and last date, and how many days have each value. Never print raw rows.
What does this prompt do?
Claude writes a parser that reads the four fixed sample columns. It saves those values under the required daily.csv header.
The parser reports only the record count and date range. Those summaries let you verify the transformation without printing raw rows.
- Approve the write to make_daily.py after confirming that its print statements contain only counts and date summaries.
Claude should report that it created make_daily.py for health-export/sample.csv.
Health Connect or Another CSV
The Health Connect route uses an obvious CSV from the export. Use the sample route if the contained format is unclear.
- Replace each bracketed item in the message below with its matching header from your local CSV.
- Send Claude Code the completed message:
Write make_daily.py. It reads the CSV in health-export. Use [date column] for date, [resting heart rate column] for resting_hr, [HRV column] for hrv_ms and [sleep column] for sleep_hours. Do not guess or print column names. Save daily.csv with one row per day. Print only the number of days, the first and last date, and how many days have each value. Never print raw rows.
What does this prompt do?
Claude maps your locally inspected CSV headers to the four required fields. It aggregates repeated dates into one daily record where needed.
The parser prints only counts and date summaries. The source rows remain inside health-export/.
- Approve the write to make_daily.py after confirming that its print statements contain only counts and date summaries.
Claude should report that it created make_daily.py with your exact CSV header mapping.
If you chose the sample route, use this check to compare Claude's file with the reference implementation.
✔️ I'll try it first
Your route-specific make_daily.py is ready for its first run.
ⓧ Let me check my work
The sample route should match this complete make_daily.py file.
import csv
from pathlib import Path
SOURCE = Path("health-export/sample.csv")
OUTPUT = Path("daily.csv")
FIELDS = ["date", "resting_hr", "hrv_ms", "sleep_hours"]
with SOURCE.open("r", newline="", encoding="utf-8") as source_file:
reader = csv.DictReader(source_file)
rows = [{field: row.get(field, "") for field in FIELDS} for row in reader]
with OUTPUT.open("w", newline="", encoding="utf-8") as output_file:
writer = csv.DictWriter(output_file, fieldnames=FIELDS)
writer.writeheader()
writer.writerows(rows)
print(f"Days: {len(rows)}")
print(f"First date: {rows[0]['date']}")
print(f"Last date: {rows[-1]['date']}")
for field in FIELDS[1:]:
count = sum(1 for row in rows if row[field] != "")
print(f"Days with {field}: {count}")
Run the local parser
The project now combines Permission Rules with Data Minimization. The local subprocess can open the export even though Claude Code's built-in Read tool remains blocked.
- Ask Claude Code to execute the parser by sending this message:
Run make_daily.py.
What does this prompt do?
Claude proposes the operating-system command that runs make_daily.py as a local Python process. That process reads the selected export and writes daily.csv.
The deny rule still blocks Claude's own file-reading tool. It does not act as an operating-system sandbox for the Python subprocess.
macOS
- Approve the run after confirming that Claude proposes python3 make_daily.py.
Windows
- Approve the run after confirming that Claude proposes python make_daily.py.
You should see the number of days followed by the first and last date. You should also see a count for each health value.
Parser stopped before creating daily.csv?
- Check that the source filename in make_daily.py matches the file already stored in health-export/.
- Correct the header mapping with the exact names you inspected locally if you selected a CSV route.
- Allow sleep_hours to remain empty when an Apple Health export has no sleep records.
Help me fix my parser without printing raw health rows.
Review only the daily averages
The aggregated file sits outside the denied raw-data folder. Claude Code can read daily.csv, so its contents may become part of the network exchange with Anthropic.
- Ask Claude Code to summarize the latest daily records by sending this message:
Open daily.csv and describe the last 7 days in one line each.
What does this prompt do?
Claude reads the aggregated daily.csv file instead of the blocked export. It summarizes only the final seven daily rows.
This keeps the review focused on daily averages. The raw source remains in health-export/.
- Approve the read of daily.csv.
- Keep the raw export inside health-export/.
You should see seven one-line summaries drawn from daily.csv.
Before you rerun the parser, do you expect its day count and date range to match the first run?
macOS
- Verify daily.csv by running this command in Terminal:
python3 make_daily.py
What does this command do?
This runs the parser again with the Mac Python command. A matching summary proves the transformation is repeatable.
Windows
- Verify daily.csv by running this command in PowerShell:
python make_daily.py
What does this command do?
This runs the parser again with the Windows Python command. A matching summary proves the transformation is repeatable.
On the sample route, you should see Days: 365.
The sample date range should run from First date: 2026-01-01 through Last date: 2026-12-31.
That is the careful handoff complete: daily.csv is ready for charting while the raw export remains behind the Read deny rule.
Your raw export is now a consistent daily table. Next, you will turn those rows into three interactive trend charts.
Build the Dashboard
Your export is now distilled into daily.csv with one minimized row for each day. You can now turn those rows into a picture you can scan.
A daily table hides long stretches that become obvious on a chart.
Pandas calculates a 7-day moving average for each health metric. Plotly draws those results as an interactive local dashboard.
In this step, get ready to:
- Generate a local dashboard from daily.csv.
- Open the interactive dashboard on your computer.
- Inspect one visible stretch outside your normal band.
Generate the first dashboard
The dashboard's rolling baseline ends one week before each tested day. That gap keeps the baseline separate from the stretch it evaluates.
The script only needs the aggregated values in daily.csv. It never needs direct access to health-export/.
- In the Claude Code session from earlier, request the dashboard generator by pasting this exact message:
Write make_dashboard.py. It reads daily.csv and makes dashboard.html with plotly: three charts stacked (resting heart rate, HRV, sleep). Each shows the daily value as dots, the 7-day average as a line, and a shaded band for my normal: the mean plus and minus 2 standard deviations of the 60 days ending a week before each day. Run it.
What does this prompt build?
- The aliases pd, go, pio, and make_subplots connect the script to pandas and Plotly.
- The frame variable holds the rows loaded from daily.csv.
- The METRICS list keeps the three chart columns paired with their display labels.
- The metric loop calculates {metric}_avg7, {metric}_normal, {metric}_std, {metric}_lower, and {metric}_upper for each chart.
- The include_plotlyjs=True setting places Plotly inside the generated HTML file. This lets the local dashboard work as a self-contained page.
Claude proposes make_dashboard.py before requesting permission to save it. The proposed script reads daily.csv and prepares three stacked charts.
- Approve the write to make_dashboard.py after confirming the proposed script reads only daily.csv.
- Review the destination path shown in Claude Code's permission prompt. It should place make_dashboard.py inside my-health-trends.
The HTML export setting should show include_plotlyjs=True before the script runs.
- Approve the local run of make_dashboard.py.
- Review the command shown in Claude Code's permission prompt. It should run the Python interpreter from Step 1 against make_dashboard.py.
Claude creates dashboard.html inside my-health-trends. That file contains the interactive figure.
Open the result
The generated page opens as a local file in the browser you already have running. Its charts remain interactive without a separate web server.
Before you open the dashboard, do you think every date will have a shaded normal band?
macOS
- Open dashboard.html from Terminal by running this command:
open dashboard.html
What does this command do?
The open command hands dashboard.html to macOS. Your existing browser then displays the local file.
Windows
- Open dashboard.html from PowerShell by running this command:
start dashboard.html
What does this command do?
The start command hands dashboard.html to Windows. Your existing browser then displays the local file.
You'll see three interactive charts for resting heart rate, HRV, and sleep. Each chart shows daily dots, a 7-day line, and a shaded normal band.
The first two months may lack a shaded band because the calculation needs 60 earlier days. This is the expected result.
Seeing a blank page?
- Ask Claude Code to rebuild the self-contained HTML file by pasting this message:
Regenerate dashboard.html from make_dashboard.py with include_plotlyjs=True, then tell me whether the file was written successfully.
Claude reruns make_dashboard.py with Plotly embedded in the output. This replaces the blank page with a self-contained dashboard.
- Approve only the local run of make_dashboard.py.
Help me diagnose a blank local Plotly dashboard.
Inspect one visible stretch
This first dashboard leaves unusual stretches for you to notice visually. Your own context gives those stretches meaning.
- Inspect the charts for one stretch where a 7-day line leaves its shaded normal band.
- For your own export, recall what was happening during that week.
On the sample route, you'll see the resting-heart-rate line rise above its band in late October 2026.
Treat the stretch as a prompt to inspect context. Medical conclusions remain outside this dashboard.
That is a real visible win: your daily table now opens as an interactive health trend dashboard. Next, you'll turn the same lagged baseline into consistent drift markers.
Flag Unusual Changes
Your Plotly dashboard now makes unusual stretches visible. You found one by inspecting the charts yourself.
Claude Code turns visual hunting into consistent drift detection against the same lagged baseline.
The alert checks each 7-day average against a normal band built from earlier data. It adds red markers without changing the one-week gap before each tested day.
In this step, get ready to:
- Add the alert rule and medical disclaimer.
- Compare the red markers with the unusual stretch you noticed earlier.
- Test the repeatable dashboard refresh process.
Add the alert rule and disclaimer
The existing normal bands already provide the comparison points. This update turns each sustained move outside those bands into a visible marker.
- Send the alert request in the Claude Code session from earlier by pasting this message:
Add alerts to make_dashboard.py. Flag a day when its 7-day average is more than 2 standard deviations from my normal: resting heart rate above, HRV below, sleep below. Mark flagged days red on each chart. At the top of the page show "All is well" if today isn't flagged, otherwise which numbers have drifted and since when. Under it add: "A personal trend chart, not a medical device. It doesn't diagnose anything. Talk to a doctor about anything that worries you." Print the flagged date ranges, nothing else. Run it.
What does this prompt do?
The prompt adds separate directional checks for each metric. Resting heart rate is flagged above its upper band while HRV and sleep are flagged below their lower bands.
It also requests red chart markers plus a current status line. The fixed disclaimer keeps the result framed as a personal trend chart.
- Approve the edit to make_dashboard.py only after confirming that the 60-day baseline still ends one week before each tested day.
- Approve the run only after confirming that the command rebuilds dashboard.html without printing raw rows.
You should see flagged date ranges only. On the sample route, the first printed range should start within a few days after 2026-10-28.
You have turned the unusual stretch into a repeatable check that runs every time the dashboard is rebuilt.
No flagged ranges from the sample?
- Confirm that THRESHOLD is set to 2.0.
- Confirm that the normal band still uses the delayed series created with series.shift(7).
- Confirm that health-export/sample.csv still contains the fixed drift from 2026-10-28 through 2026-11-17.
Help me compare my alert logic with the expected lagged-baseline behavior.
Use the reference below if you want to compare the complete sample implementation with your updated file.
✔️ Awesome, I've got everything!
Your updated script prints flagged ranges and rebuilds the dashboard with red markers plus the required status content.
ⓧ I'd like to double check the full code
from datetime import date, timedelta
from pathlib import Path
import pandas as pd
import plotly.graph_objects as go
import plotly.io as pio
from plotly.subplots import make_subplots
THRESHOLD = 2.0
DISCLAIMER = "A personal trend chart, not a medical device. It doesn't diagnose anything. Talk to a doctor about anything that worries you."
METRICS = [
("resting_hr", "Resting heart rate", "high"),
("hrv_ms", "HRV", "low"),
("sleep_hours", "Sleep", "low"),
]
frame = pd.read_csv("daily.csv", parse_dates=["date"])
for metric, _, direction in METRICS:
series = frame[metric]
frame[f"{metric}_avg7"] = series.rolling(7, min_periods=7).mean()
delayed = series.shift(7)
frame[f"{metric}_normal"] = delayed.rolling(60, min_periods=60).mean()
frame[f"{metric}_std"] = delayed.rolling(60, min_periods=60).std()
frame[f"{metric}_lower"] = frame[f"{metric}_normal"] - THRESHOLD * frame[f"{metric}_std"]
frame[f"{metric}_upper"] = frame[f"{metric}_normal"] + THRESHOLD * frame[f"{metric}_std"]
if direction == "high":
frame[f"{metric}_flag"] = frame[f"{metric}_avg7"] > frame[f"{metric}_upper"]
else:
frame[f"{metric}_flag"] = frame[f"{metric}_avg7"] < frame[f"{metric}_lower"]
def flagged_ranges(flag_values):
dates = [date.fromisoformat(str(day)[:10]) for day, flagged in zip(frame["date"], flag_values) if bool(flagged)]
if not dates:
return []
ranges = []
start = dates[0]
previous = dates[0]
for current in dates[1:]:
if current != previous + timedelta(days=1):
ranges.append((start, previous))
start = current
previous = current
ranges.append((start, previous))
return ranges
def current_range_start(flag_values):
values = [bool(value) for value in flag_values]
if not values or not values[-1]:
return None
index = len(values) - 1
while index > 0 and values[index - 1]:
index -= 1
return str(frame["date"].iloc[index])[:10]
current_alerts = []
for metric, label, _ in METRICS:
flag_column = frame[f"{metric}_flag"]
for start, end in flagged_ranges(flag_column):
print(f"{label}: {start.isoformat()} to {end.isoformat()}")
start = current_range_start(flag_column)
if start is not None:
current_alerts.append(f"{label} has drifted since {start}")
status = "All is well" if not current_alerts else "; ".join(current_alerts)
figure = make_subplots(rows=3, cols=1, shared_xaxes=True, subplot_titles=[label for _, label, _ in METRICS], vertical_spacing=0.08)
for row_number, (metric, label, _) in enumerate(METRICS, start=1):
figure.add_trace(go.Scatter(x=frame["date"], y=frame[f"{metric}_lower"], mode="lines", line={"width": 0}, showlegend=False, hoverinfo="skip"), row=row_number, col=1)
figure.add_trace(go.Scatter(x=frame["date"], y=frame[f"{metric}_upper"], mode="lines", line={"width": 0}, fill="tonexty", fillcolor="rgba(80, 140, 220, 0.18)", name="Your normal", showlegend=row_number == 1, hoverinfo="skip"), row=row_number, col=1)
figure.add_trace(go.Scatter(x=frame["date"], y=frame[metric], mode="markers", marker={"size": 4, "color": "rgba(70, 70, 70, 0.45)"}, name="Daily value", showlegend=row_number == 1), row=row_number, col=1)
figure.add_trace(go.Scatter(x=frame["date"], y=frame[f"{metric}_avg7"], mode="lines", line={"width": 2, "color": "#2457a6"}, name="7-day average", showlegend=row_number == 1), row=row_number, col=1)
flag_values = frame[f"{metric}_flag"]
flag_x = [day for day, flagged in zip(frame["date"], flag_values) if bool(flagged)]
flag_y = [value for value, flagged in zip(frame[f"{metric}_avg7"], flag_values) if bool(flagged)]
figure.add_trace(go.Scatter(x=flag_x, y=flag_y, mode="markers", marker={"size": 8, "color": "red"}, name="Flagged", showlegend=row_number == 1), row=row_number, col=1)
plot_html = pio.to_html(figure, include_plotlyjs=True, full_html=False, default_height="900px")
html = "<!doctype html><html><head><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'><title>My Health Trends</title><style>body{font-family:system-ui;margin:24px;max-width:1200px}.status{font-size:1.3rem;font-weight:700}.disclaimer{color:#555}</style></head><body>" + f"<p class='status'>{status}</p><p class='disclaimer'>{DISCLAIMER}</p>{plot_html}</body></html>"
Path("dashboard.html").write_text(html, encoding="utf-8")
Reopen and compare
The rebuilt page places the automatic markers on the charts you inspected manually. Comparing both views shows whether the rule catches the same stretch.
Before you reopen the page, do you expect the sample dashboard's latest day to remain flagged?
macOS
- Reopen the updated dashboard.html from the Terminal window you used earlier by running this command:
open dashboard.html
What does this command do?
The command sends the local HTML file to its registered browser. It loads the version that the updated script just rebuilt.
Windows
- Reopen the updated dashboard.html from the PowerShell window you used earlier by running this command:
start dashboard.html
What does this command do?
The command opens the local HTML file through its registered file association. Your browser loads the dashboard that the script just rebuilt.
On the sample route, you should see red markers around the late-October stretch. The final status should read All is well with the required disclaimer directly underneath.
- Compare the red markers with the stretch where the 7-day line left its normal band in the previous step.
The markers should identify the same unusual stretch. A flag means “look at this”, never “you are ill”.
Refresh it later
The refresh process keeps the section names plus the files daily.csv and dashboard.html stable. A later export can pass through the same local pipeline.
- Replace the matching source inside health-export/ when you have a later export.
Before you test the refresh sequence, do you expect the same source data to reproduce the same flagged ranges?
macOS
- Rebuild the daily table plus the dashboard from the current export by running these commands in the Terminal window from earlier:
python3 make_daily.py
python3 make_dashboard.py
open dashboard.html
What do these commands do?
The first command rebuilds daily.csv from the local export. The second rebuilds dashboard.html before the third opens it.
Windows
- Rebuild the daily table plus the dashboard from the current export by running these commands in the PowerShell window from earlier:
python make_daily.py
python make_dashboard.py
start dashboard.html
What do these commands do?
The first command rebuilds daily.csv from the local export. The second rebuilds dashboard.html before the third opens it.
The terminal should print counts plus dates from make_daily.py followed by flagged ranges from make_dashboard.py. On the sample route, the reopened dashboard should retain its red markers and final All is well status.
Your dashboard can reveal private health values. The validation below asks you to blur them before uploading.
Secret mission
Test Held-Back Events
Test your alerts against event dates that were kept separate from the dashboard. You will compare three thresholds, inspect the early-warning and false-alarm trade-off, then apply one threshold without changing the medical disclaimer.
Clean Up Your Resources
Clean Up Your Resources
Choose whether to keep the project ready for refreshes, pause it by separating the raw export, or delete it completely. There are no cloud infrastructure costs, while future Claude Code use remains part of the eligible Claude plan you already use.
Resources you used:
- The local my-health-trends/ folder. It contains the sensitive health-export/ folder, .claude/settings.json, daily.csv, dashboard.html, events.csv, make_sample.py, make_daily.py, and make_dashboard.py.
- Any source-export or downloaded archive copies you kept outside my-health-trends/.
Keep everything running
No action is needed. Choose this if you want to refresh the dashboard as new health data becomes available.
- Leave my-health-trends/ in place so the outputs, scripts, held-back events, and permission rule stay together.
- Keep health-export/ inside the project only if you are comfortable storing the sensitive source there.
- Retain daily.csv and dashboard.html so you can review the latest aggregated trends without processing the raw export again.
Pause - I'll come back to this later
Pause by separating the sensitive source data from the reusable project outputs. Your self-contained dashboard remains available while the raw export stays in encrypted storage.
- Move health-export/ from my-health-trends/ to an encrypted storage location you control by using Finder on macOS or File Explorer on Windows.
- Keep daily.csv, dashboard.html, events.csv, the scripts, and .claude/settings.json inside my-health-trends/.
- Restore the raw folder as my-health-trends/health-export/ before your next refresh.
Your Deny Rule Stays Ready
The rule in .claude/settings.json remains in the project. It applies to health-export/ again when you restore that folder.
Delete - I don't want to use this again
Deleting my-health-trends/ permanently removes every project file inside it. You stay in control because the next actions only target copies you choose.
macOS
- Copy any output you want to retain to an encrypted location you control.
- Use Finder to locate my-health-trends/ in the location where you created it.
- Delete the entire my-health-trends/ folder through Finder.
- Use Finder to locate any additional source-export or downloaded archive copies from this project.
- Delete every additional copy you no longer need.
- Empty the Trash after confirming that it contains no files you want to keep.
You should no longer find my-health-trends/ or any unwanted source-export copies on your Mac.
Windows
- Copy any output you want to retain to an encrypted location you control.
- Use File Explorer to locate my-health-trends/ in the location where you created it.
- Delete the entire my-health-trends/ folder through File Explorer.
- Use File Explorer to locate any additional source-export or downloaded archive copies from this project.
- Delete every additional copy you no longer need.
- Empty the Recycle Bin after confirming that it contains no files you want to keep.
You should no longer find my-health-trends/ or any unwanted source-export copies on your Windows PC.
Nice Work!
Nice Work!
You did it! You built a local interactive health dashboard that shows daily changes against your normal band.
What you learned:
- Applied Daily Aggregation with Python to create daily.csv with one row per day. The sample route covers 365 days from 2026-01-01 through 2026-12-31.
- Applied Data Minimization by blocking Claude Code from reading health-export/ directly. Local scripts still process the export while printing only counts, dates, and daily averages.
- Built dashboard.html with Plotly to show resting heart rate, HRV, and sleep together. Added Rolling Baseline bands, red drift markers, a current status line, and the required medical disclaimer.
- Secret Mission: Used Held-Back Testing to compare thresholds 1.5, 2, and 2.5 against events.csv. Selected one threshold for make_dashboard.py while keeping the disclaimer unchanged.
Ready to quiz yourself?