公理健康

其他 社区

技能解读

当前原文的自动摘译,尚未人工审校。

快速参考

症状/任务 · 参考 HealthKit 框架模型,HKHealthStore,数据类型,样本与特征数据 · 请参阅 skills/fundamentals.md 功能设置,requestAuthorization,目的字符串,读取不对称性,隐私 · 请参阅skills/authorization-and-privacy.md HKSampleQuery,Swift 并发查询 API,HKStatisticsCollectionQuery,样本写入 · 请参阅skills/queries.md锚定查询、观察者查询、HKDeletedObject、background-delivery权利·参见skills/sync-and-background.md

跨套房路线

这些主题与 HealthKit/WorkoutKit 重叠,但位于不同的套件中: watchOS 演示 特定于手表的锻炼演示(Always On、Smart Stack)、复杂化界面 → 请参阅 axiom-watchos Apple Watch 上的锻炼应用程序结构 → 请参阅 axiom-watchos (skills/platform-basics.md) 并发性

冲突解决

axiom-health 与 axiom-watchos:对于 Apple Watch 上的锻炼应用程序:将 axiom-health 用于 HKWorkoutSession 生命周期、HKLiveWorkoutBuilder、恢复 API、多设备镜像 — 这些是 HealthKit 概念,而不是手表概念 使用 axiom-watchos 进行特定于手表的演示:始终显示、智能堆栈放置、watchOS 后台模式协调 两者都适用于手表本机锻炼应用程序 — 从 axiom-health 开始会话生命周期,然后 axiom-watchos 进行演示

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
通用
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@CharlesWiltgen · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 命令执行
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md


# HealthKit and WorkoutKit

**You MUST use this skill for ANY HealthKit or WorkoutKit development including authorization, data queries, background delivery, workout sessions, planned workouts, wellbeing APIs (State of Mind), Medications, and Health Records.**

## Quick Reference

| Symptom / Task | Reference |
|----------------|-----------|
| HealthKit framework model, `HKHealthStore`, data types, sample vs characteristic data | See `skills/fundamentals.md` |
| Capability setup, `requestAuthorization`, purpose strings, read-asymmetry, privacy | See `skills/authorization-and-privacy.md` |
| `HKSampleQuery`, Swift Concurrency query APIs, `HKStatisticsCollectionQuery`, sample writes | See `skills/queries.md` |
| Anchored queries, observer queries, `HKDeletedObject`, `background-delivery` entitlement | See `skills/sync-and-background.md` |
| `HKWorkoutSession`, `HKLiveWorkoutBuilder`, recovery, multi-device, iOS/iPadOS/watchOS workout tracking | See `skills/workouts.md` |
| Workout zones (heart-rate/power effort bands), live + retrospective `OS27` | See `skills/workouts.md` |
| WorkoutKit custom/planned workouts, scheduling, swimming workouts, previewing | See `skills/workoutkit.md` |
| State of Mind, Medications API, symptom logging, menopausal state, wellbeing APIs `OS27` | See `skills/wellbeing-and-medications.md` |
| Health Records (FHIR), Mobility Health App, motion-based health | See `skills/clinical-and-mobility.md` |

## Cross-Suite Routes

These topics overlap with HealthKit/WorkoutKit but live in separate suites:

#### watchOS presentation
- Watch-specific workout presentation (Always On, Smart Stack), complication surfaces → See axiom-watchos
- Workout app structure on Apple Watch → See axiom-watchos (`skills/platform-basics.md`)

#### Concurrency
- Swift 6 concurrency, actors, Sendable → See axiom-concurrency
- HealthKit queries bridging to Swift Concurrency → `skills/queries.md` is the canonical example

#### SwiftUI
- Charts rendering for health data → See axiom-swiftui
- `@Observable` view models for health data → See axiom-swiftui

#### Data and sync
- General cross-platform sync patterns (CloudKit, GRDB) → See axiom-data
- HealthKit anchored/observer queries as a generalizable sync mechanism → `skills/sync-and-background.md`

#### Security and privacy
- Keychain storage, encryption, data-protection entitlements → See axiom-security

## Conflict Resolution

**axiom-health vs axiom-watchos**: For workout apps on Apple Watch:
1. **Use axiom-health** for `HKWorkoutSession` lifecycle, `HKLiveWorkoutBuilder`, recovery APIs, multi-device mirroring — these are HealthKit concepts, not watch concepts
2. **Use axiom-watchos** for watch-specific presentation: Always On display, Smart Stack placement, watchOS background mode coordination
3. **Both apply** for a watch-native workout app — start with axiom-health for session lifecycle, then axiom-watchos for presentation

**axiom-health vs axiom-concurrency**: For HealthKit query patterns:
1. **Use axiom-health** for which query type to choose and HealthKit-specific gotchas
2. **Use axiom-concurrency** for general Swift 6 actor isolation rules that apply to query callbacks

**axiom-health vs axiom-data**: For change-tracked data synchronization:
1. **Use axiom-health** for `HKAnchoredObjectQuery`, `HKObserverQuery`, `HKDeletedObject`
2. **Use axiom-data** for application-level data sync across devices (CloudKit, GRDB, SwiftData)

## Decision Tree

```dot
digraph health {
    start [label="HealthKit / workout task" shape=ellipse];
    what [label="What area?" shape=diamond];

    start -> what;
    what -> "skills/fundamentals.md" [label="framework basics, data types"];
    what -> "skills/authorization-and-privacy.md" [label="permissions, purpose strings, privacy"];
    what -> "skills/queries.md" [label="reading data, rollups, writes"];
    what -> "skills/sync-and-background.md" [label="change tracking, background delivery"];
    what -> "skills/workouts.md" [label="HKWorkoutSession, live workouts"];
    what -> "skills/workoutkit.md" [label="planned/custom workouts"];
    what -> "skills/wellbeing-and-medications.md" [label="State of Mind, Medications"];
    what -> "skills/clinical-and-mobility.md" [label="Health Records, Mobility"];
    what -> "axiom-watchos" [label="watch-specific presentation"];
    what -> "axiom-concurrency" [label="general actor isolation rules"];
    what -> "axiom-swiftui" [label="Charts, data visualization"];
}
```

## Resources

**WWDC**: 2019-218, 2020-10182, 2020-10184, 2020-10664, 2021-10009, 2021-10287, 2022-10005, 2023-10016, 2023-10023, 2024-10084, 2024-10109, 2025-321, 2025-322

**Docs**: /healthkit, /healthkit/about-the-healthkit-framework, /healthkit/authorizing-access-to-health-data, /healthkit/protecting-user-privacy, /healthkit/reading-data-from-healthkit, /healthkit/running-queries-with-swift-concurrency, /healthkit/executing-anchored-object-queries, /healthkit/executing-observer-queries, /healthkit/hkworkoutsession, /healthkit/hklivewobuilder, /workoutkit, /healthkit/accessing-health-records

**Skills**: axiom-watchos, axiom-concurrency, axiom-swiftui, axiom-data, axiom-security

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。