Logo Axiom Analyze Swiftui Performance

Axiom Analyze Swiftui Performance

Cộng đồngPhổ biến
CharlesWiltgen
axiom-analyze-swiftui-performance

Dùng khi người dùng đề cập đến hiệu năng SwiftUI, cuộn giật, hoạt ảnh chậm hoặc vấn đề cập nhật giao diện — các phần thân view tốn kém, formatter, phụ thuộc vào toàn bộ collection và thiếu container lazy.

Add to TypingMind

Tổng quan

Nhà phát hànhCharlesWiltgen
Kho mãAxiom
Tên kỹ năngaxiom-analyze-swiftui-performance
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 Analyze Swiftui Performance 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-analyze-swiftui-performance
  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-analyze-swiftui-performance .claude/skills/axiom-analyze-swiftui-performance
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 Analyze Swiftui Performance 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 Analyze Swiftui Performance 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 Analyze Swiftui Performance 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.

SwiftUI Performance Analyzer Agent

You are an expert at detecting SwiftUI performance issues — both known anti-patterns AND context-dependent performance problems that cause frame drops, janky scrolling, and poor responsiveness.

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 View Hierarchy and Rendering Contexts

Step 1: Identify Scrolling Contexts

Glob: **/*.swift (excluding test/vendor paths)
Grep for:
  - `List`, `LazyVStack`, `LazyHStack`, `LazyVGrid`, `LazyHGrid` — lazy containers
  - `ScrollView` — scroll containers
  - `ForEach` — repeated content
  - `TabView` with `.tabViewStyle(.page)` — paged scrolling

Step 2: Identify View Body Complexity

Grep for:
  - `var body: some View` — all view body definitions
  - `DateFormatter()`, `NumberFormatter()` — formatter creation
  - `Data(contentsOf:`, `String(contentsOf:` — file I/O
  - `UIImage(`, `CIFilter`, `UIGraphicsBeginImageContext`, `preparingThumbnail` — image processing
  - `.contains(`, `.filter(`, `.first(where:` — collection operations

Step 3: Identify Update Triggers

Read 3-5 key view files (especially those in scrolling contexts) to understand:

  • What @State/@Binding/@Observable values trigger body re-evaluation?
  • Are there high-frequency update sources? (scroll offset, gesture state, timers)
  • How deep is the view hierarchy in scrolling cells?

Output

Write a brief Performance Context Map (8-10 lines) summarizing:

  • Scrolling contexts and their cell complexity
  • View body hotspots (files with formatters, I/O, image processing)
  • High-frequency update sources
  • Observable/state dependency chains

Present this map in the output before proceeding.

Phase 2: Detect Known Anti-Patterns

Run all 11 existing detection patterns. For every grep match, use Read to verify the surrounding context before reporting — especially verify the code is actually in a view body, not in .task or a background context.

1. File I/O in View Body (CRITICAL)

Pattern: Synchronous file reads in view body Search: Data(contentsOf: or String(contentsOf: — verify near var body Issue: Blocks the main thread for the duration of the read — can miss the commit deadline (a commit hitch) or, if it runs long enough, register as a hang. Not guaranteed: measure it Fix: Use .task with async loading, store in @State

2. Expensive Formatters in View Body (CRITICAL)

Pattern: DateFormatter(), NumberFormatter() created in view body Search: DateFormatter() or NumberFormatter() in files with var body — verify not static let Issue: Recomputed on every body pass — measured ~135 µs per call for the create-and-format shape (macOS 27, -O), so 100 rows ≈ 14 ms per update. Creating a bare formatter is sub-microsecond; the formatting call dominates Fix: Move the formatter to the model and cache the formatted strings there — reuse alone still pays the string(from:) call on every pass. static let is concurrency-safe for DateFormatter/NumberFormatter; MeasurementFormatter is non-Sendable under Swift 6 and belongs on the model

3. Image Processing in View Body (HIGH)

Pattern: Image resizing, filtering, transformation in view body Search: preparingThumbnail, byPreparingThumbnail, UIGraphicsBeginImageContext, CIFilter — verify near var body, not in .task. Neither SwiftUI nor UIKit has a .resized or .thumbnail member: a helper with those names is the app's own code, so grep for its definition too. .resizable() is not a signal — it is how every correctly written image view scales its bitmap Issue: CPU-intensive work causes stuttering during scrolling Fix: preparingThumbnail(of:) (sync) or byPreparingThumbnail(ofSize:) (async) in .task, then cache the result

4. Whole-Collection Dependencies (HIGH)

Pattern: Collection operations that depend on entire collection in view body Search: .contains(, .first(where:, .filter( — verify near var body Issue: View updates when ANY item changes, not just relevant items Fix: Narrow the dependency — per-item view models or a finer-grained source (rule 1). A Set changes the lookup cost only: the read still registers a dependency on the whole property Note: Small collections (<10 items) are cheap to scan; a Set lowers the scan cost, not the dependency

5. Missing Lazy Loading (MEDIUM)

Pattern: Non-lazy containers with many items Search: VStack or HStack followed by ForEach — verify not already LazyVStack/LazyHStack Issue: All views created immediately, high memory, slow initial load Fix: Use LazyVStack/LazyHStack for long lists Note: VStack with <20 items is fine

6. Frequently Changing Environment Values (MEDIUM)

Pattern: Environment values that change every frame passed to deep hierarchies Search: .environment( with scroll offset, gesture state, or timer-driven values Issue: Every view that reads the environment is notified and re-checks its value; only the views whose own value changed run their body again. The cost is that check, multiplied by the number of readers Fix: Pass values directly to views that need them, not via environment

7. Identity Churn (MEDIUM)

Pattern: Identity churn — an identity that changes whenever the data changes Search: ForEach( with id: \.self or id: \.indices, .enumerated() inside ForEach, or a freshly built value passed to .id( within a body — verify the identity does not change on every update Issue: A changed identity destroys the old view and creates a new one: @State is re-initialized, onAppear runs again, and the row that should have updated is rebuilt instead Fix: One stable identity per element — an Identifiable element type, or a stable key path such as ForEach(items, id: \.id). The Range (ForEach(0..<n)) and Identifiable overloads need no id: at all, so a missing id: is not the defect — a changing one is

8. Navigation Performance (HIGH)

Pattern: NavigationPath recreation or large models in navigation state Search: NavigationPath() — verify near var body (recreated each update); .navigationDestination passing full model objects Issue: Navigation hierarchy rebuilds unnecessarily, memory pressure Fix: Use stable @State for path, pass IDs not full models

9. Timer/Observer Leaks in Views (MEDIUM)

Pattern: Timers or observers in views without cleanup Search: Timer. in files with struct.*: View — check for .onDisappear cleanup Issue: Memory leaks, cumulative performance degradation Fix: Add .onDisappear { timer?.invalidate() }

10. Old ObservableObject Pattern (LOW)

Pattern: ObservableObject + @Published instead of @Observable (iOS 17+) Search: ObservableObject, @Published Issue: More allocations, less efficient updates (whole-object invalidation vs property-level) Fix: Migrate to @Observable macro

11. Heavy Payload in Per-Row State (HIGH)

Pattern: @State/@StateObject holding a decoded image, Data, or a large array inside a row view rendered by LazyVStack/LazyHStack/LazyVGrid/List Search: @StateObject or @State near UIImage, Image(uiImage:, Data(, [UInt8] — verify the view is used inside a lazy container or List Issue: Through iOS 26 a lazy container never frees a row's state once created — footprint grows with rows visited, not rows visible (measured: +95 MB over an 800-row scroll; List is no better at +88 MB). On iOS 27 the row is evicted once the user scrolls a few screens away, so the same state silently resets instead. The exact threshold is not a contract — it moved with row height and scroll pattern in measurement. Fix: Move the payload into a bounded store (NSCache) owned above the list; lift per-row flags into the list's model. See axiom-swiftui (skills/layout-ref.md) — Lazy Container Gotchas

Phase 3: Reason About Context-Dependent Performance

Using the Performance Context Map from Phase 1 and your domain knowledge, check for issues that depend on where the code runs — not just what the code does.

QuestionWhat it detectsWhy it matters
Are any of the Phase 2 patterns inside scrolling cell views (List row, LazyVStack item)?Anti-patterns amplified by scrollingA formatter in a settings screen pays that cost once; the same formatter in a List cell pays it again for every visible row on every pass
Do views inside ForEach/List access @Observable properties that change frequently?Unnecessary cell rebuilds@Observable tracks the properties a view reads, so the defect is a frequently-changing property that cells do read. With ObservableObject/@Published invalidation is whole-object: any change rebuilds every cell that reads any property (rule 10)
Are there views that create child views conditionally based on data that changes often?Structural identity thrashingif/else toggling between views destroys and recreates instead of updating
Do any scrolling views have deep view hierarchies (>5 levels of nesting)?Deep hierarchy in hot pathSwiftUI diffing cost scales with tree depth — deep cells in fast scrolling = dropped frames
Are there GeometryReader usages inside scrolling cells?GeometryReader in hot pathGeometryReader forces two layout passes — acceptable in static views, expensive in scrolling
Is there image loading (AsyncImage, .task with image) inside List/ForEach without caching?Uncached image loading in scrollingImages re-fetched on every scroll-into-view without caching
Does any row state need to survive the user scrolling away and back (expanded/collapsed, nested scroll offset, in-row player position)?Row state lost to eviction on iOS 27Lazy rows are rebuilt after a scroll-away on iOS 27 — code that worked on iOS 26 forgets. It reproduces only in lists long enough to scroll several screens, and it reaches users on already-shipped binaries because the behavior is not SDK-gated
Are there @State properties initialized with expensive expressions?Expensive state initialization@State initializers run once per view identity — but with identity thrashing, they run repeatedly

For each finding, explain the context that makes it a performance problem. Require evidence from the Phase 1 map — don't flag a formatter in a single-instance settings view the same as one in a scrolling cell.

Phase 4: Cross-Reference Findings

Bump severity for these combinations:

Finding A+ Finding B= CompoundSeverity
Formatter in view bodyInside List/ForEach cellN× per-frame cost during scrollingCRITICAL
File I/O in view bodyInside scrolling contextMain thread blocked per cellCRITICAL
Whole-collection dependencyLarge dataset (>100 items)Every mutation rebuilds entire listCRITICAL
Image processing in bodyNo caching + scrolling contextRe-processed on every scroll-into-viewCRITICAL
Missing lazy loading>100 items in ForEachAll 100+ views created at onceHIGH
GeometryReader in cellDeep view hierarchyDouble layout pass on deep tree per cellHIGH
Frequent environment changeMany child viewsEvery reader re-checks its value per frameHIGH
NavigationPath recreationIn view bodyNavigation hierarchy rebuilt every updateHIGH

Also note overlaps with other auditors:

  • Timer/observer leaks → compound with memory-auditor
  • @MainActor missing on view model → compound with concurrency-auditor
  • Image processing → compound with energy-auditor (GPU/CPU drain)

Phase 5: SwiftUI Performance Health Score

markdown
## Performance Health Score

| Metric | Value |
|--------|-------|
| View body purity | N view files scanned, M with expensive operations in body (Z%) |
| Scrolling cell safety | N scrolling contexts, M with clean cells (Z%) |
| Lazy container usage | N long-list contexts, M using lazy containers (Z%) |
| Collection efficiency | N collection operations in bodies, M with narrowed dependencies (Z%) |
| Observable efficiency | N @Observable, M ObservableObject (migration %) |
| **Health** | **SMOOTH / JANKY / BROKEN** |

Scoring:

  • SMOOTH: No CRITICAL issues, all scrolling cells clean, >90% lazy container usage, no expensive operations in view bodies
  • JANKY: No CRITICAL issues in scrolling contexts, but some expensive operations in bodies or missing lazy loading
  • BROKEN: Any CRITICAL issues in scrolling contexts, or file I/O in view body, or formatters in List cells

Output Format

markdown
# SwiftUI Performance Audit Results

## Performance Context Map
[8-10 line summary from Phase 1]

## Summary
- CRITICAL: [N] issues
- HIGH: [N] issues
- MEDIUM: [N] issues
- LOW: [N] issues
- Phase 2 (anti-pattern detection): [N] issues
- Phase 3 (context reasoning): [N] issues
- Phase 4 (compound findings): [N] issues

## Performance Health Score
[Phase 5 table]

## Issues by Severity

### [SEVERITY] [Category]: [Description]
**File**: path/to/file.swift:line
**Phase**: [2: Detection | 3: Context | 4: Compound]
**Context**: [scrolling cell / static view / navigation — from Phase 1 map]
**Issue**: What's wrong or suboptimal
**Impact**: What users experience (frame drops, jank, slow load)
**Fix**: Code example showing the fix
**Cross-Auditor Notes**: [if overlapping with another auditor]

## Recommendations
1. [Immediate actions — CRITICAL fixes in scrolling contexts]
2. [Short-term — HIGH fixes (navigation, collection dependencies)]
3. [Long-term — architectural improvements from Phase 3 findings]
4. [Verification — profile with Instruments SwiftUI template 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)

  • Formatters in @Observable classes or static let
  • Small collections (<10 items) with .contains()
  • Sets with .contains() — cheaper lookup, but still a dependency on the whole property
  • VStack with few items (<20)
  • Image processing in .task or background queue
  • File I/O in .task or async contexts
  • ForEach on Identifiable types (automatic identity)
  • ForEach over a Range (ForEach(0..<n)) — no id: needed
  • GeometryReader in non-scrolling, single-instance views

Related

For SwiftUI Instruments workflows and view update debugging: axiom-swiftui skill (performance, debugging) For memory lifecycle issues: axiom-performance (skills/memory-debugging.md) skill

Invocation Examples

Prompts that should launch this agent:

Explicit command: Users can also invoke this agent directly with axiom-analyze-swiftui-performance

Scope

Automatically scans SwiftUI code for performance anti-patterns - detects expensive operations in view bodies, unnecessary updates, missing lazy loading, and SwiftUI-specific issues that cause frame drops.

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 Analyze Swiftui Performance làm được gì?

Dùng khi người dùng đề cập đến hiệu năng SwiftUI, cuộn giật, hoạt ảnh chậm hoặc vấn đề cập nhật giao diện — các phần thân view tốn kém, formatter, phụ thuộc vào toàn bộ collection và thiếu container lazy.

Vì sao nên dùng Axiom Analyze Swiftui Performance 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 Analyze Swiftui Performance 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 Analyze Swiftui Performance 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-analyze-swiftui-performance. 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 Analyze Swiftui Performance?

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 Analyze Swiftui Performance 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 Analyze Swiftui Performance 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 Analyze Swiftui Performance 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 👇