Skill Overview
--- name: swiftui-performance-audit description: 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. --- # SwiftUI Performance Audit _Attribution: copied from @Dimillian’s `Dimillian/Skills` (2025-12-31)._ ## Overview Audit SwiftUI view performance end-to-end, from instrumentation and baselining to root-cause analysis and concrete remediation steps. ## Workflow Decision Tree - If the user provides code, start with "Code-First Review." - If the user only describes symptoms, ask for minimal code/context, then do "Code-First Review." - If code review is inconclusive, go to "Guide the User to Profile" and ask for a trace or screenshots. ## 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 or resizing. - Over-animated hierarchies (implicit animations on large trees). Provide: - Likely root causes with code references. - Suggested fixes and refactors. - If needed, a minimal repro or instrumentation suggestion. ## 2. Guide the User to Profile Explain how to collect data with Instruments: - Use the SwiftUI template in Instruments (Release build). - Reproduce the exact interaction (scroll, navigation, animation). - Capture SwiftUI timeline and Time Profiler. - Export or screenshot the relevant lanes and the call tree. Ask for: - Trace export or screenshots of SwiftUI lanes + Time Profiler call tree. - Device/OS/buil
Bot Reviews(1)
SwiftUI slowdown triage with an escalation path
Audits interface rendering performance starting from code, looking for invalidation storms, unstable list identity, heavy work inside view bodies and layout thrash. When static inspection is not decisive the skill stops guessing and hands the user a procedure for collecting a trace on a release build, then asks for the call tree and timeline screenshots before concluding. That division of labour is the honest part, since no profiling happens automatically and the analysis is only as good as the diagnostics supplied. Symptom-only reports are asked for minimal reproducing code first. Oversized images that skip downsampling are flagged as a common cheap win.
Use case: Diagnosing janky scrolling in a SwiftUI screen
Study Guides(1)
Auditing view performance from code before profiling
This skill diagnoses slow rendering and jank in a ui framework by reading the code first and only moving to a profiler when the review is inconclusive. The workflow is a decision tree: code first review, then guided profiling, then concrete remediation. ## What it does - Looks for view invalidation storms caused by broad state changes. - Flags unstable list identity, such as identifiers regenerated on every render. - Finds heavy work inside the view body, including formatting, sorting and image decoding. - Checks for layout thrash from deep stacks and geometry readers. - Catches large images that are not downsampled and hierarchies with implicit animation everywhere. - Guides a profiler session when the code review does not explain the symptom. ## When it is the wrong choice It reasons about code and described symptoms, so a performance problem that only appears under real data or on a specific device can stay hidden. The profiler path needs a release build, a reproduced interaction and an exported trace, which is real work and cannot be done for you. The findings are ranked by likelihood rather than measured, so two plausible causes may need to be fixed one at a time to find the culprit. And it is a diagnosis tool: applying every suggestion at once makes it impossible to tell which change actually helped. ```json { "focus": [ "invalidation storms from broad state changes", "unstable list identity", "heavy work inside the view body", "layout thrash", "large images without downsampling" ], "next_step": "profile a release build and export the trace" } ``` ## Working notes - Profiling uses a release build and the framework specific template. - A trace or screenshots of the relevant lanes are what the review needs. - Symptoms and reproduction steps are collected before any diagnosis.
Quick Facts
Install
npx clawhub@latest install swiftui-performance-audit