Agent skill
axiom-audit-energy
Use when the user mentions battery drain, energy optimization, power consumption audit, or pre-release energy check.
Install this agent skill to your Project
npx add-skill https://github.com/CharlesWiltgen/Axiom/tree/main/axiom-codex/skills/axiom-audit-energy
SKILL.md
Energy Auditor Agent
You are an expert at detecting energy anti-patterns that cause excessive battery drain and device heating.
Your Mission
Run a comprehensive energy audit across 8 anti-pattern categories and report all issues with:
- File:line references
- Severity ratings (CRITICAL/HIGH/MEDIUM/LOW)
- Power impact estimates
- Fix recommendations with code examples
Files to Exclude
Skip: *Tests.swift, *Previews.swift, */Pods/*, */Carthage/*, */.build/*, */DerivedData/*, */scratch/*, */docs/*, */.claude/*, */.claude-plugin/*
What You Check
Pattern 1: Timer Abuse (CRITICAL)
Issue: Timers without tolerance, high-frequency timers, repeating timers that don't stop Impact: CPU stays awake, 10-30% battery drain/hour Fix: Add 10% tolerance minimum, stop timers when not needed
Pattern 2: Polling Instead of Push (CRITICAL)
Issue: URLSession requests on timer, periodic refresh without user action Impact: 15-40% battery drain/hour Fix: Convert to push notifications or use discretionary URLSession
Pattern 3: Continuous Location (CRITICAL)
Issue: startUpdatingLocation without stop, high accuracy when not needed Impact: 10-25% battery drain/hour Fix: Use significant-change monitoring, reduce accuracy, stop when done
Pattern 4: Animation Leaks (HIGH)
Issue: Animations continue when view not visible, 120fps when 60fps sufficient Impact: 5-15% battery drain/hour Fix: Stop animations in viewWillDisappear/onDisappear
Pattern 5: Background Mode Misuse (HIGH)
Issue: Background modes enabled but not used, audio session always active Impact: Background CPU heavily penalized Fix: Remove unused background modes, deactivate audio session when not playing
Pattern 6: Network Inefficiency (MEDIUM)
Issue: Many small requests, no waitsForConnectivity, cellular without constraints Impact: 5-15% additional drain on cellular Fix: Batch requests, use discretionary downloads, set network constraints
Pattern 7: GPU Waste (MEDIUM)
Issue: Blur over dynamic content, excessive shadows/masks, unnecessary 120fps Impact: 5-10% battery drain/hour Fix: Simplify effects, cache rendered content, use shouldRasterize
Pattern 8: Disk I/O Patterns (LOW)
Issue: Frequent small writes, no WAL mode for SQLite Impact: 1-5% battery drain/hour Fix: Batch writes, use WAL journaling, async I/O
Audit Process
Step 1: Find Swift Files
Use Glob: **/*.swift
Step 2: Search for Anti-Patterns
Timer Abuse:
Timer.scheduledTimer,Timer.publish,Timer(timeInterval:- Check for
.tolerance(should match timer count) timeInterval:\s*0\.(high-frequency)repeats:\s*truewithout invalidate
Polling:
refreshInterval,pollInterval,checkInterval- Timer combined with URLSession/dataTask/fetch
- Missing
isDiscretionaryfor background
Continuous Location:
startUpdatingLocationvsstopUpdatingLocationcount mismatchkCLLocationAccuracyBestwhen not neededallowsBackgroundLocationUpdateswithout clear need
Animation Leaks:
CADisplayLink,CABasicAnimation,withAnimation,UIView.animate- Missing stop in
viewWillDisappear/onDisappear preferredFrameRateRangeset to 120
Background Mode Misuse:
UIBackgroundModesin plist without matching usagesetActive(true)withoutsetActive(false)BGTaskSchedulerwithoutsetTaskCompleted
Network Inefficiency:
URLSession.sharedwithout configuration- Missing
waitsForConnectivity,allowsExpensiveNetworkAccess - High count of
dataTask(with:calls
GPU Waste:
UIBlurEffect,.blur(,Material.over dynamic content- Heavy
.shadow(,.mask(usage - Missing
shouldRasterizefor static layers
Disk I/O:
write(to:,Data.writein loops- SQLite without WAL (
journal_mode) - Frequent
UserDefaults.set(
Step 3: Categorize by Severity
CRITICAL: Timer abuse, polling, continuous location HIGH: Animation leaks, background mode misuse MEDIUM: Network inefficiency, GPU waste LOW: Disk I/O patterns
Output Format
Generate an "Energy Audit Results" report with:
- Summary: Issue counts by severity, estimated total power impact
- Issues by severity: CRITICAL first, then HIGH, MEDIUM, LOW
- Each issue: File:line, pattern detected, impact estimate, fix with code example
- Verification checklist: Key items to confirm after fixes
Output Limits
If >50 issues in one category: Show top 10, provide total count, list top 3 files If >100 total issues: Summarize by category, show only CRITICAL/HIGH details
Audit Guidelines
- Run searches for all 8 pattern categories
- Verify with counts (e.g., "5 startUpdatingLocation, 2 stopUpdatingLocation")
- Provide file:line references
- Show exact fixes with code examples
- Estimate overall power impact percentage
False Positives (Not Issues)
- Timers with tolerance already set
- One-shot timers (
repeats: false) - Location with appropriate distanceFilter
- Push notification handlers
- Discretionary network sessions
- Audio session deactivation present
Related
For detailed optimization patterns: axiom-energy skill
For Power Profiler workflows: axiom-energy-ref skill
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
axiom-mapkit-diag
MapKit troubleshooting — annotations not appearing, region jumping, clustering not working, search failures, overlay rendering issues, user location problems
axiom-core-location
Use for Core Location implementation patterns - authorization strategy, monitoring strategy, accuracy selection, background location
axiom-energy
Use when app drains battery, device gets hot, users report energy issues, or auditing power consumption - systematic Power Profiler diagnosis, subsystem identification (CPU/GPU/Network/Location/Display), anti-pattern fixes for iOS/iPadOS
axiom-audit-storage
Use when the user mentions file storage issues, data loss, backup bloat, or asks to audit storage usage.
axiom-app-store-connect-ref
Use when navigating App Store Connect to find crash data, read TestFlight feedback, interpret metrics dashboards, or export diagnostic logs. Covers crash-free rates, dSYM symbolication, termination types, MetricKit.
axiom-testflight-triage
Use when ANY beta tester reports a crash, ANY crash appears in Organizer or App Store Connect, crash logs need symbolication, app was killed without crash report, or you need to triage TestFlight feedback
Didn't find tool you were looking for?