HealthKit Sync
by @mneves75
iOS HealthKit data sync CLI commands and patterns. Use when working with healthsync CLI, fetching Apple Health data (steps, heart rate, sleep, workouts), pairing iOS devices over local network, or understanding the iOS Health Sync project architecture including mTLS certificate pinning, Keychain storage, and audit logging.
clawhub install healthkit-syncπ About This Skill
name: healthkit-sync description: iOS HealthKit data sync CLI commands and patterns. Use when working with healthsync CLI, fetching Apple Health data (steps, heart rate, sleep, workouts), pairing iOS devices over local network, or understanding the iOS Health Sync project architecture including mTLS certificate pinning, Keychain storage, and audit logging. license: Apache-2.0 compatibility: macOS with healthsync CLI installed (~/.healthsync/config.json) metadata: category: development platforms: ios,macos author: mneves
HealthKit Sync CLI
Securely sync Apple HealthKit data from iPhone to Mac over local network using mTLS.
When to Use This Skill
healthsync CLI commandsCLI Quick Reference
Pairing Flow (First Time)
# 1. Discover devices on local network
healthsync discover2. On iOS app: tap "Share" to generate QR code, then "Copy"
3. Scan QR from clipboard (Universal Clipboard)
healthsync scanAlternative: scan from image file
healthsync scan --file ~/Desktop/qr.png
Fetching Health Data
# Check connection status
healthsync statusList enabled data types
healthsync typesFetch data as CSV (default)
healthsync fetch --start 2026-01-01T00:00:00Z --end 2026-12-31T23:59:59Z --types stepsFetch multiple types as JSON
healthsync fetch --start 2026-01-01T00:00:00Z --end 2026-12-31T23:59:59Z \
--types steps,heartRate,sleepAnalysis --format json | jqPipe to file
healthsync fetch --start 2026-01-01T00:00:00Z --end 2026-12-31T23:59:59Z \
--types steps > steps.csv
Available Health Data Types
Activity: steps, distanceWalkingRunning, distanceCycling, activeEnergyBurned, basalEnergyBurned, exerciseTime, standHours, flightsClimbed, workouts
Heart: heartRate, restingHeartRate, walkingHeartRateAverage, heartRateVariability
Vitals: bloodPressureSystolic, bloodPressureDiastolic, bloodOxygen, respiratoryRate, bodyTemperature, vo2Max
Sleep: sleepAnalysis, sleepInBed, sleepAsleep, sleepAwake, sleepREM, sleepCore, sleepDeep
Body: weight, height, bodyMassIndex, bodyFatPercentage, leanBodyMass
Configuration
Config stored at ~/.healthsync/config.json (permissions: 0600):
{
"host": "192.168.1.x",
"port": 8443,
"fingerprint": "sha256-certificate-fingerprint"
}
Token stored in macOS Keychain under service org.mvneves.healthsync.cli.
Security Architecture
Certificate Pinning
The CLI validates server certificates by SHA256 fingerprint (TOFU model): 1. First pairing stores fingerprint from QR code 2. Subsequent connections verify fingerprint matches 3. Mismatch = connection rejected (MITM protection)
Local Network Only
Host validation restricts connections to:
localhost, *.local domains192.168.*, 10.*, 172.16-31.*::1, link-local: fe80::Keychain Storage
Tokens never stored in config file - always in Keychain with:
kSecAttrAccessibleWhenUnlocked protection classorg.mvneves.healthsync.clitoken-{host}Project Structure
ai-health-sync-ios-clawdbot/
βββ iOS Health Sync App/ # Swift 6 iOS app
β βββ Services/Security/ # CertificateService, KeychainStore, PairingService
β βββ Services/HealthKit/ # HealthKitService, HealthSampleMapper
β βββ Services/Network/ # NetworkServer (TLS), HTTPTypes
β βββ Services/Audit/ # AuditService (SwiftData)
βββ macOS/HealthSyncCLI/ # Swift Package CLI
Troubleshooting
"No devices found":
"Pairing code expired":
"Certificate mismatch":
~/.healthsync/config.json and re-pair"Connection refused":
healthsync status --dry-run to test without connectingSee Also
βοΈ Configuration
Config stored at ~/.healthsync/config.json (permissions: 0600):
{
"host": "192.168.1.x",
"port": 8443,
"fingerprint": "sha256-certificate-fingerprint"
}
Token stored in macOS Keychain under service org.mvneves.healthsync.cli.
π Tips & Best Practices
"No devices found":
"Pairing code expired":
"Certificate mismatch":
~/.healthsync/config.json and re-pair"Connection refused":
healthsync status --dry-run to test without connecting