# core-motion

A Core Motion skill for your coding agent: accelerometer, gyroscope, pedometer, activity recognition, altitude, AirPods motion and watchOS dive depth.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3700 installs · ★ 1237
- Author: dpearson2699
- License: LicenseRef-Unknown · policy=link-only · description only; the file stays with the author
- Source: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/core-motion/SKILL.md
- Updated: 2026-07-31
- HTML: https://affpapa.org/en/nevibecode/skills/core-motion

## What it does

The skill hands the agent a Core Motion reference for Swift 6.3 and iOS 26+. Its sections cover raw accelerometer and gyro streams from `CMMotionManager`, fused device motion with the attitude reference frames, `CMPedometer` for steps and distance, `CMMotionActivityManager` for walking, running, cycling or driving, and `CMAltimeter` for altitude. It also goes over polling samples each frame in a game loop, update intervals and battery cost.

There are traps worth knowing. Keep a single `CMMotionManager` for the whole app, since more than one instance drags sensor rates down. Ask `CMMotionManager.availableAttitudeReferenceFrames()` before requesting a magnetic-north or true-north frame and fall back to what exists. The `NSMotionUsageDescription` key belongs in Info.plist; skip it and the app crashes on the first sensor call.

Some managers report authorization on their own (`CMPedometer`, `CMMotionActivityManager`, `CMAltimeter`), while `CMMotionManager` streams have no such request API and surface failures through start and update callbacks. Availability checks such as `isStepCountingAvailable()` or `isAccelerometerAvailable` are collected in a table. A list of common mistakes and a review checklist close out the skill.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill core-motion -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/core-motion/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/core-motion/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill core-motion -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/core-motion/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill core-motion -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/core-motion/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install dpearson2699/swift-ios-skills core-motion
```

2. **Manually: put the files in place**
- File: `.github/skills/core-motion/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill core-motion -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/dpearson2699/swift-ios-skills --path skills/core-motion
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/core-motion/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add dpearson2699/swift-ios-skills --skill core-motion -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/dpearson2699/swift-ios-skills/tree/HEAD/skills/core-motion/SKILL.md

## When to use it
- read accelerometer and gyroscope samples at a fixed rate
- count steps and distance walked today
- detect whether the user is walking, running or driving
- track altitude and floors climbed
- pick a working attitude reference frame instead of a missing one

## Example prompts
- Show how to subscribe to raw accelerometer updates from CMMotionManager at 60 Hz.
- Query today's step history from CMPedometer and print the distance.
- My .xTrueNorthZVertical frame returns nothing. Check which attitude frames the device supports.

## Similar
- [vercel-react-native-skills](https://affpapa.org/en/nevibecode/skills/vercel-react-native-skills.md) — skill · 255200 installs
- [animate-expo](https://affpapa.org/en/nevibecode/skills/animate-expo.md) — skill · 137900 installs
- [mobile-native](https://affpapa.org/en/nevibecode/skills/mobile-native.md) — skill · 86600 installs
- [aso](https://affpapa.org/en/nevibecode/skills/aso.md) — skill · 75400 installs
- [swiftui-pro](https://affpapa.org/en/nevibecode/skills/swiftui-pro.md) — skill · 35200 installs
- [orca-emulator](https://affpapa.org/en/nevibecode/skills/orca-emulator.md) — skill · 5800 installs

From the same set: [dpearson2699/swift-ios-skills](https://affpapa.org/en/nevibecode/by/dpearson2699/swift-ios-skills.md) — 86 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
