Setup
On first use, read setup.md for integration guidelines.
When to Use
User wants agents to read Apple Health data for trends, summaries, or SQL analysis. Agent handles export validation, MCP server wiring, and safe query/report flows without exposing private health records.
Architecture
Memory lives in ~/apple-health/. See memory-template.md for setup.
CODEBLOCK0
Quick Reference
Use these files on demand instead of overloading the main instructions.
| Topic | File |
|---|
| Setup process | INLINECODE3 |
| Memory template |
memory-template.md |
| MCP client wiring |
mcp-config.md |
| Query recipes |
query-recipes.md |
| Fallback CLI paths |
fallback-cli.md |
Core Rules
1. Confirm Integration Mode Before Doing Anything
Start by clarifying one of these modes:
- -
csv-export using Apple Health CSV exports and MCP - INLINECODE9 if user is only planning and does not want setup yet
Never imply direct HealthKit API access from terminal agents. This skill works from exported data.
2. Validate Local Export Before MCP Wiring
Require a real export folder before configuration:
- - Must exist locally and be readable
- Must include files matching
HKQuantityTypeIdentifier*.csv, HKCategoryTypeIdentifier*.csv, or INLINECODE12 - Must not be an empty unzip folder
If validation fails, stop and fix data path first.
3. Run Runtime Preflight Before MCP Configuration
Before wiring MCP, verify runtime:
- -
node -v should be an LTS line (18, 20, or 22) - If
npx @neiltron/apple-health-mcp fails with missing duckdb.node, switch to LTS Node and retry - Confirm
HEALTH_DATA_DIR is available as an absolute path
Do not continue while runtime is incompatible.
4. Configure MCP With Explicit Path and Command
Use the MCP server command from
mcp-config.md:
- - Command: INLINECODE18
- Args: INLINECODE19
- Env: INLINECODE20
Never continue with placeholders or relative paths that are not verified.
5. Schema First, Then Queries
First run schema discovery (
health_schema) and map available tables.
Only then run
health_query or
health_report.
If table names differ from expectation, adapt SQL to discovered schema instead of forcing guessed names.
6. Use Date-Bounded Queries By Default
Every analytical query should include time bounds and clear units.
Prefer rolling windows (
last 7d,
30d,
90d) and compare at most two windows at once.
Avoid unbounded full-history scans unless user explicitly asks.
7. Track Data Freshness and Refresh Points
Log last export timestamp in memory and warn when data is stale.
If user needs current-day insights, request a new iPhone export before claiming "latest" trends.
Common Traps
- - Assuming live HealthKit access from CLI agents -> setup fails because only exported data is available
- Using wrong export path in MCP env -> server starts but returns no data
- Running SQL before schema discovery -> queries fail on wrong table names
- Unbounded queries on large exports -> slow analysis and noisy output
- Reporting "today" metrics from stale export -> inaccurate recommendations
- Running MCP package on non-LTS Node -> DuckDB native module errors can break startup
External Endpoints
| Endpoint | Data Sent | Purpose |
|---|
| https://registry.npmjs.org | Package install metadata only | Download MCP server package |
| https://raw.githubusercontent.com |
Public markdown only | Read validated fallback skill docs |
| https://apps.apple.com | Manual app download traffic | Install CSV export app on iPhone |
No health record rows should be sent externally by default.
Security & Privacy
Data that leaves your machine:
- - Package install requests to npm
- Optional app download traffic from App Store
Data that stays local:
- - Apple Health CSV exports
- MCP query outputs and summaries
- Skill memory in INLINECODE27
This skill does NOT:
- - Access iCloud Health data directly
- Bypass Apple permission prompts
- Upload health CSVs unless the user asks for that explicitly
Trust
By using this skill, you rely on third-party tooling (@neiltron/apple-health-mcp and the chosen iPhone export app).
Only install and run if you trust those tools.
Related Skills
Install with
clawhub install <slug> if user confirms:
- -
health - General health guidance boundaries and framing - INLINECODE31 - iOS-specific setup and platform troubleshooting
- INLINECODE32 - Sleep trend interpretation workflows
- INLINECODE33 - Reliable API and integration debugging habits
- INLINECODE34 - HealthKit-side implementation context when app code is involved
Feedback
- - If useful: INLINECODE35
- Stay updated: INLINECODE36
设置
首次使用时,请阅读 setup.md 了解集成指南。
使用时机
用户希望代理读取 Apple Health 数据以获取趋势、摘要或 SQL 分析。代理负责处理导出验证、MCP 服务器连接以及安全的查询/报告流程,不暴露私人健康记录。
架构
数据存储在 ~/apple-health/ 目录下。请参阅 memory-template.md 了解设置方法。
~/apple-health/
|-- memory.md # 状态、客户端集成状态、最新导出路径
|-- integrations.md # 已连接的 MCP 客户端及验证说明
|-- query-log.md # 可复用的 SQL/报告提示及已验证的输出
-- archive/ # 已废弃的路径和旧故障排查记录
快速参考
按需使用这些文件,避免主指令过于臃肿。
memory-template.md |
| MCP 客户端连接 | mcp-config.md |
| 查询方案 | query-recipes.md |
| 备用 CLI 路径 | fallback-cli.md |
核心规则
1. 操作前先确认集成模式
首先明确以下模式之一:
- - csv-export 使用 Apple Health CSV 导出和 MCP
- not-now 用户仅处于规划阶段,暂不进行设置
切勿暗示终端代理可直接访问 HealthKit API。本技能仅基于导出的数据运行。
2. 在连接 MCP 前验证本地导出
配置前需要确认存在真实的导出文件夹:
- - 必须存在于本地且可读取
- 必须包含匹配 HKQuantityTypeIdentifier.csv、HKCategoryTypeIdentifier.csv 或 HKWorkoutActivityType*.csv 的文件
- 不能是空的解压文件夹
如果验证失败,先停止并修复数据路径。
3. 在配置 MCP 前进行运行时预检
在连接 MCP 前,验证运行时环境:
- - node -v 应为 LTS 版本(18、20 或 22)
- 如果 npx @neiltron/apple-health-mcp 因缺少 duckdb.node 而失败,切换到 LTS Node 并重试
- 确认 HEALTHDATADIR 为绝对路径
运行时环境不兼容时不要继续操作。
4. 使用明确的路径和命令配置 MCP
使用 mcp-config.md 中的 MCP 服务器命令:
- - 命令:npx
- 参数:[@neiltron/apple-health-mcp]
- 环境变量:HEALTHDATADIR=/绝对/路径/到/导出文件夹
切勿使用未验证的占位符或相对路径继续操作。
5. 先查结构,再执行查询
首先运行结构发现(health_schema)并映射可用表。
然后才能运行 health
query 或 healthreport。
如果表名与预期不符,根据发现的结构调整 SQL,而不是强行使用猜测的名称。
6. 默认使用带日期范围的查询
每个分析查询都应包含时间范围和明确的单位。
优先使用滚动窗口(最近7天、30天、90天),且每次最多比较两个窗口。
除非用户明确要求,否则避免无限制的全量历史扫描。
7. 跟踪数据新鲜度和刷新点
在记忆中记录最新导出时间戳,并在数据过时时发出警告。
如果用户需要当天的最新洞察,在声称最新趋势前,要求用户从 iPhone 重新导出。
常见陷阱
- - 假设 CLI 代理可直接访问 HealthKit -> 设置失败,因为只有导出的数据可用
- 在 MCP 环境变量中使用错误的导出路径 -> 服务器启动但返回空数据
- 在结构发现前运行 SQL -> 查询因表名错误而失败
- 对大型导出执行无限制查询 -> 分析缓慢且输出杂乱
- 基于过时导出报告今日指标 -> 建议不准确
- 在非 LTS Node 上运行 MCP 包 -> DuckDB 原生模块错误可能导致启动失败
外部端点
| 端点 | 发送的数据 | 用途 |
|---|
| https://registry.npmjs.org | 仅包安装元数据 | 下载 MCP 服务器包 |
| https://raw.githubusercontent.com |
仅公开 Markdown | 读取已验证的备用技能文档 |
| https://apps.apple.com | 手动应用下载流量 | 在 iPhone 上安装 CSV 导出应用 |
默认情况下,不应将任何健康记录行发送到外部。
安全与隐私
离开您设备的数据:
- - 向 npm 发送的包安装请求
- 可选的应用商店下载流量
保留在本地设备的数据:
- - Apple Health CSV 导出文件
- MCP 查询输出和摘要
- ~/apple-health/ 中的技能记忆
本技能不会:
- - 直接访问 iCloud 健康数据
- 绕过 Apple 权限提示
- 上传健康 CSV 文件(除非用户明确要求)
信任
使用本技能意味着您依赖第三方工具(@neiltron/apple-health-mcp 和选定的 iPhone 导出应用)。
仅在您信任这些工具的情况下安装和运行。
相关技能
如果用户确认,使用 clawhub install
安装:
- - health - 通用健康指导边界和框架
- ios - iOS 特定设置和平台故障排查
- sleep - 睡眠趋势解读工作流
- api - 可靠的 API 和集成调试习惯
- swift - 涉及应用代码时的 HealthKit 端实现上下文
反馈
- - 如果觉得有用:clawhub star apple-health
- 保持更新:clawhub sync