Skills healthkit-code-review
Reviews HealthKit code for authorization patterns, query usage, background delivery, and data type handling. Use when reviewing code with import HealthKit, HKHealthStore, HKSampleQuery, HKObserverQuery, or HKQuantityType.
install
source · Clone the upstream repo
git clone https://github.com/openclaw/skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/anderskev/healthkit-code-review" ~/.claude/skills/openclaw-skills-healthkit-code-review && rm -rf "$T"
OpenClaw · Install into ~/.openclaw/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.openclaw/skills && cp -r "$T/skills/anderskev/healthkit-code-review" ~/.openclaw/skills/openclaw-skills-healthkit-code-review && rm -rf "$T"
manifest:
skills/anderskev/healthkit-code-review/SKILL.mdsource content
HealthKit Code Review
Quick Reference
| Issue Type | Reference |
|---|---|
| HKHealthStore, permissions, status checks, privacy | references/authorization.md |
| HKQuery types, predicates, anchored queries, statistics | references/queries.md |
| Background delivery, observer queries, completion handlers | references/background.md |
| HKQuantityType, HKCategoryType, workouts, units | references/data-types.md |
Review Checklist
-
called before any HealthKit operationsHKHealthStore.isHealthDataAvailable() - Authorization requested only for needed data types (minimal permissions)
-
completion handler not misinterpreted as permission grantedrequestAuthorization - No attempt to determine read permission status (privacy by design)
- Query results dispatched to main thread for UI updates
-
used only with bounded predicatesHKObjectQueryNoLimit -
used for aggregations instead of manual summingHKStatisticsQuery - Observer query
always called (usecompletionHandler()
)defer - Background delivery registered in
application(_:didFinishLaunchingWithOptions:) - Background delivery entitlement added (iOS 15+)
- Correct units used for quantity types (e.g.,
for heart rate)count/min - Long-running queries stored as properties and stopped in
deinit
When to Load References
- Reviewing authorization/permissions flow -> authorization.md
- Reviewing HKSampleQuery, HKAnchoredObjectQuery, or predicates -> queries.md
- Reviewing HKObserverQuery or
-> background.mdenableBackgroundDelivery - Reviewing HKQuantityType, HKCategoryType, or HKWorkout -> data-types.md
Review Questions
- Is
checked before creating HKHealthStore?isHealthDataAvailable() - Does the code gracefully handle denied permissions (empty results)?
- Are observer query completion handlers called in all code paths?
- Is work in background handlers minimal (~15 second limit)?
- Are HKQueryAnchors persisted per sample type (not shared)?