# healthkit

This skill guides AI agents through reading, writing, and querying Apple Health data via HealthKit in Swift. Use it for workout flows, health metric charts, and background updates.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3900 installs · ★ 1237
- Author: dpearson2699
- License: LicenseRef-Unknown · policy=link-only · description only; the file stays with the author
- Source: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/healthkit/SKILL.md
- Updated: 2026-07-31
- HTML: https://affpapa.org/en/nevibecode/skills/healthkit

## What it does

The skill outlines workflows for Apple HealthKit targeting Swift 6.3 and iOS 26+. It guides the setup of a single `HKHealthStore` instance and enforces initial checks with `HKHealthStore.isHealthDataAvailable()`. This check prevents crashes on unsupported hardware like iPadOS 16 or earlier.

Inside, it emphasizes modern async/await descriptors rather than legacy callbacks. For one-off sample reads it applies `HKSampleQueryDescriptor`, while aggregated totals use `HKStatisticsQueryDescriptor`. When building chart series, it configures `HKStatisticsCollectionQueryDescriptor` with custom date anchors and intervals.

Xcode setup requires enabling the HealthKit capability alongside `NSHealthShareUsageDescription` and `NSHealthUpdateUsageDescription` keys in Info.plist. Because HealthKit conceals whether read permission was denied, queries silently return empty results if access was withheld, making permission debugging easy to misinterpret.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill healthkit -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/healthkit/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/healthkit/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill healthkit -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/healthkit/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill healthkit -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/healthkit/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install dpearson2699/swift-ios-skills healthkit
```

2. **Manually: put the files in place**
- File: `.github/skills/healthkit/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill healthkit -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/dpearson2699/swift-ios-skills --path skills/healthkit
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/healthkit/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill healthkit -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/healthkit/SKILL.md

## When to use it
- configure `HKHealthStore` permissions without requesting redundant types
- fetch recent heart rate samples using `HKSampleQueryDescriptor`
- calculate daily step counts with `HKStatisticsQueryDescriptor`
- group activity metrics into time intervals for charts

## Example prompts
- Write a Swift function to fetch today's total steps using HKStatisticsQueryDescriptor
- How do I fetch the 20 most recent heart rate samples using HKSampleQueryDescriptor?
- Show how to check HealthKit availability and request read and write permissions

## Similar
- [axiom-health](https://affpapa.org/en/nevibecode/skills/axiom-health.md) — skill · 953 installs
- [xcode-project-setup](https://affpapa.org/en/nevibecode/skills/xcode-project-setup.md) — skill · 130700 installs
- [expo-migrate-module](https://affpapa.org/en/nevibecode/skills/expo-migrate-module.md) — skill · 19400 installs
- [clerk-swift](https://affpapa.org/en/nevibecode/skills/clerk-swift.md) — skill · 14500 installs
- [swiftdata-pro](https://affpapa.org/en/nevibecode/skills/swiftdata-pro.md) — skill · 9300 installs
- [cmux-architecture](https://affpapa.org/en/nevibecode/skills/cmux-architecture.md) — skill · 4900 installs

## Other versions with the same name
- [healthkit · prisma-labs-dev](https://affpapa.org/en/nevibecode/skills/prisma-labs-dev-healthkit.md) — 712 installs

From the same set: [dpearson2699/swift-ios-skills](https://affpapa.org/en/nevibecode/by/dpearson2699/swift-ios-skills.md) — 86 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
