swiftui-performance-audit

Audit SwiftUI code and guide Instruments profiling to diagnose rendering bottlenecks.

330|47|Updated Aug 30, 2020
One-click install
npx skills add https://github.com/harperreed/dotfiles --skill swiftui-performance-audit-harperreed
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-performance-audit
Source: https://github.com/harperreed/dotfiles/tree/main/.claude/skills/swiftui-performance-audit
Command: npx skills add https://github.com/harperreed/dotfiles --skill swiftui-performance-audit-harperreed

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps you identify why your SwiftUI app feels slow—such as janky scrolling, slow navigation, excessive CPU/memory use, or frequent view updates—and turn that evidence into concrete remediation steps.

Core Features & Use Cases

  • Code-first SwiftUI review: pinpoints likely causes like view invalidation storms, unstable list identity, expensive work inside body, layout thrash, and over-animated hierarchies.
  • Instruments-guided profiling: helps you decide what to capture (SwiftUI timeline + Time Profiler) and what to share so the diagnosis is traceable to real bottlenecks.
  • Actionable fixes + verification: proposes targeted refactors (narrow state scope, precompute/cache heavy logic, stabilize ForEach identity, reduce layout complexity) and guides re-measurement to confirm improvements.

Quick Start

Ask the AI to audit your slow SwiftUI screen by reviewing the relevant view code and suggesting what to profile in Instruments if the review does not conclusively explain the hitch.

Frequently Asked Questions about swiftui-performance-audit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I diagnose slow SwiftUI rendering and fix janky scrolling?

Diagnose slow SwiftUI rendering by first auditing view code for unstable list identity and excessive state updates, then capturing SwiftUI timeline and Time Profiler traces in Instruments to pinpoint bottlenecks and guide targeted refactors.

Why does my SwiftUI view body update so frequently and cause performance issues?

Frequent SwiftUI view body updates occur when observable models fan out excessive state changes or perform expensive work inside the body. Auditing state scope and precomputing heavy logic reduces invalidation storms and stabilizes rendering performance.

What's the best way to profile SwiftUI layout thrash and view invalidation in Instruments?

The best way to profile layout thrash is capturing the SwiftUI timeline alongside Time Profiler in Instruments, which traces view invalidation patterns and layout complexity back to specific code paths for targeted remediation.

How do I fix unstable list identity churn in SwiftUI ForEach loops?

Fix unstable list identity churn in SwiftUI ForEach by stabilizing item identifiers so views track elements correctly across updates. This prevents unnecessary view recreation and reduces scrolling hitching caused by identity mismatches.

Can this Instruments-guided profiling workflow help identify excessive CPU usage from SwiftUI state updates?

Yes, the Instruments-guided profiling workflow captures Time Profiler traces to identify excessive CPU usage caused by SwiftUI state update fan-out. It correlates observable model changes with view body evaluations to isolate expensive state-driven computations.

When should I move expensive logic out of a SwiftUI view body to improve performance?

Move expensive logic out of a SwiftUI view body when Instruments traces show long body evaluation times or layout thrash. Precomputing and caching heavy operations narrows state scope and prevents unnecessary recomputation during view invalidation cycles.