Skip to content
Agent Orchestration
Skill

/swiftui-performance-audit

Audit and improve SwiftUI runtime performance. Use for requests to diagnose slow rendering, janky scrolling, high CPU/memory usage, excessive view updates, or layout thrash in SwiftUI apps.

From plugin
termio
66429 skills

Claude Code

$ npx -y skills add termio-sh/termio --skill swiftui-performance-audit --agent claude-code

SKILL.md

swiftui-performance-audit.SKILL.md
name: performance-audit
description: Audit and improve SwiftUI runtime performance. Use for requests to diagnose slow rendering, janky scrolling, high CPU/memory usage, excessive view updates, or layout thrash in SwiftUI apps.

SwiftUI Performance Audit

Overview

Audit SwiftUI view performance from instrumentation and baselining to root-cause analysis and concrete remediation steps.

Workflow Decision Tree

1. **If user provides code**: Start with Code-First Review 2. **If user only describes symptoms**: Ask for minimal code/context, then Code-First Review 3. **If code review is inconclusive**: Guide user to profile with Instruments

1. Code-First Review

Collect

  • Target view/feature code
  • Data flow: state, environment, observable models
  • Symptoms and reproduction steps

Focus On

  • View invalidation storms from broad state changes
  • Unstable identity in lists (`id` churn, `UUID()` per render)
  • Heavy work in `body` (formatting, sorting, image decoding)
  • Layout thrash (deep stacks, `GeometryReader`, preference chains)
  • Large images without downsampling
  • Over-animated hierarchies (implicit animations on large trees)

Provide

  • Likely root causes with code references
  • Suggested fixes and refactors
  • Minimal repro or instrumentation suggestion if needed

2. Guide User to Profile

If code review is inconclusive, explain how to collect data:

1. Use SwiftUI template in Instruments (Release build) 2. Reproduce the exact interaction (scroll, navigation, animation) 3. Capture SwiftUI timeline and Time Profiler 4. Export or screenshot relevant lanes and call tree

Ask for:

  • Trace export or screenshots
  • Device/OS/build configuration

3. Common Code Smells (and Fixes)

Expensive formatters in `body`

**Bad:**

var body: some View {
    let formatter = NumberFormatter()  // Slow allocation every render
    Text(formatter.string(from: value))
}

**Good:**

final class Formatters {
    static let number = NumberFormatter()
}

var body: some View {
    Text(Formatters.number.string(from: value))
}

Computed properties with heavy work

**Bad:**

var filtered: [Item] {
    items.filter { $0.isEnabled }  // Runs every body eval
}

**Good:**

@State private var filtered: [Item] = []

.onChange(of: items) {
    filtered = items.filter { $0.isEnabled }
}

Sorting/filtering in ForEach

**Bad:**

ForEach(items.sorted(by: sortRule)) { item in
    Row(item)
}

**Good:**

let sortedItems = items.sorted(by: sortRule)  // Compute once
ForEach(sortedItems) { item in
    Row(item)
}

Unstable identity

**Bad:**

ForEach(items, id: \.self) { item in  // \.self may not be stable
    Row(item)
}

**Good:**

ForEach(items, id: \.stableID) { item in
    Row(item)
}

Image decoding on main thread

**Bad:**

Image(uiImage: UIImage(data: data)!)

**Good:**

// Decode/downsample off main thread, cache the result
@State private var image: UIImage?

.task {
    image = await ImageLoader.load(data: data, targetSize: size)
}

Broad dependencies in observable models

**Bad:**

@Observable class Model {
    var items: [Item] = []
}

var body: some View {
    Row(isFavorite: model.items.contains(item))  // Entire array dependency
}

**Good:**

// Granular view models or per-item state to reduce update fan-out

4. Remediation Strategies

| Issue | Fix | |-------|-----| | Broad state changes | Narrow scope with `@State`/`@Observable` closer to leaves | | Unstable identities | Use stable, unique IDs for `ForEach` | | Heavy work in body | Precompute, cache, move to `@State` | | Expensive subtrees | Use `equatable()` or value wrappers | | Large images | Downsample before rendering | | Layout complexity | Reduce nesting, use fixed sizing where possible |

5. Verify

Ask user to re-run same capture and compare with baseline:

  • CPU usage
  • Frame drops
  • Memory peak

Output Format

Provide: 1. Metrics table (before/after if available) 2. Top issues (ordered by impact) 3. Proposed fixes with estimated effort

Profiling Commands

# Build for profiling
xcodebuild -scheme MyApp -configuration Release -destination 'platform=iOS Simulator,name=iPhone 15 Pro' build

# Open in Instruments
open -a Instruments

Instruments Checklist

  • [ ] Use Release build (not Debug)
  • [ ] Select SwiftUI template
  • [ ] Reproduce exact problematic interaction
  • [ ] Look at SwiftUI timeline for body evaluations
  • [ ] Check Time Profiler for hot spots
  • [ ] Note frame rate drops in Animation timeline
Read more
@termio-sh
Ships withtermio

A terminal-first agentic development environment for agentic coding. Build for CLI/TUI agent. Runtime for Coding Agent, Tmux alternative

Stars on GitHub

Momentum

stars in total
664
Star history of termio-sh/termio on GitHub, a chart by star-history.com

Other skills on termio.

termio-device

termio-device

See and drive the sibling agent sessions running alongside you on this machine via the `termio session` CLI — list them and their…

@termio-sh@termio-shInstall Skill
termio

termio

See and drive the sibling agent sessions running alongside you in this Termio project via the `termio session` CLI — list and…

@termio-sh@termio-shInstall Skill
animation-vocabulary

animation-vocabulary

Reverse-lookup glossary that turns a vague description of a web animation or motion effect into its exact term ("the bouncy thing…

@termio-sh@termio-shInstall Skill
app-screenshot-debug

app-screenshot-debug

Drive the running termio app via AppleScript / System Events to reach a UI state (focus the window, click a sidebar project, a…

@termio-sh@termio-shInstall Skill
apple-design

apple-design

Apple's approach to interface design and fluid, physical motion, translated for the web. Use when building or reviewing…

@termio-sh@termio-shInstall Skill
asc

asc

Drive App Store Connect from the terminal with the `asc` CLI — TestFlight builds, groups, testers and What to Test notes; App…

@termio-sh@termio-shInstall Skill

More skills from other plugins.

1password

1password

Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.

openclaw7d395k
@steipete@steipeteInstall Skill
jira-tickets

jira-tickets

Read and update Jira tickets through Orca's saved Jira connections. Use when a task comes from Jira or the user asks for Jira…

orca5d128k
@stablyai@stablyaiInstall Skill
agentmail

agentmail

Use your assigned AgentMail inbox to read email tasks, explicitly send or reply, and check delivery. Provided automatically by…

paperclip6d114k
@paperclipai@paperclipaiInstall Skill
adr-create

adr-create

Create a new Architecture Decision Record with sequential numbering and AgentDB registration

@ruvnet@ruvnetInstall Skill

Questions about swiftui-performance-audit.

Which coding agents can use swiftui-performance-audit?
swiftui-performance-audit installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.