| name | battery-data |
| description | Collects and normalizes macOS battery metrics using IOKit with pmset fallback. Use when implementing or debugging battery status retrieval, charging state, capacities, temperature, cycle count, and power source fields. |
Battery Data Skill
Goal
Produce a normalized battery snapshot model from macOS sources.
Steps
- Try IOKit (
IOPSCopyPowerSourcesInfo, IOPSCopyPowerSourcesList, IOPSGetPowerSourceDescription) for primary data.
- Read keys defensively and map into app model fields.
- If critical fields are missing, use
pmset -g batt as fallback parser.
- Keep parsing functions pure and unit-testable.
Output Contract
levelPercent
isCharging
powerSource
currentCapacityMah
maxCapacityMah
designCapacityMah (optional)
cycleCount (optional)
temperatureCelsius (optional)
chargePowerWatts (optional)
timeRemainingMinutes (optional)