# How do I connect Apple Health to Claude Code?

Source: https://healthsql.app/claude-code · Updated 2026-11-30

Install the HealthSQL app on your iPhone, then ask Claude Code to set up the Mac side: it runs `curl -fsSL https://healthsql.app/install | sh` and can then query your Health data with `healthsql query`. To have the same data as MCP tools in every session, it also runs `healthsql connect claude-code`.

HealthSQL is an iPhone app and a command-line tool that copy your whole Apple Health record into a local SQLite database on your computer, so AI agents can query it with SQL or MCP. Claude Code reads a SQLite database on your Mac; nothing goes through a third-party server.

## Let Claude Code do the setup

Install the iPhone app and let it finish its first export ([setup, step 1](https://healthsql.app/setup#1-install-the-iphone-app)). Then paste this into Claude Code:

```text
Set up HealthSQL on this computer so you can read my Apple Health data. Follow https://healthsql.app/agents.md and tell me what my record covers when you are done.
```

[agents.md](https://healthsql.app/agents.md) is written for an agent. Claude Code checks with you that the iPhone part is done, installs the command, reads what `healthsql setup` reports, can register itself over MCP, and ends with the dates your record covers, when the phone last synced, and a few facts from your last week. If something is wrong, it tells you the one thing to do.

## Shell or MCP

Claude Code can use your Health data both ways. Pick one; both read the same database.

| | Shell | MCP |
|---|---|---|
| How Claude reads it | Runs `healthsql` and `healthsql query "..."` with its shell tool | Calls `health_overview` and `health_query` |
| Setup | Nothing after the install | `healthsql connect claude-code` (once) |
| Best for | Scripts, files and charts: Claude can pipe rows into Python or save them | Having the tools in every session and every project, with no command to discover |

`healthsql connect claude-code` runs this, which you can also run yourself:

```sh
claude mcp add --scope user healthsql -- ~/.local/bin/healthsql mcp
```

`--scope user` makes it available in every project. Start a new Claude Code session to load it.

## If macOS blocks iCloud Drive

The first time, macOS may keep the app that runs Claude Code (Terminal, iTerm, VS Code or another) out of iCloud Drive. The command then says:

> This program may not read iCloud Drive. Allow it in System Settings, Privacy & Security, Files and Folders (or Full Disk Access), for the app that runs this command. Then run it again.

Allow iCloud Drive for that app in System Settings, Privacy & Security, Files and Folders, and run the command again. Every other message and its fix: [troubleshooting](https://healthsql.app/setup#troubleshooting).

## Prompts to try

- "Use healthsql. Compare my average resting heart rate in October and November."
- "From my workouts, write a weekly training log for the last two months to training.md."
- "Plot my sleep for the last 60 nights with matplotlib and save it as sleep.png."
- "Find the days my HRV was lowest this year. What did I do the day before?"
- "How fresh is my Health data?"

Claude reads daily numbers from the `daily` view, which holds Apple Health's own totals. The rules it follows are in the [schema reference](https://healthsql.app/docs/schema#rules-for-agents).

## Questions

### Does Claude Code have Apple Health built in?

No. As of November 2026, Anthropic's Apple Health connection works only in the Claude iPhone app ([Anthropic help page](https://support.claude.com/en/articles/11869619-use-claude-with-ios-apps)). Claude Code reads Health data through a tool on your Mac, such as HealthSQL. More: [Claude and Apple Health](https://healthsql.app/claude).

### Does it work when Claude Code runs on another machine?

Only where the database is. `healthsql` reads the files iCloud Drive brings to your Mac, so Claude Code must run on that Mac.

### How fresh is the data Claude sees?

As fresh as the iPhone's last export. Every answer carries `phone_synced`, and Claude Code can tell you the time. If the phone has not exported for more than 3 days, the answer also has a `problem` line.

### Does it work with Codex too?

Yes: `healthsql connect codex`. Any agent with a shell can also run `healthsql` directly.
