react-native-healthkit-contributing
Skill719 starsChanged 46 days agoMITView on GitHub
How to change the react-native-healthkit monorepo itself (packages/core, packages/react-native-healthkit, packages/health-records, apps/example). Use when adding or changing a HealthKit identifier, a native (Nitro/Swift) API, a hook, the Expo config plugin, codegen, tests or CI in this repository, when nitrogen/codegen or the iOS build fails, or before committing/releasing changes here. For how to *use* the library in an app, see the react-native-healthkit skill instead.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- expo-deploymentSkill
- expo-dev-clientSkill
- react-native-best-practicesSkill
- upgrading-expoSkill
- react-native-healthkitSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
Put code in core only when both packages need it.
- Very specific: line 27
All three packages share one version (changesets fixed), and the pods pin core to the exact same version.
- Very specific: line 41
After changing anything in src/specs/ of either package, or any type they reference (including packages/core/src/types), run bun codegen.
- Very specific: line 42
Before committing, run bun typecheck, bun lint and bun run test until they pass.
- Very specific: line 44
Add a changeset for every user-facing feature or fix (bunx changeset), bumping semver correctly.
- Distinctive: line 45
Every new export needs three entries:
- Very specific: line 49
Look up Apple semantics as Markdown: append .md to any developer.apple.com documentation URL, e.g.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Contributing to react-native-healthkit
Mental model
packages/core @react-native-healthkit/core: shared TS types (src/types), createUnavailableHelpers,
Expo plugin building blocks (src/plugin), ReactNativeHealthkitCore pod (ios/):
HealthKitStore, Queries, Predicates, Anchors, MetadataSerialization,
TypeIdentifiers, BackgroundDeliveryManager, ExceptionCatcher. No Nitro specs.
packages/react-native-healthkit @kingstinct/react-native-healthkit: Nitro specs (src/specs/*.nitro.ts),
Swift impls (ios/*.swift), JS wiring (src/modules.ts, healthkit.ios.ts, healthkit.ts),
hooks, SDK-generated identifier types (src/generated, scripts/generate-healthkit*).
packages/health-records @react-native-healthkit/health-records: one spec (HealthRecordsModule), FHIR types.
apps/example Expo Router app (prebuild → ios/RNHealthKit.xcworkspace, scheme RNHealthKit),
plus contract tests (apps/example/contracts).- Core has no Nitro specs. Packages import core's TS types into their specs, and nitrogen generates a per-package Swift copy of them. So core must be built first (
bun run build:core) before codegen, typecheck or builds of the other packages.bun installdoes this inpostinstall. - Put code in core only when both packages need it. Core Swift must be
public. - All three packages share one version (changesets
fixed), and the pods pin core to the exact same version. - Identifiers, units, category value enums and metadata key maps are generated from the iOS SDK. Never hand-edit
src/generated/*.
Pick the workflow
| Task | Read |
| New HealthKit quantity or category identifier, category value, metadata key or workout activity type | references/add-identifier.md |
| New native function, module, hook or proxy method (Nitro spec → Swift → JS) | references/add-native-api.md |
| Checks to run, tests, CI, changesets and release | references/verify-and-release.md |
| nitrogen, codegen, pod or Xcode build failures | references/codegen-troubleshooting.md |
Non-negotiables
- After changing anything in
src/specs/of either package, or any type they reference (includingpackages/core/src/types), runbun codegen. Usebun codegen:healthkitorbun codegen:health-recordsfor a single package. - Before committing, run
bun typecheck,bun lintandbun run testuntil they pass. For Swift changes, also runbun run swiftlint. - Build the example app with xcodebuild when on macOS (see verify-and-release.md). On Linux you cannot. Say so explicitly instead of claiming the native build passed.
- Add a changeset for every user-facing feature or fix (
bunx changeset), bumping semver correctly. - Every new export needs three entries:
- the iOS implementation in
healthkit.ios.ts; - a non-iOS stub in
healthkit.tsviaUnavailableFnFromModule(a missing stub is a type error); - a
jest.fn()insrc/test-setup.ts'smockModuleif it calls a native module.
- the iOS implementation in
- Look up Apple semantics as Markdown: append
.mdto any developer.apple.com documentation URL, e.g.https://developer.apple.com/documentation/healthkit/hkhealthstore.md. The metadata header'savailabilitytells you the iOS version to gate on. Put the Apple link in the spec's JSDoc with@see. - Match the mapping philosophy: keep names and serialization as close to HealthKit as possible, so Apple's docs keep applying.
Conventions
- TypeScript: Biome with single quotes, no semicolons and 2-space indent.
useExhaustiveDependenciesanduseHookAtTopLevelare errors.bun lint-fixautofixes. - Swift:
- Async natives return
Promise.async { ... }. - Throw or warn with each package's
ios/Helpers.swifthelpers (runtimeErrorWithPrefix,warnWithPrefix). - HealthKit raises Objective-C exceptions (for example on a bad unit string or invalid statistics options), and Swift can't catch those. Wrap such calls with core's
runCatchingObjCExceptions { }, and parse unit strings withparseUnitStringSafe(_:)rather thanHKUnit(from:). - Gate new-SDK symbols with
#if compiler(>=X)and#available(iOS N, *)(see add-native-api).
- Async natives return
- Commits: Conventional commits (commitlint runs in husky
commit-msg).pre-commitruns lint-staged (biome and swiftlint --fix).pre-pushrunsbun run test && bun run typecheck.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

