healthkit

Integrate HealthKit to read, write, and observe health and workout data.

4|1|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill healthkit-autisticaf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: healthkit
Source: https://github.com/AutisticAF/claude-code-apple-dev-plugin/tree/main/skills/healthkit
Command: npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill healthkit-autisticaf

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Integrates HealthKit patterns and best practices to reliably read, write, observe, and display health and workout data while handling authorization, entitlements, and background delivery constraints.

Core Features & Use Cases

  • Authorization & Entitlements: Guidance for requesting NSHealthShareUsageDescription / NSHealthUpdateUsageDescription and enabling HealthKit capabilities and background delivery.
  • Reading & Aggregation: Recipes for one-time reads, aggregated statistics, time-bucketed collections, and incremental sync with anchored queries.
  • Real-time & Background: Use HKObserverQuery, enableBackgroundDelivery, and persist anchors to support background updates and efficient incremental sync.
  • Workout Support: Patterns for HKWorkoutSession, HKWorkoutBuilder, and HKLiveWorkoutBuilder to build, collect, and save workouts on watchOS, plus HealthKit UI patterns like Activity Ring integration.
  • Use Case: Build an iOS/watchOS fitness feature that requests minimal permissions, streams live heart rate during workouts, persists anchors for sync, and displays activity summaries.

Quick Start

Use the healthkit skill to generate Swift code that requests authorization for steps and heart rate, enables background delivery, and fetches the latest heart rate samples.

Frequently Asked Questions about healthkit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I request HealthKit authorization for reading and writing health data in iOS?

To request HealthKit authorization, configure the NSHealthShareUsageDescription and NSHealthUpdateUsageDescription entitlements, verify HKHealthStore availability, and execute read/write permission requests for specific health data types.

How does background delivery work for HealthKit observer queries?

Background delivery works by setting up HKObserverQuery, calling enableBackgroundDelivery for specific data types, and persisting anchors to support efficient incremental sync when the app receives background updates.

What is the best way to sync incremental health data changes using anchored queries?

The best way to sync incremental health data is using HKAnchoredObjectQuery with anchor persistence, which fetches only newly added samples since the last sync anchor to efficiently update your local data store.

Can I track live workout sessions and stream heart rate data on watchOS?

Yes, you can track live workouts on watchOS using HKWorkoutSession and HKLiveWorkoutBuilder to build, collect, and save workout data while streaming real-time heart rate samples during active fitness sessions.

How do I query aggregated health statistics over a time period using HealthKit?

You query aggregated health statistics using HKStatisticsCollectionQuery to perform time-bucketed collections, which calculates grouped mathematical results like averages and sums across specified time intervals.

Why is my HealthKit query returning empty results after authorization?

HealthKit queries return empty results when HKHealthStore is unavailable, authorization is incomplete, or the query predicates restrict the time scope too narrowly for the requested health sample data types.