Audit and improve SwiftUI runtime performance from code review and architecture. Use for requests to diagnose slow rendering, janky scrolling, high CPU/memory usage, excessive view updates, or layout thrash in SwiftUI apps, and to provide guidance for user-run Instruments profiling when code review alone is insufficient.
The SwiftUI Performance Audit skill is designed to diagnose and improve the runtime performance of SwiftUI applications by analyzing code and architecture. It helps identify and address common performance issues such as slow rendering, janky scrolling, high CPU/memory usage, excessive view updates, and layout thrash. This skill provides a systematic approach to pinpoint performance bottlenecks, from initial code reviews to guiding users through more detailed profiling with Instruments, making it invaluable for developers aiming to optimize their SwiftUI apps for smoother user experiences and better resource efficiency.
This skill is structured around a multi-step workflow, starting with a 'Code-First Review' to analyze the target view/feature code, data flow, and symptoms. It proceeds to guide users on how to profile their app using Instruments if code review alone is insufficient. Key areas of focus include issues with view invalidation, heavy work in the `body`, layout thrash, large images without downsampling, and over-animated hierarchies. The skill offers concrete remediation steps, such as narrowing state scope, stabilizing identities in lists, moving heavy work out of `body`, and optimizing images. It is an essential tool for SwiftUI developers looking to troubleshoot performance-related issues and improve the efficiency of their applications.
Target users for this skill include SwiftUI developers facing performance issues in their applications. It is useful for those dealing with performance degradation due to inefficient rendering, unnecessary state changes, excessive updates, or large views. This skill also benefits teams looking to review and optimize their existing codebase for better performance, as well as those aiming to learn effective profiling techniques using Instruments for SwiftUI apps.
Start by providing the target view/feature code along with details on the data flow and any symptoms or reproduction steps. If you only have a description of the problem, minimal code/context is still required to begin the review.
If the code review is inconclusive, the next step is to guide the user to profile their app using Instruments. You'll need to collect traces or screenshots from the SwiftUI timeline and Time Profiler to analyze further.
Yes, to use the profiling aspect, you will need a Release build of your SwiftUI app and access to the Instruments tool to capture performance data.
This skill is focused on diagnosing common SwiftUI performance problems, such as slow rendering, layout thrash, and high CPU/memory usage. It may not cover more complex system-level performance issues or non-SwiftUI-related performance problems.
This skill is designed for SwiftUI applications and should work with any version of SwiftUI that supports the use of Instruments for profiling, typically targeting recent versions of Xcode and macOS.
Quick Setup:
.claude/skills/Repository
steipete/agent-scripts