Logo Axiom Audit Energy

Axiom Audit Energy

Cộng đồngPhổ biến
CharlesWiltgen
axiom-audit-energy

Dùng khi bạn nhắc đến tình trạng hao pin, tối ưu năng lượng, kiểm tra mức tiêu thụ điện hoặc kiểm tra năng lượng trước khi phát hành — chẳng hạn như lạm dụng bộ hẹn giờ, thăm dò liên tục, theo dõi vị trí liên tục, rò rỉ hoạt ảnh và sử dụng sai chế độ chạy nền.

Add to TypingMind

Tổng quan

Nhà phát hànhCharlesWiltgen
Kho mãAxiom
Tên kỹ năngaxiom-audit-energy
Sao
1.2K
Bản fork
86
Tệp đi kèm
1
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 1 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được CharlesWiltgen công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Axiom Audit Energy trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/CharlesWiltgen/Axiom/tree/main/axiom-codex/skills/axiom-audit-energy
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/CharlesWiltgen/Axiom.git /tmp/Axiom
mkdir -p .claude/skills
cp -r /tmp/Axiom/axiom-codex/skills/axiom-audit-energy .claude/skills/axiom-audit-energy
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Axiom Audit Energy trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Axiom Audit Energy ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Axiom Audit Energy với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

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.

QuestionWhat it detectsWhy 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 lifecycleA 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 visibilityGPS 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 entitlementsSystem 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 activityEach 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 offscreenGPU work for invisible content wastes 100% of its energy
Does the app deactivate its audio session when not actually playing audio?Always-active audio sessionActive 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 workHeavy 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/stopstartUpdatingLocation 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= CompoundSeverity
Timer without toleranceHigh frequency (<1s interval)CPU never sleepsCRITICAL
Polling network requestsOn cellular without constraintsRadio stays permanently awakeCRITICAL
Continuous locationIn background modeGPS drains battery even when app not visibleCRITICAL
Animation leak120fps frame rateMaximum GPU power draw for invisible workCRITICAL
Background mode registeredNo matching feature codeSystem grants wasted background timeHIGH
Audio session always activeApp is not an audio appPrevents system sleep optimizationsHIGH
Multiple separate network requestsNo batching strategyCellular radio restart penalty per requestHIGH
Timer runningFeature screen not visibleEnergy spent on unused featureHIGH

Also note overlaps with other auditors:

  • Timer without invalidate → compound with memory-auditor
  • Animation without onDisappear cleanup → compound with memory-auditor
  • Background URLSession → compound with networking-auditor
  • Continuous location without stop → compound with concurrency-auditor (asymmetric lifecycle)

Phase 5: Energy Health Score

markdown
## Energy Health Score

| Metric | Value |
|--------|-------|
| Timer discipline | N timers, M with tolerance (Z%), repeating without invalidate: N |
| Location lifecycle | startUpdating: N, stopUpdating: M (match: yes/no), accuracy level |
| Network efficiency | N request patterns, M batched/discretionary (Z%) |
| Animation lifecycle | N animations/display links, M with visibility cleanup (Z%) |
| Background modes | N registered, M with matching code (Z%) |
| Estimated idle drain | [sum of pattern impacts] %/hour above baseline |
| **Health** | **EFFICIENT / WASTEFUL / DRAINING** |

Scoring:

  • EFFICIENT: No CRITICAL issues, all timers have tolerance, location starts match stops, no unnecessary background modes, estimated <2% idle drain above baseline
  • WASTEFUL: No CRITICAL issues, but some timers without tolerance, or unused background modes, or network batching opportunities missed
  • DRAINING: Any CRITICAL issues, or continuous location without stop, or polling without push alternative, or estimated >5% idle drain above baseline

Output Format

markdown
# Energy Audit Results

## Energy Profile Map
[8-10 line summary from Phase 1]

## Summary
- CRITICAL: [N] issues (estimated [X]% battery drain/hour)
- HIGH: [N] issues
- MEDIUM: [N] issues
- LOW: [N] issues
- Phase 2 (anti-pattern detection): [N] issues
- Phase 3 (unnecessary work reasoning): [N] issues
- Phase 4 (compound findings): [N] issues

## Energy Health Score
[Phase 5 table]

## Verification Counts
- Timers: N created, M with tolerance, K invalidated
- Location: N start calls, M stop calls
- Network: N request patterns, M batched
- Animations: N created, M stopped on disappear

## Issues by Severity

### [SEVERITY] [Category]: [Description]
**File**: path/to/file.swift:line
**Phase**: [2: Detection | 3: Unnecessary Work | 4: Compound]
**Issue**: What's wrong or unnecessary
**Impact**: Estimated power cost (X% battery drain/hour)
**Fix**: Code example showing the fix
**Cross-Auditor Notes**: [if overlapping with another auditor]

## Recommendations
1. [Immediate actions — CRITICAL fixes (biggest battery impact)]
2. [Short-term — HIGH fixes (lifecycle cleanup, background mode audit)]
3. [Long-term — architectural improvements from Phase 3 findings]
4. [Verification — profile with Power Profiler in Instruments 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

False Positives (Not Issues)

  • Timers with tolerance already set
  • One-shot timers (repeats: false)
  • Location with appropriate distanceFilter set
  • Push notification handlers (not polling)
  • Discretionary network sessions
  • Audio session with matching deactivation
  • Background modes with matching feature code
  • CADisplayLink in active game/animation screens (expected GPU usage)

Field Termination Correlation

Energy anti-patterns surface in the field as system terminations, not slow-draining batteries. When the user has .ips artifacts, xcsym's pattern_tag flags the termination mode directly:

pattern_tagEnergy anti-pattern it exposes
cpu_resource_fatalCPU budget exceeded — tight timer loops, animation leaks, or busy-wait polling (Patterns 1, 4)
background_task_expiredBGTask didn't call setTaskCompleted (Pattern 5) or exceeded its 30s budget
watchdog_terminationMain-thread hang from a sync I/O/network call blocking rendering (Pattern 6/8)
jetsam_oomBackground memory growth — often a timer/animation retaining state across backgrounding
bash
xcsym crash --format=summary <path-to-ips>

Use the crashed-thread frames to pinpoint which Phase 1 background-activity owner is the culprit.

Related

For detailed optimization patterns: axiom-performance (skills/energy.md) skill For Power Profiler workflows: axiom-performance (skills/energy-ref.md) skill For timer lifecycle issues: axiom-integration (skills/timer-patterns.md) For symbolicating CPU/background/watchdog terminations: axiom-tools (skills/xcsym-ref.md)

Invocation Examples

Prompts that should launch this agent:

Explicit command: Users can also invoke this agent directly with axiom-audit-energy

Scope

Automatically scans codebase for the 8 most common energy anti-patterns - timer abuse, polling instead of push, continuous location, animation leaks, background mode misuse, network inefficiency, GPU waste, and disk I/O patterns.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Axiom Audit Energy làm được gì?

Dùng khi bạn nhắc đến tình trạng hao pin, tối ưu năng lượng, kiểm tra mức tiêu thụ điện hoặc kiểm tra năng lượng trước khi phát hành — chẳng hạn như lạm dụng bộ hẹn giờ, thăm dò liên tục, theo dõi vị trí liên tục, rò rỉ hoạt ảnh và sử dụng sai chế độ chạy nền.

Vì sao nên dùng Axiom Audit Energy trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Axiom Audit Energy là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Axiom Audit Energy trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/CharlesWiltgen/Axiom/tree/main/axiom-codex/skills/axiom-audit-energy. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Axiom Audit Energy?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Axiom Audit Energy với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Axiom Audit Energy với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Axiom Audit Energy có miễn phí không?

Có. Kỹ năng này được CharlesWiltgen phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇