Best for
- Use when an app needs SensorKit entitlement setup, Research Sensor & Usage Data authorization, ambient light, recorded motion, device usage, keyboard metrics, visits, speech, face, wrist temperature, ECG, PPG, acoustic…
dpearson2699/swift-ios-skills/skills/sensorkit/SKILL.md
Access research-grade sensor data using SensorKit for approved studies. Use when an app needs SensorKit entitlement setup, Research Sensor & Usage Data authorization, ambient light, recorded motion, device usage, keyboard metrics, visits, speech, face, wrist temperature, ECG, PPG, acoustic settings, or sleep-session data. Route ordinary motion to CoreMotion and health records/workouts to HealthKit.
Decision brief
Choose the exact SRSensor and verify its individual availability. Use CoreMotion for ordinary motion/activity features and HealthKit for health records and workouts.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill "skills/sensorkit"Inspect the Agent Skill "sensorkit" from https://github.com/dpearson2699/swift-ios-skills/blob/90c9573272531337962fbb3505036d61ed23389a/skills/sensorkit/SKILL.md at commit 90c9573272531337962fbb3505036d61ed23389a. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
Add the exact Info.plist Configuration usage-detail entry for every requested sensor.
[ ] Apple-approved research study in place before development
SensorKit enables research apps to record and fetch sensor data across iPhone and Apple Watch. The framework requires:
Add the SensorKit reader entitlement to a .entitlements file. List only the sensors Apple approved for the study. Common entitlement values include:
Three keys are required:
Permission review
The documentation includes network, browsing, or remote request actions.
<string>https://example.com/privacy-policy</string>The documentation includes network, browsing, or remote request actions.
reader.fetch(request)Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 77/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 933 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Choose the exact SRSensor and verify its individual availability. Use
CoreMotion for ordinary motion/activity features and HealthKit for health
records and workouts.
SensorKit enables research apps to record and fetch sensor data across iPhone and Apple Watch. The framework requires:
com.apple.developer.sensorkit.reader.allow
only for approved studies.An app can access up to 7 days of prior recorded data for an active sensor.
Add the SensorKit reader entitlement to a .entitlements file. List only the
sensors Apple approved for the study. Common entitlement values include:
<key>com.apple.developer.sensorkit.reader.allow</key>
<array>
<string>ambient-light-sensor</string>
<string>motion-accelerometer</string>
<string>device-usage</string>
<string>keyboard-metrics</string>
</array>
Load the Entitlement and Usage-Detail Catalog
when selecting the exact entitlement string and NSSensorKitUsageDetail key
for each approved sensor. Recheck specialized sensors against their individual
SRSensor pages.
For manual signing, set Code Signing Entitlements to the entitlements file,
Code Signing Identity to Apple Developer, Code Signing Style to Manual,
and Provisioning Profile to the explicit profile with SensorKit capability.
Three keys are required:
<!-- Study purpose shown in the authorization sheet -->
<key>NSSensorKitUsageDescription</key>
<string>This study monitors activity patterns for sleep research.</string>
<!-- Link to your study's privacy policy -->
<key>NSSensorKitPrivacyPolicyURL</key>
<string>https://example.com/privacy-policy</string>
<!-- Per-sensor usage explanations -->
<key>NSSensorKitUsageDetail</key>
<dict>
<key>SRSensorUsageMotion</key>
<dict>
<key>Description</key>
<string>Measures physical activity levels during the study.</string>
<key>Required</key>
<true/>
</dict>
<key>SRSensorUsageAmbientLightSensor</key>
<dict>
<key>Description</key>
<string>Records ambient light to assess sleep environment.</string>
</dict>
</dict>
If Required is true and the user denies that sensor, the system warns them
that the study needs it and offers a chance to reconsider.
Use the exact usage-detail dictionary for each requested sensor. Load the Entitlement and Usage-Detail Catalog when mapping sensors beyond the motion and ambient-light examples above.
Request authorization for the sensors your study needs. The system shows the Research Sensor & Usage Data sheet on first request.
import SensorKit
let reader = SRSensorReader(sensor: .ambientLightSensor)
// Request authorization for multiple sensors at once
SRSensorReader.requestAuthorization(
sensors: [.ambientLightSensor, .accelerometer, .keyboardMetrics]
) { error in
if let error {
print("Authorization request failed: \(error)")
}
}
Use one status handler both for the initial check and delegate changes:
private func applyAuthorizationStatus(
_ status: SRAuthorizationStatus,
to reader: SRSensorReader
) {
switch status {
case .authorized:
reader.startRecording()
case .denied:
reader.stopRecording()
// Direct the user to Settings > Privacy > Research Sensor & Usage Data.
case .notDetermined:
break // Request authorization first.
@unknown default:
break
}
}
applyAuthorizationStatus(reader.authorizationStatus, to: reader)
func sensorReader(_ reader: SRSensorReader, didChange authorizationStatus: SRAuthorizationStatus) {
applyAuthorizationStatus(authorizationStatus, to: reader)
}
Load the Sensor Catalog to map
each SRSensor to its sample type. Request only sensors approved for the study
and recheck the selected sensor's availability and usage-detail key.
SRSensorReader is the central class for accessing sensor data. Each instance
reads from a single sensor.
import SensorKit
// Create a reader for one sensor
let lightReader = SRSensorReader(sensor: .ambientLightSensor)
let keyboardReader = SRSensorReader(sensor: .keyboardMetrics)
// Assign delegate to receive callbacks
lightReader.delegate = self
keyboardReader.delegate = self
The reader communicates through SRSensorReaderDelegate. Load the
Delegate Method Catalog
when wiring the complete authorization, recording, device-fetch, and
sample-fetch lifecycle.
// Begin recording -- sensor stays active as long as any app has a stake
reader.startRecording()
// Stop recording -- framework deactivates the sensor when
// no app or system process is using it
reader.stopRecording()
Build an SRFetchRequest with a time range and target device, then pass it to
the reader:
let request = SRFetchRequest()
request.device = SRDevice.current
request.from = SRAbsoluteTime(CFAbsoluteTimeGetCurrent() - 86400 * 2) // 2 days ago
request.to = SRAbsoluteTime.current()
reader.fetch(request)
Receive results through the delegate:
func sensorReader(
_ reader: SRSensorReader,
fetching request: SRFetchRequest,
didFetchResult result: SRFetchResult<AnyObject>
) -> Bool {
let timestamp = result.timestamp
switch reader.sensor {
case .ambientLightSensor:
if let sample = result.sample as? SRAmbientLightSample {
let lux = sample.lux
let chromaticity = sample.chromaticity
let placement = sample.placement
processSample(lux: lux, chromaticity: chromaticity, at: timestamp)
}
case .keyboardMetrics:
if let sample = result.sample as? SRKeyboardMetrics {
let words = sample.totalWords
let speed = sample.typingSpeed
processKeyboard(words: words, speed: speed, at: timestamp)
}
case .deviceUsageReport:
if let sample = result.sample as? SRDeviceUsageReport {
let wakes = sample.totalScreenWakes
let unlocks = sample.totalUnlocks
processUsage(wakes: wakes, unlocks: unlocks, at: timestamp)
}
default:
break
}
return true // Return true to continue receiving results
}
func sensorReader(_ reader: SRSensorReader, didCompleteFetch request: SRFetchRequest) {
print("Fetch complete for \(reader.sensor)")
}
func sensorReader(
_ reader: SRSensorReader,
fetching request: SRFetchRequest,
failedWithError error: any Error
) {
print("Fetch failed: \(error)")
}
Cast result.sample to the sample shape for the reader's sensor. Some streams
return one object per result, while recorded motion, ECG, PPG, and ambient
pressure streams can return arrays of recorded samples.
SensorKit imposes a 24-hour holding period on newly recorded data. Fetch requests whose time range overlaps this period return no results. Design data collection workflows around this delay.
SRDevice identifies the hardware source for sensor samples. Use it to
distinguish data from iPhone versus Apple Watch.
// Get the current device
let currentDevice = SRDevice.current
print("Model: \(currentDevice.model)")
print("System: \(currentDevice.systemName) \(currentDevice.systemVersion)")
// Fetch all available devices for a sensor
reader.fetchDevices()
Handle fetched devices through the delegate:
func sensorReader(_ reader: SRSensorReader, didFetch devices: [SRDevice]) {
for device in devices {
let request = SRFetchRequest()
request.device = device
request.from = SRAbsoluteTime(CFAbsoluteTimeGetCurrent() - 86400)
request.to = SRAbsoluteTime.current()
reader.fetch(request)
}
}
func sensorReader(_ reader: SRSensorReader, fetchDevicesDidFailWithError error: any Error) {
print("Failed to fetch devices: \(error)")
}
| Property | Type | Description |
|---|---|---|
model | String | User-defined device name |
name | String | Framework-defined device name |
systemName | String | OS name (iOS, watchOS) |
systemVersion | String | OS version |
productType | String | Hardware identifier |
current | SRDevice | Class property for the running device |
Obtain Apple's study approval, the sensor-specific entitlement values, and a matching manual provisioning profile before constructing production readers.
Apply the Data Holding Period; a fetch overlapping the hold is not proof that recording failed.
Assign the delegate before startRecording() or fetch(_:); results and
failures arrive through delegate callbacks.
Add the exact Info.plist Configuration usage-detail entry for every requested sensor.
Distinguish at least .invalidEntitlement, .noAuthorization,
.dataInaccessible, .fetchRequestInvalid, .promptDeclined, and unknown
future codes. Load the Full Delegate Implementation
for the complete switch and callback wiring.
com.apple.developer.sensorkit.reader.allow entitlement lists only needed sensorsNSSensorKitUsageDescription in Info.plist with clear study purposeNSSensorKitPrivacyPolicyURL in Info.plist with valid privacy policy URLNSSensorKitUsageDetail entries for every requested sensorRequired key set appropriately for essential vs. optional sensorsstartRecording() or fetch(_:)SRError codes handled in all failure delegate methodsfetchDevices() used to discover available devices before fetchingstopRecording() called when data collection is completesensorReader(_:fetching:didFetchResult:) returns true to continue or false to stopAlternatives
coreyhaines31/marketingskills
When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program
coreyhaines31/marketingskills
When the user wants to reduce churn, build cancellation flows, set up save offers, recover failed payments, or implement retention strategies. Also use when the user mentions 'churn,' 'cancel flow,' 'offboarding,' 'save offer,' 'dunning,' 'failed payment recovery,' 'win-back,' 'retention,' 'exit survey,' 'pause subscription,' 'involuntary churn,' 'people keep canceling,' 'churn rate is too high,' 'how do I keep users,' or 'customers are leaving.' Use this whenever someone is losing subscribers o
event4u-app/agent-config
Use when the user says "review the design", "check the UI", or wants a comprehensive UI/UX review. Uses a 7-phase methodology covering interaction, responsiveness, accessibility, and more.
K-Dense-AI/scientific-agent-skills
Distributed computing for larger-than-RAM pandas/NumPy workflows. Use when you need to scale existing pandas/NumPy code beyond memory or across clusters. Best for parallel file processing, distributed ML, integration with existing pandas code. For out-of-core analytics on single machine use vaex; for in-memory speed use polars.