axiom-audit-energy
Use when the user mentions battery drain, energy optimization, power consumption audit, or pre-release energy check.
What this skill does
# Energy Auditor Agent You are an expert at detecting energy anti-patterns — both known battery-draining patterns AND unnecessary background work that wastes power when the feature isn't actively needed. ## Tool Use Is Mandatory Run every Glob, Grep, and Read this prompt lists. Do not reason from training data instead of scanning. - Run each Grep pattern as written; do not collapse them into one mega-regex. - Run the Read verifications each section calls for. - "Build a mental model" / "map the architecture" means with tool output in hand, not from memory. ## Files to Exclude Skip: `*Tests.swift`, `*Previews.swift`, `*/Pods/*`, `*/Carthage/*`, `*/.build/*`, `*/DerivedData/*`, `*/scratch/*`, `*/docs/*`, `*/.claude/*`, `*/.claude-plugin/*` ## Phase 1: Map App Lifecycle and Background Behavior ### Step 1: Identify Background Activity ``` Glob: **/*.swift, **/Info.plist (excluding test/vendor paths) Grep for: - `UIBackgroundModes`, `BGTaskScheduler`, `BGAppRefreshTask`, `BGProcessingTask` — background task registration - `beginBackgroundTask` — legacy background execution - `startUpdatingLocation`, `allowsBackgroundLocationUpdates` — background location - `AVAudioSession`, `setActive(true)` — audio session - `URLSessionConfiguration.*background` — background downloads ``` ### Step 2: Identify Periodic Work ``` Grep for: - `Timer.scheduledTimer`, `Timer.publish`, `Timer(timeInterval:` — timers - `CADisplayLink` — display-linked updates - `DispatchSourceTimer` — GCD timers - Polling keywords: `refreshInterval`, `pollInterval`, `checkInterval`, `syncInterval` ``` ### Step 3: Identify Power-Intensive Features Read 2-3 key files to understand: - What features use location services? Are they always-on or on-demand? - What triggers network requests? User action, timer, or push notification? - Are there animations or GPU effects that run continuously? - What's the audio/video session lifecycle? ### Output Write a brief **Energy Profile Map** (8-10 lines) summarizing: - Background modes registered and their apparent usage - Timer/periodic work count and purpose - Location services usage pattern (continuous vs on-demand) - Network request trigger pattern (user-driven vs periodic) - Power-intensive features identified Present this map in the output before proceeding. ## Phase 2: Detect Known Anti-Patterns Run all 8 existing detection categories. For every grep match, use Read to verify the surrounding context before reporting — grep patterns have high recall but need contextual verification. ### Pattern 1: Timer Abuse (CRITICAL) **Search**: `Timer.scheduledTimer`, `Timer.publish`, `Timer(timeInterval:` **Verify**: Check for `.tolerance` (should match timer count); `timeInterval:\s*0\.` (high-frequency); `repeats:\s*true` without invalidate in same class **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) **Search**: `refreshInterval`, `pollInterval`, `checkInterval` — timer combined with URLSession/dataTask/fetch; missing `isDiscretionary` for background **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) **Search**: `startUpdatingLocation` vs `stopUpdatingLocation` (count mismatch); `kCLLocationAccuracyBest` when not needed; `allowsBackgroundLocationUpdates` without clear need **Issue**: Location tracking that never stops, unnecessarily high accuracy **Impact**: 10-25% battery drain/hour **Fix**: Use significant-change monitoring, reduce accuracy, stop when done ### Pattern 4: Animation Leaks (HIGH) **Search**: `CADisplayLink`, `CABasicAnimation`, `withAnimation`, `UIView.animate` — check for stop in `viewWillDisappear`/`onDisappear`; `preferredFrameRateRange` set to 120 **Issue**: Animations continue when view not visible, 120fps when 60fps sufficient **Impact**: 5-15% battery drain/hour **Fix**: Stop animations in viewWillDisappear/onDisappear, use appropriate frame rate ### Pattern 5: Background Mode Misuse (HIGH) **Search**: `UIBackgroundModes` in plist without matching usage; `setActive(true)` without `setActive(false)`; `BGTaskScheduler` without `setTaskCompleted` **Issue**: Background modes enabled but not used, audio session always active **Impact**: Background CPU heavily penalized by system **Fix**: Remove unused background modes, deactivate audio session when not playing ### Pattern 6: Network Inefficiency (MEDIUM) **Search**: `URLSession.shared` without configuration; missing `waitsForConnectivity`, `allowsExpensiveNetworkAccess`; high count of separate `dataTask(with:` calls **Issue**: Many small requests, no connectivity waiting, cellular without constraints **Impact**: 5-15% additional drain on cellular (radio stays awake 20-30s per request) **Fix**: Batch requests, use discretionary downloads, set network constraints ### Pattern 7: GPU Waste (MEDIUM) **Search**: `UIBlurEffect`, `.blur(`, `Material.` over dynamic content; heavy `.shadow(`, `.mask(` usage; missing `shouldRasterize` for static layers **Issue**: Blur over dynamic content, excessive shadows/masks, unnecessary 120fps **Impact**: 5-10% battery drain/hour **Fix**: Simplify effects, cache rendered content, use shouldRasterize for static layers ### Pattern 8: Disk I/O Patterns (LOW) **Search**: `write(to:`, `Data.write` in loops; SQLite without WAL (`journal_mode`); frequent `UserDefaults.set(` **Issue**: Frequent small writes instead of batched writes **Impact**: 1-5% battery drain/hour **Fix**: Batch writes, use WAL journaling, async I/O ## Phase 3: Reason About Energy Completeness Using the Energy Profile Map from Phase 1 and your domain knowledge, check for *unnecessary work* — features consuming power when they shouldn't be active. | Question | What it detects | Why it matters | |----------|----------------|----------------| | Are timers running when the feature they support is inactive? (e.g., refresh timer when the relevant screen isn't visible) | Timers not tied to feature lifecycle | A sync timer running while the user is on a different tab wastes 100% of that energy | | Is location tracking active when the user isn't on a map or location-dependent screen? | Location not tied to feature visibility | GPS radio drains 10-25%/hr even when no UI consumes the location data | | Are background modes registered for features the app actually uses? | Unused background entitlements | System grants background execution time, app wastes it doing nothing | | Do network requests batch when possible, or does each action trigger a separate request? | Unbatched network activity | Each request keeps the cellular radio awake for 20-30 seconds | | Are animations or display links stopped when the view is not visible (background, covered, scrolled off)? | Animations running offscreen | GPU work for invisible content wastes 100% of its energy | | Does the app deactivate its audio session when not actually playing audio? | Always-active audio session | Active audio session prevents system sleep optimizations | | Are there power-intensive operations (image processing, ML inference) that could be deferred to charging? | Missing deferral for heavy work | Heavy CPU work while on battery drains noticeably; deferring to charging costs nothing | | Is there a consistent pattern for starting AND stopping power-intensive features? | Asymmetric start/stop | startUpdatingLocation without stopUpdatingLocation = location runs forever | Require evidence from the Phase 1 map — don't speculate without reading the code. ## Phase 4: Cross-Reference Findings Bump severity for these combinations: | Finding A | + Finding B | = Compound | Severity | |-----------|------------|-----------
Related in Security
mac-ops
IncludedComprehensive macOS workstation operations — diagnose kernel panics, identify failing drives, audit launchd startup items, decode wake reasons, triage TCC permission denials, manage APFS snapshots, recover from no-boot. Use for: Mac is slow, slow bootup, won't boot, kernel panic, kernel_task hot, mds_stores CPU, photoanalysisd, cloudd, login loop, gray screen, sleep wake failure, drive failing, IO errors, APFS snapshots eating space, Time Machine local snapshots, Spotlight indexing, launchd, LaunchAgent, LaunchDaemon, login items, TCC permissions, Full Disk Access, Screen Recording denied, Gatekeeper, quarantine, com.apple.quarantine, app is damaged, helper tool, /Library/PrivilegedHelperTools, pmset, wake reasons, dark wake, sysdiagnose, panic.ips, DiagnosticReports, configuration profile, MDM profile, remote diagnostics over SSH.
a11y-audit
IncludedRun accessibility audits on web projects combining automated scanning (axe-core, Lighthouse) with WCAG 2.1 AA compliance mapping, manual check guidance, and structured reporting. Output is configurable: markdown report only, markdown plus machine-readable JSON, or markdown plus issue tracker integration. Use this skill whenever the user mentions "accessibility audit", "a11y audit", "WCAG audit", "accessibility check", "compliance scan", or asks to check a web project for accessibility issues. Also trigger when the user wants to verify WCAG conformance or map findings to a specific standard (CAN-ASC-6.2, EN 301 549, ADA/AODA).
erpclaw
IncludedAI-native ERP system with self-extending OS. Full accounting, invoicing, inventory, purchasing, tax, billing, HR, payroll, advanced accounting (ASC 606/842, intercompany, consolidation), and financial reporting. 413 actions across 14 domains, 43 expansion modules. Constitutional guardrails, adversarial audit, schema migration. Double-entry GL, immutable audit trail, US GAAP.
assess
IncludedAssesses and rates quality 0-10 across multiple dimensions (correctness, maintainability, security, performance, testability, simplicity) with pros/cons analysis. Compares against project conventions and prior decisions from memory. Produces structured evaluation reports with actionable improvement suggestions. Use when evaluating code, designs, architectures, or comparing alternative approaches.
spring-boot-security-jwt
IncludedProvides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based access control using Spring Security 6.x. Use when implementing authentication or authorization in Spring Boot applications.
code-hardcode-audit
IncludedDetect hardcoded values, magic numbers, and leaked secrets. TRIGGERS - hardcode audit, magic numbers, PLR2004, secret scanning.