Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Healthkit

ASecurity

Builds HealthKit authorization, sample reads/writes, statistics, background delivery, and workout sessions. Use for Apple Health metrics, charts, HKQuantitySample storage, HKLiveWorkoutBuilder, unit handling, workout recording, or health-data delivery and privacy behavior.

3 stars
0 votes
0 copies
0 views
Added 9/28/2026
developmentswiftapidocumentation

Works with

cliapi

Security Analysis

A100/100

Scanned 9/28/2026

Install to Claude Code

$npx -y skills add thiennc-tesoglobal/ios-skills --skill healthkit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Healthkit?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Healthkit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/thiennc-tesoglobal-healthkit/badge)](https://www.skillsdirectory.com/skills/thiennc-tesoglobal-healthkit)

More formats (shields.io, HTML) on the badges page.

Files
SKILL.md
---
name: healthkit
description: "Builds HealthKit authorization, sample reads/writes, statistics, background delivery, and workout sessions. Use for Apple Health metrics, charts, HKQuantitySample storage, HKLiveWorkoutBuilder, unit handling, workout recording, or health-data delivery and privacy behavior."
---

# HealthKit

Access, query, and store health and fitness metrics in Apple Health using `HealthKit`. Covers authorization, quantity samples, statistics collection queries, background delivery, and workout sessions. Targets Swift 6.3 / iOS 26+.

## Contents

- [Capabilities and Privacy](#capabilities-and-privacy)
- [Availability and HKHealthStore](#availability-and-hkhealthstore)
- [Query Selection Matrix](#query-selection-matrix)
- [Writing Samples and Units](#writing-samples-and-units)
- [Route by Task](#route-by-task)
- [Common Mistakes](#common-mistakes)
- [Review Checklist](#review-checklist)
- [References](#references)

## Capabilities and Privacy

Enable **HealthKit** in Signing & Capabilities. If your app observes updates in the background, enable the **Background Delivery** checkbox.

Declare usage descriptions in `Info.plist`:
- `NSHealthShareUsageDescription`: Required for reading health data.
- `NSHealthUpdateUsageDescription`: Required for writing health data.
- `NSHealthClinicalHealthRecordsShareUsageDescription`: Required if accessing clinical records.

> [!IMPORTANT]
> Request only the exact types needed for the immediate feature. App Review strictly rejects apps requesting unneeded health permissions.

## Availability and HKHealthStore

Always guard initialization with `HKHealthStore.isHealthDataAvailable()`. HealthKit is supported on iPhone, Apple Watch, iPad (iPadOS 17+), and Vision Pro, but unavailable on iPadOS 16 or earlier and managed devices with restrictions.

```swift
guard HKHealthStore.isHealthDataAvailable() else { return }
let healthStore = HKHealthStore() // Single thread-safe shared store
```

## Query Selection Matrix

| Query Type | Best Used For | Execution |
|---|---|---|
| `HKSampleQueryDescriptor` | Raw individual samples with sorting and limits | One-shot async |
| `HKStatisticsQueryDescriptor` | Single aggregate metric (sum, average, min/max) over a date range | One-shot async |
| `HKStatisticsCollectionQueryDescriptor` | Time-series aggregations (daily step charts, hourly heart rate) | One-shot or continuous |
| `HKAnchoredObjectQueryDescriptor` | Incremental synchronization with anchor tokens | One-shot or streaming |
| `HKObserverQuery` | Background delivery triggers when health data changes | Background notification |

## Writing Samples and Units

Always specify compatible `HKUnit`s matching the quantity type. For cumulative metrics (steps, active energy), set start and end dates encompassing the measurement interval; for discrete metrics (heart rate), use identical start and end dates.

## Route by Task

- For statistics collection queries and SwiftUI health chart configurations, read [Statistics and Charts](references/healthkit-patterns.md#statistics-collection-queries).
- For background observation and setting up `enableBackgroundDelivery`, read [Background Delivery](references/healthkit-patterns.md#background-delivery).
- For recording live workouts with `HKWorkoutSession` and `HKLiveWorkoutBuilder`, read [Live Workout Sessions](references/healthkit-patterns.md#workout-sessions).
- For complete HKUnit string formats, conversion, and compound units, read [HKUnit Reference](references/healthkit-patterns.md#hkunit-reference).

## Common Mistakes

- Calling HealthKit APIs without checking `HKHealthStore.isHealthDataAvailable()`.
- Missing `NSHealthShareUsageDescription` or `NSHealthUpdateUsageDescription`, causing immediate crash on launch.
- Creating multiple `HKHealthStore` instances instead of sharing a single instance across the app.
- Assuming read authorization can be inspected (Apple intentionally masks read authorization status for privacy).
- Using incompatible units (e.g. attempting to store step count with `.meter()` instead of `.count()`).

## Review Checklist

- [ ] `HKHealthStore.isHealthDataAvailable()` checked before accessing store
- [ ] Info.plist contains both share and update descriptions
- [ ] HealthKit capability enabled in target signing
- [ ] Read and write authorization requested in separate explicit sets
- [ ] Unit matches target `HKQuantityType` dimension
- [ ] Background delivery enabled with `enableBackgroundDelivery(for:frequency:)`
- [ ] Queries use predicate intervals to prevent scanning full lifetime history
- [ ] UI gracefully handles devices where HealthKit is unavailable (e.g. iPadOS 16)

## References

- [HealthKit extended query patterns and workout builders](references/healthkit-patterns.md)
- [HealthKit documentation](https://sosumi.ai/documentation/healthkit)
- [HKHealthStore](https://sosumi.ai/documentation/healthkit/hkhealthstore)
- [HKQuantityType](https://sosumi.ai/documentation/healthkit/hkquantitytype)
- [HKWorkoutSession](https://sosumi.ai/documentation/healthkit/hkworkoutsession)

Attribution

thiennc-tesoglobalthiennc-tesoglobal
View sourceMore from thiennc-tesoglobal →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284972 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

10311 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →