About corebluetooth
A reference skill for Apple Core Bluetooth development, covering central and peripheral roles, workflows, API lookup, and lifecycle constraints. It helps developers plan BLE operations and follow role-specific steps and practices.
Key features
- 01Central-role workflow guidance
- 02Peripheral-role workflow guidance
- 03BLE API and symbol lookup
- 04Background processing and restoration guidance
- 05Role-specific best practices
Use cases
- 01Build an app that scans for and connects to peripherals
- 02Configure an app to advertise as a peripheral
- 03Handle Bluetooth background behavior and state restoration
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ nonameplum/ agent-skills --skill corebluetoothAfter installing, type/corebluetoothin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
AboutCoreBluetooth.mdBestPracticesforInteractingwithaRemotePeripheralDevice.mdBestPracticesforSettingUpYourLocalDeviceasaPeripheral.mdBluetoothStateRestorationAppReaunchRules.mdcorebluetooth.mdCoreBluetoothBackgroundProcessingforiOSApps.mdCoreBluetoothOverview.mdPerformingCommonCentralRoleTasks.mdPerformingCommonPeripheralRoleTasks.mdDetails
From the project READMECore Bluetooth
What to open
- Use
corebluetooth/AboutCoreBluetooth.mdandcorebluetooth/CoreBluetoothOverview.mdfor concepts and role orientation. - Use
corebluetooth/PerformingCommonCentralRoleTasks.mdfor step-by-step central workflows. - Use
corebluetooth/PerformingCommonPeripheralRoleTasks.mdfor step-by-step peripheral workflows. - Use
corebluetooth/BestPracticesforInteractingwithaRemotePeripheralDevice.mdandcorebluetooth/BestPracticesforSettingUpYourLocalDeviceasaPeripheral.mdfor pitfalls and best practices. - Use
corebluetooth/CoreBluetoothBackgroundProcessingforiOSApps.mdfor background modes and lifecycle constraints. - Use
corebluetooth/BluetoothStateRestorationAppReaunchRules.mdfor state restoration app relaunch rules. - Use
corebluetooth/corebluetooth.mdfor API quick maps and symbol lookup.
Workflow
- Identify whether the app acts as a central, a peripheral, or both.
- Wait for the manager state to be
poweredOnbefore issuing BLE operations. - Follow the role checklist to keep discovery and connection order correct.
- Open the role task guide and best practices first; use the API reference for exact signatures.
Central checklist
- Create a
CBCentralManagerwith a delegate and queue. - Handle
centralManagerDidUpdateState(_:)and gate scanning on.poweredOn. - Scan with
scanForPeripherals(withServices:options:)and stop when the target is found. - Connect, set the
CBPeripheraldelegate, and discover services and characteristics. - Read, write, or subscribe to characteristic notifications as needed.
Peripheral checklist
- Create a
CBPeripheralManagerwith a delegate and queue. - Wait for the state to become
.poweredOn. - Define services and characteristics, then add them to the manager.
- Start advertising with service UUIDs and optional local name.
- Respond to read and write requests; publish updates to subscribed centrals.
Reminders
- Retain discovered
CBPeripheralinstances to keep them alive. - Use notifications for streaming data; use write-without-response only when
canSendWriteWithoutResponseis true. - Use L2CAP only for use cases that do not fit GATT characteristics.
Comments
Markdown supported