Skip to content
SwiftSkills

HealthKit with AI agents

Enable the HealthKit capability, confirm data is available on the device, and keep a single HKHealthStore. Request read and write permission per data type only when you need it, and set NSHealthShareUsageDescription and NSHealthUpdateUsageDescription or the app will crash. Do not treat a denied read as distinguishable from an empty store, and never use HealthKit data to serve ads.

Last updated:

Apple facts are from "HealthKit", "About the HealthKit framework", "Setting up HealthKit", "Authorizing access to health data" and "Protecting user privacy" on developer.apple.com. Tool facts are from each README. Stars as of 12 Nov 2026.

What Apple documents

  • HealthKit lets apps access and share health and fitness data while maintaining the user’s privacy and control. Data types and units are a predefined list so every app understands what the data means.

  • Before using HealthKit, enable the HealthKit capability, confirm it is available on the current device with isHealthDataAvailable(), create a single long-lived HKHealthStore, then request permission to read and share data.

  • HealthKit requires fine-grain authorization: request permission to both read and share each data type before your app attempts to use it. You don’t need to request every type at once; wait until you need the data.

  • As a privacy protection, the app does not know whether someone granted or denied permission to read data. If they denied it, reads return only samples the app itself saved. People can also grant only a limited window of recent data.

  • Set NSHealthShareUsageDescription for reading and NSHealthUpdateUsageDescription for writing. Apps must include these usage descriptions or they will crash when requesting authorization.

  • Only enable Clinical Health Records if the app actually uses clinical record data; App Review may reject apps that enable the capability without using it. If HealthKit isn’t required for the app to work, remove it from the required device capabilities array so the app can be installed on devices without a HealthKit store.

  • The HealthKit store is encrypted while the device is locked, so background reads may fail; the app can still write, and HealthKit caches those writes until unlock. Do not use information gained through HealthKit for advertising, and do not disclose it to a third party without express permission (and only when they also provide a health or fitness service).

Rules for AGENTS.md

Code

- Use HealthKit (HKHealthStore) for health and fitness data. Do not invent a custom health database or a third-party health SDK unless I ask.
- Call isHealthDataAvailable() before any other HealthKit API. Keep a single long-lived HKHealthStore.
- Request read and write authorization per data type only when that type is needed. Set NSHealthShareUsageDescription and NSHealthUpdateUsageDescription first.
- Never treat an empty read as proof that the user has no data; denied read access looks the same.
- Do not use HealthKit data to serve ads, and do not enable Clinical Health Records unless the app reads clinical records.
- Look up types and method names in Apple's HealthKit docs before writing them.

Step 1: ground the agent in HealthKit docs

Install Apple Docs MCP or Sosumi and ask it to open "Setting up HealthKit" and "Authorizing access to health data".

Step 2: capability, availability, one store

Have the agent enable the HealthKit capability, add the two usage-description keys, call isHealthDataAvailable(), and create one HKHealthStore.

Step 3: request only the types you need

Ask for read and write permission for the types this screen uses, just before first use, not for the entire catalog at launch.

Step 4: check the permission UI and the advertising rules

Run HIG Doctor on the Health permission and data screens. Confirm marketing text and UI make the health or fitness purpose obvious, and that no HealthKit data feeds ads.

Tools compared (5)

ToolBest forAgents (README)Install (README)LicenseStarsLast push
Apple Docs MCP (kimsungwhee)Look up HealthKit types, HKHealthStore and authorization APIsClaude Code, Cursor, VS Code, Windsurfclaude mcp add apple-docs -- npx -y @kimsungwhee/apple-docs-mcp@latestMIT138417 Mar 2026 ⚠
sosumi.ai (NSHipster)Pull Apple HealthKit docs, HIG and WWDC notes as Markdownany MCP hostnpx -y mcp-remote https://sosumi.ai/mcpMIT48911 Nov 2026
ApKI (Gucky)Route the agent to official Apple developer resourcesCodex, Claude Codenpx skills add https://github.com/Gucky/ApKI --skill apkiMIT23 Nov 2026
HIG Doctor (raintree-technology)Audit the permission sheet and Health UI against Apple HIGClaude Code, Cursor, Codexnpx hig-doctor . or npx -y hig-mcpMIT1543 Nov 2026
Apple Platforms 27 Skills (hechen)Current-platform SwiftUI around the Health screensClaude Code, Cursor, Codexnpx skills add hechen/apple-platforms-27-skills --skill '*'MIT227 Sep 2026 ⚠

⚠ = no push in the last 4 weeks.

Which one to pick

  • Official API lookup → Apple Docs MCP or Sosumi.

  • A short route into Apple's current developer resources → ApKI.

  • Permission-sheet and Health UI audit → HIG Doctor.

  • Current-platform SwiftUI around the Health screens → Apple Platforms 27 Skills.

HealthKit authorization is not a privacy manifest and not a location permission. Manifests are in iOS privacy manifests with AI agents. When In Use versus Always location is in iOS Core Location permissions with AI agents.

A prompt that keeps the agent honest

Code

Add HealthKit to this app so I can read step count and save a workout, and nothing else. Enable the capability, add NSHealthShareUsageDescription and NSHealthUpdateUsageDescription, call isHealthDataAvailable() first, keep one HKHealthStore, and request only those two types when the user first taps Track. Do not enable Clinical Health Records. Do not use HealthKit data for ads. Look up every type and method in Apple's HealthKit docs before you write it.

FAQ

Does HealthKit require permission for every data type?
Yes. Apple says HealthKit requires fine-grain authorization. You need to request permission to both read and share each data type before your app attempts to use the data.
Can my app tell if the user denied read access?
No. As part of the privacy protections, your app doesn’t know whether someone granted or denied permission to read data from HealthKit. If they denied permission, attempts to read data return only samples that your app successfully saved.
Should the agent request every type at launch?
No. Apple says you don’t need to request permission for all data types at once. It might make more sense to wait until you need to access the data before asking for permission.
Which Info.plist keys are required?
Xcode requires separate custom messages for reading and writing HealthKit data. Set NSHealthShareUsageDescription for reading and NSHealthUpdateUsageDescription for writing. Apps must include usage descriptions, or they will crash when requesting authorization.
Which tool should I install first?
Apple Docs MCP or Sosumi, so the agent reads “Setting up HealthKit” and “Authorizing access to health data” instead of inventing APIs. Add HIG Doctor when you audit the permission UI.