agentleFS
kingstinctkingstinct/react-native-healthkit/.agents/skills/react-native-healthkit-contributing/SKILL.md

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.

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
  1. Very specific:

    Put code in core only when both packages need it.

    line 26
  2. Very specific:

    All three packages share one version (changesets fixed), and the pods pin core to the exact same version.

    line 27
  3. Very specific:

    After changing anything in src/specs/ of either package, or any type they reference (including packages/core/src/types), run bun codegen.

    line 41
  4. Very specific:

    Before committing, run bun typecheck, bun lint and bun run test until they pass.

    line 42
  5. Very specific:

    Add a changeset for every user-facing feature or fix (bunx changeset), bumping semver correctly.

    line 44
  6. Distinctive:

    Every new export needs three entries:

    line 45
  7. Very specific:

    Look up Apple semantics as Markdown: append .md to any developer.apple.com documentation URL, e.g.

    line 49

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 install does this in postinstall.
  • 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

TaskRead
New HealthKit quantity or category identifier, category value, metadata key or workout activity typereferences/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 releasereferences/verify-and-release.md
nitrogen, codegen, pod or Xcode build failuresreferences/codegen-troubleshooting.md

Non-negotiables

  1. After changing anything in src/specs/ of either package, or any type they reference (including packages/core/src/types), run bun codegen. Use bun codegen:healthkit or bun codegen:health-records for a single package.
  2. Before committing, run bun typecheck, bun lint and bun run test until they pass. For Swift changes, also run bun run swiftlint.
  3. 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.
  4. Add a changeset for every user-facing feature or fix (bunx changeset), bumping semver correctly.
  5. Every new export needs three entries:
    • the iOS implementation in healthkit.ios.ts;
    • a non-iOS stub in healthkit.ts via UnavailableFnFromModule (a missing stub is a type error);
    • a jest.fn() in src/test-setup.ts's mockModule if it calls a native module.
  6. Look up Apple semantics as Markdown: append .md to any developer.apple.com documentation URL, e.g. https://developer.apple.com/documentation/healthkit/hkhealthstore.md. The metadata header's availability tells you the iOS version to gate on. Put the Apple link in the spec's JSDoc with @see.
  7. 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. useExhaustiveDependencies and useHookAtTopLevel are errors. bun lint-fix autofixes.
  • Swift:
    • Async natives return Promise.async { ... }.
    • Throw or warn with each package's ios/Helpers.swift helpers (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 with parseUnitStringSafe(_:) rather than HKUnit(from:).
    • Gate new-SDK symbols with #if compiler(>=X) and #available(iOS N, *) (see add-native-api).
  • Commits: Conventional commits (commitlint runs in husky commit-msg). pre-commit runs lint-staged (biome and swiftlint --fix). pre-push runs bun run test && bun run typecheck.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.