axiom-energy-diag
36
总安装量
36
周安装量
#5682
全站排名
安装命令
npx skills add https://github.com/charleswiltgen/axiom --skill axiom-energy-diag
Agent 安装分布
claude-code
27
opencode
24
codex
21
cursor
20
gemini-cli
18
antigravity
18
Skill 文档
Energy Diagnostics
Symptom-based troubleshooting for energy issues. Start with your symptom, follow the decision tree, get the fix.
Related skills: axiom-energy (patterns, checklists), axiom-energy-ref (API reference)
Symptom 1: App at Top of Battery Settings
Users or you notice your app consuming significant battery.
Diagnosis Decision Tree
App at top of Battery Settings?
â
ââ Step 1: Run Power Profiler (15 min)
â ââ CPU Power Impact high?
â â ââ Continuous? â Timer leak or polling loop
â â â ââ Fix: Check timers, add tolerance, convert to push
â â ââ Spikes during actions? â Eager loading or repeated parsing
â â ââ Fix: Use LazyVStack, cache parsed data
â â
â ââ Network Power Impact high?
â â ââ Many small requests? â Batching issue
â â â ââ Fix: Batch requests, use discretionary URLSession
â â ââ Regular intervals? â Polling pattern
â â ââ Fix: Convert to push notifications
â â
â ââ GPU Power Impact high?
â â ââ Animations? â Running when not visible
â â â ââ Fix: Stop in viewWillDisappear
â â ââ Blur effects? â Over dynamic content
â â ââ Fix: Remove or use static backgrounds
â â
â ââ Display Power Impact high?
â ââ Light backgrounds on OLED?
â ââ Fix: Implement Dark Mode (up to 70% savings)
â
ââ Step 2: Check background section in Battery Settings
ââ High background time?
â ââ Location icon visible? â Continuous location
â â ââ Fix: Switch to significant-change monitoring
â ââ Audio active? â Session not deactivated
â â ââ Fix: Deactivate audio session when not playing
â ââ BGTasks running long? â Not completing promptly
â ââ Fix: Call setTaskCompleted sooner
â
ââ Background time appropriate?
ââ Issue is in foreground usage â Focus on CPU/GPU fixes above
Time-Cost Analysis
| Approach | Time | Accuracy |
|---|---|---|
| Run Power Profiler, identify subsystem | 15-20 min | High |
| Guess and optimize random areas | 4+ hours | Low |
| Read all code looking for issues | 2+ hours | Medium |
Recommendation: Always use Power Profiler first. It costs 15 minutes but guarantees you optimize the right subsystem.
Symptom 2: Device Gets Hot
Device temperature increases noticeably during app use.
Diagnosis Decision Tree
Device gets hot during app use?
â
ââ Hot during specific action?
â â
â ââ During video/camera use?
â â ââ Video encoding? â Expected, but check efficiency
â â â ââ Fix: Use hardware encoding, reduce resolution if possible
â â ââ Camera active unnecessarily? â Not releasing session
â â ââ Fix: Call stopRunning() when done
â â
â ââ During scroll/animation?
â â ââ GPU-intensive effects? â Blur, shadows, many layers
â â â ââ Fix: Reduce effects, cache rendered content
â â ââ High frame rate? â Unnecessary 120fps
â â ââ Fix: Use CADisplayLink preferredFrameRateRange
â â
â ââ During data processing?
â ââ JSON parsing? â Repeated or large payloads
â â ââ Fix: Cache parsed results, paginate
â ââ Image processing? â Synchronous on main thread
â ââ Fix: Move to background, cache results
â
ââ Hot during normal use (no specific action)?
â â
â ââ Run Power Profiler to identify:
â â ââ CPU high continuously â Timer, polling, tight loop
â â ââ GPU high continuously â Animation leak
â â ââ Network high continuously â Polling pattern
â â
â ââ Check for infinite loops or runaway recursion
â ââ Use Time Profiler in Instruments
â
ââ Hot only in background?
ââ Location updates continuous? â High accuracy or no stop
â ââ Fix: Reduce accuracy, stop when done
ââ Audio session active? â Hardware kept powered
â ââ Fix: Deactivate when not playing
ââ BGTask running too long? â System may throttle
ââ Fix: Complete tasks faster, use requiresExternalPower
Time-Cost Analysis
| Approach | Time | Outcome |
|---|---|---|
| Power Profiler + Time Profiler | 20-30 min | Identifies exact cause |
| Check code for obvious issues | 1-2 hours | May miss non-obvious causes |
| Wait for user complaints | N/A | Reputation damage |
Symptom 3: Background Battery Drain
App drains battery even when user isn’t actively using it.
Diagnosis Decision Tree
High background battery usage?
â
ââ Step 1: Check Info.plist background modes
â â
â ââ "location" enabled?
â â ââ Actually need background location?
â â â ââ YES â Use significant-change, lowest accuracy
â â â ââ NO â Remove background mode, use when-in-use only
â â ââ Check: Is stopUpdatingLocation called?
â â
â ââ "audio" enabled?
â â ââ Audio playing? â Expected
â â ââ Audio NOT playing? â Session still active
â â â ââ Fix: Deactivate session, use autoShutdownEnabled
â â ââ Playing silent audio? â Anti-pattern for keeping app alive
â â ââ Fix: Use proper background API (BGTask)
â â
â ââ "fetch" enabled?
â â ââ Check: Is earliestBeginDate reasonable? (not too frequent)
â â
â ââ "remote-notification" enabled?
â ââ Expected for push updates, check didReceiveRemoteNotification efficiency
â
ââ Step 2: Check BGTaskScheduler usage
â â
â ââ BGAppRefreshTask scheduled too frequently?
â â ââ Fix: Increase earliestBeginDate interval
â â
â ââ BGProcessingTask not using requiresExternalPower?
â â ââ Fix: Add requiresExternalPower = true for non-urgent work
â â
â ââ Tasks not completing? (setTaskCompleted not called)
â ââ Fix: Always call setTaskCompleted, implement expirationHandler
â
ââ Step 3: Check beginBackgroundTask usage
â
ââ endBackgroundTask called promptly?
â ââ Fix: Call immediately after work completes, not at expiration
â
ââ Multiple overlapping background tasks?
ââ Fix: Track task IDs, ensure each is ended
Common Background Drain Patterns
| Pattern | Power Profiler Signature | Fix |
|---|---|---|
| Continuous location | CPU lane + location icon | significant-change |
| Audio session leak | CPU lane steady | setActive(false) |
| Timer not invalidated | CPU spikes at intervals | invalidate in background |
| Polling from background | Network lane at intervals | Push notifications |
| BGTask too long | CPU sustained | Faster completion |
Time-Cost Analysis
| Approach | Time | Outcome |
|---|---|---|
| Check Info.plist + BGTask code | 30 min | Finds common issues |
| On-device Power Profiler trace | 1-2 hours (real usage) | Captures real behavior |
| User-collected trace | Variable | Best for unreproducible issues |
Symptom 4: High Energy Only on Cellular
Battery drains faster on cellular than WiFi.
Diagnosis Decision Tree
High battery drain on cellular only?
â
ââ Expected: Cellular radio uses more power than WiFi
â ââ But: Excessive drain indicates optimization opportunity
â
ââ Check URLSession configuration
â â
â ââ allowsExpensiveNetworkAccess = true (default)?
â â ââ Fix: Set to false for non-urgent requests
â â
â ââ isDiscretionary = false (default)?
â â ââ Fix: Set to true for background downloads
â â
â ââ waitsForConnectivity = false (default)?
â ââ Fix: Set to true to avoid failed connection retries
â
ââ Check request patterns
â â
â ââ Many small requests? â High connection overhead
â â ââ Fix: Batch into fewer larger requests
â â
â ââ Polling? â Radio stays active
â â ââ Fix: Push notifications
â â
â ââ Large downloads in foreground? â Could wait for WiFi
â ââ Fix: Use background URLSession with discretionary
â
ââ Check Low Data Mode handling
ââ Respecting allowsConstrainedNetworkAccess?
â ââ Fix: Set to false for non-essential requests
â
ââ Checking ProcessInfo.processInfo.isLowDataModeEnabled?
ââ Fix: Reduce payload sizes, defer non-essential transfers
Time-Cost Analysis
| Approach | Time | Outcome |
|---|---|---|
| Review URLSession configs | 15 min | Quick wins |
| Add discretionary flags | 30 min | Significant savings |
| Convert poll to push | 2-4 hours | Largest impact |
Symptom 5: Energy Spike During Specific Action
Noticeable battery drain or heat when performing particular operation.
Diagnosis Decision Tree
Energy spike during specific action?
â
ââ Step 1: Record Power Profiler during action
â ââ Note which subsystem spikes (CPU/GPU/Network/Display)
â
ââ CPU spike?
â â
â ââ Is it parsing data?
â â ââ Same data parsed repeatedly?
â â â ââ Fix: Cache parsed results (lazy var)
â â ââ Large JSON/XML payload?
â â ââ Fix: Paginate, stream parse, or use binary format
â â
â ââ Is it creating views?
â â ââ Many views at once?
â â â ââ Fix: Use LazyVStack/LazyHStack
â â ââ Complex view hierarchies?
â â ââ Fix: Simplify, use drawingGroup()
â â
â ââ Is it image processing?
â ââ On main thread?
â â ââ Fix: Move to background queue
â ââ No caching?
â ââ Fix: Cache processed images
â
ââ GPU spike?
â â
â ââ Starting animation?
â â ââ Fix: Ensure frame rate appropriate
â â
â ââ Showing blur effect?
â â ââ Fix: Use solid color or pre-rendered blur
â â
â ââ Complex render? (shadows, masks, many layers)
â ââ Fix: Simplify, use shouldRasterize, cache
â
ââ Network spike?
â â
â ââ Large download started?
â â ââ Fix: Use background URLSession, show progress
â â
â ââ Many parallel requests?
â â ââ Fix: Limit concurrency, batch
â â
â ââ Retrying failed requests?
â ââ Fix: Exponential backoff, waitsForConnectivity
â
ââ Display spike?
ââ Unusual unless changing brightness programmatically
ââ Fix: Don't modify brightness, let system control
Time-Cost Analysis
| Approach | Time | Outcome |
|---|---|---|
| Power Profiler during action | 5-10 min | Identifies subsystem |
| Time Profiler for CPU details | 10-15 min | Identifies function |
| Code review without profiling | 1+ hours | May miss actual cause |
Quick Diagnostic Checklist
Use this when you need fast answers:
30-Second Check
- Device plugged in? (Power metrics show 0)
- Debug build? (Less optimized than release)
- Low Power Mode on? (May affect measurements)
5-Minute Check (Power Profiler)
- Which subsystem is dominant? (CPU/GPU/Network/Display)
- Sustained or spiky?
- Foreground or background?
15-Minute Investigation
- If CPU: Run Time Profiler to identify function
- If Network: Check request frequency and size
- If GPU: Check animation frame rates
- If Background: Check Info.plist modes
Common Quick Fixes
| Finding | Quick Fix | Time |
|---|---|---|
| Timer without tolerance | Add .tolerance = 0.1 |
1 min |
| VStack with large ForEach | Change to LazyVStack | 1 min |
| allowsExpensiveNetworkAccess = true | Set to false | 1 min |
| Missing stopUpdatingLocation | Add stop call | 2 min |
| No Dark Mode | Add asset variants | 30 min |
| Audio session always active | Add setActive(false) | 5 min |
When to Escalate
Use axiom-energy skill when
- Need full audit checklist
- Want comprehensive patterns with code
- Planning proactive optimization
Use axiom-energy-ref skill when
- Need specific API details
- Want complete code examples
- Implementing from scratch
Use energy-auditor agent when
- Want automated codebase scan
- Looking for anti-patterns at scale
- Pre-release energy audit
Run: /axiom:audit energy
Last Updated: 2025-12-26 Platforms: iOS 26+, iPadOS 26+