Skip to content
Development
Skill

/axiom-analyze-swiftui-performance

Use when the user mentions SwiftUI performance, janky scrolling, slow animations, or view update issues — expensive bodies, formatters, whole-collection dependencies, and missing lazy containers.

From plugin
axiom
1.2k69 skills42 agents17 commands1 MCP
Install
$ npx -y skills add charleswiltgen/axiom --skill axiom-analyze-swiftui-performance --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/axiom-analyze-swiftui-performance

Context preview

The summary Claude sees to decide when to auto-load this skill.

Use when the user mentions SwiftUI performance, janky scrolling, slow animations, or view update issues — expensive bodies, formatters, whole-collection dependencies, and missing lazy containers.

SKILL.md

axiom-analyze-swiftui-performance.SKILL.md
name: axiom-analyze-swiftui-performance
description: Use when the user mentions SwiftUI performance, janky scrolling, slow animations, or view update issues — expensive bodies, formatters, whole-collection dependencies, and missing lazy containers.
license: MIT

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 e

Read more
Ships withaxiom

Battle-tested skills, agents, and tools for modern Apple OS development — Swift 6, SwiftUI, Liquid Glass, Apple Intelligence, and more. Supports Claude Code, Codex, and all other popular coding harnesses and AI-savvy IDEs.

Get the whole plugin

Other skills on axiom.