Skip to main content
skill CX Codex

healthkit-code-review — Claude Code skill: HealthKit code review

healthkit-code-review walks HealthKit code through a fixed sequence: authorization, queries, observers, background delivery. Handy when you are the one reviewing health data work.

Apache-2.0 134 installs ★ 89 updated 2026-09-15

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add existential-birds/beagle --skill healthkit-code-review -a claude-code
Open on GitHub

What healthkit-code-review does

Some HealthKit mistakes survive a quick read: a requestAuthorization that finished fine is taken as read access, an observer never calls its completion handler. This skill turns those traps into a checklist the agent follows in order.

Six review gates run one after another. The agent names the files and symbols touching HealthKit, then points at where isHealthDataAvailable() is called, then walks the branches of each authorization handler. Findings from a later gate wait until the current one passes, so the review does not scatter into random nitpicks.

Four reference files sit behind it: references/authorization.md, references/queries.md, references/background.md, references/data-types.md. They load by what the diff touches. The checklist also covers HKObjectQueryNoLimit without a bounded predicate, manual summing where HKStatisticsQuery belongs, and units like count/min for heart rate. Background delivery needs its entitlement on iOS 15+ and registration in application(_:didFinishLaunchingWithOptions:).

What it helps with

  • catch HKHealthStore use that skips the availability check
  • keep a successful requestAuthorization from being read as read permission
  • confirm every query carries a predicate and a limit
  • find observer queries that miss completionHandler() on some path
  • check that anchors are persisted per sample type

Example prompts for the agent

  • Walk the review gates over HealthStoreManager.swift and show me where the authorization handling is wrong.
  • Look at the observer queries in this diff and tell me whether completionHandler() fires on every path.
  • Find each HKQuantityType in the project and verify the units.

How to install healthkit-code-review

1Skills CLI (Vercel)

npx skills add existential-birds/beagle --skill healthkit-code-review -a claude-code

2Manually: put the files in place

~/.claude/skills/healthkit-code-review/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/healthkit-code-review/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about healthkit-code-review

How do I install healthkit-code-review in Claude Code?

Run npx skills add existential-birds/beagle --skill healthkit-code-review -a claude-code. The skill file lands at ~/.claude/skills/healthkit-code-review/SKILL.md.

What does healthkit-code-review do?

It reviews HealthKit code against a checklist: data availability, minimal permissions, query predicates and limits, observers, background delivery, units. It also flags attempts to work out read permission from authorizationStatus.

What does background delivery require?

An entitlement on iOS 15+ and registration in application(_:didFinishLaunchingWithOptions:). Work inside the background handler should stay near the 15 second limit.

Source text

SKILL.md · Apache-2.0
---
name: healthkit-code-review
description: 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.
---

# HealthKit Code Review

## Quick Reference

| Issue Type | Reference |
|------------|-----------|
| HKHealthStore, permissions, status checks, privacy | [references/authorization.md](references/authorization.md) |
| HKQuery types, predicates, anchored queries, statistics | [references/queries.md](references/queries.md) |
| Background delivery, observer queries, completion handlers | [references/background.md](references/background.md) |
| HKQuantityType, HKCategoryType, workouts, units | [references/data-types.md](references/data-types.md) |

## Review Checklist

- [ ] `HKHealthStore.isHealthDataAvailable()` called before any HealthKit operations
- [ ] Authorization requested only for needed data types (minimal permissions)
- [ ] `requestAuthorization` completion handler not misinterpreted as permission granted
- [ ] No attempt to determine read permission status (privacy by design)
- [ ] Query results dispatched to main thread for UI updates
- [ ] `HKObjectQueryNoLimit` used only with bounded predicates
- [ ] `HKStatisticsQuery` used for aggregations instead of manual summing
- [ ] Observer query `completionHandler()` always called (use `defer`)
- [ ] Background delivery registered in `application(_:didFinishLaunchingWithOptions:)`
- [ ] Background delivery entitlement added (iOS 15+)
- [ ] Correct units used for quantity types (e.g., `count/min` for heart rate)
- [ ] 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 `enableBackgroundDelivery` -> background.md
- Reviewing HKQuantityType, HKCategoryType, or HKWorkout -> data-types.md

## Review gates

Run in order. **Do not state a finding in a later step until the pass condition for the current step is satisfied** (each pass condition is answerable from the codebase under review).

1. **Scope** — **Pass:** Name the file path(s) and types/symbols using `HealthKit`, `HKHealthStore`, or `HK*` APIs (or state clearly that the diff touches none).
2. **Availability and store** — **Pass:** Cite the call site of `isHealthDataAvailable()` before HealthKit use, or document why omission is acceptable for the scoped code; cite where `HKHealthStore` is created or injected.
3. **Authorization semantics** — **Pass:** For each `requestAuthorization` / `getRequestStatusForAuthorization`, cite handler branches per [references/authorization.md](references/authorization.md) (e.g. success does not prove read access); do not infer read permission from `authorizationStatus` alone.
4. **Queries and limits** — **Pass:** For each query, cite predicate + limit (`HKObjectQueryNoLimit` only with a bounded predicate); for totals/aggregates, cite `HKStatisticsQuery` / collection vs manual summing per [references/queries.md](references/queries.md).
5. **Observers and background** — **Pass:** If `HKObserverQuery` or `enableBackgroundDelivery` appears, cite where the observer is started/stopped and where background delivery is registered; cite entitlements/Info.plist or flag missing config per [references/background.md](references/background.md). If absent, **Pass:** one line “no observer/background in scope.”
6. **Threading and lifecycle** — **Pass:** Cite main-queue (or documented pattern) for UI updates from query callbacks; cite retention/`stop()`/`deinit` for long-running queries per checklist above.

## Review Questions

1. Is `isHealthDataAvailable()` checked before creating HKHealthStore?
2. Does the code gracefully handle denied permissions (empty results)?
3. Are observer query completion handlers called in all code paths?
4. Is work in background handlers minimal (~15 second limit)?
5. Are HKQueryAnchors persisted per sample type (not shared)?

© existential-birds · Apache-2.0 · existential-birds/beagle

Similar skills

All skills for Mobile →

From the same set68

The whole set →
watchos-code-review The watchos-code-review skill reviews watchOS code for lifecycle, complications, WatchConnectivity, and resource limits. Use it when checking WatchKit or SwiftUI app code. CX Codex +1 137installs swiftdata-code-review swiftdata-code-review reviews SwiftData code for model relationships, query predicates, actor concurrency, and schema migrations. Works on .swift files. CX Codex +1 136installs howto-docs The howto-docs skill shapes task-focused how-to guides with prerequisites, actionable steps, result checks, and troubleshooting for readers who already know the product. CX Codex +1 135installs deepagents-code-review deepagents-code-review reviews Deep Agents code and flags what breaks agents at runtime: interrupt_on with no checkpointer, backends with no store. CX Codex +1 134installs cloudkit-code-review cloudkit-code-review audits CloudKit code for custom zones, batching, error backoff, and asset size limits. CX Codex +1 127installs prometheus-go-code-review The prometheus-go-code-review skill reviews Prometheus instrumentation in Go, covering metric types, labels, naming, and registration. Use it when checking prometheus/client_golang code. CX Codex +1 126installs review-skill-improver review-skill-improver reviews code-review feedback logs, spots recurring rejection patterns, and proposes changes to review skills. Use it after feedback has accumulated and you want to refine review rules. CX Codex +1 125installs elixir-code-review elixir-code-review reviews Elixir files for OTP conventions, security caveats, and idiomatic style across .ex and .exs code. CX Codex +1 124installs

Project sponsors

Companies that keep this analytics open