swiftui-performance-auditAudit 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.
Install via ClawdBot CLI:
clawdbot install steipete/swiftui-performance-audit_Attribution: copied from @Dimillianโs Dimillian/Skills (2025-12-31)._
Audit SwiftUI view performance end-to-end, from instrumentation and baselining to root-cause analysis and concrete remediation steps.
Collect:
Focus on:
id churn, UUID() per render).body (formatting, sorting, image decoding).GeometryReader, preference chains).Provide:
Explain how to collect data with Instruments:
Ask for:
Prioritize likely SwiftUI culprits:
id churn, UUID() per render).body (formatting, sorting, image decoding).GeometryReader, preference chains).Summarize findings with evidence from traces/logs.
Apply targeted fixes:
@State/@Observable closer to leaf views).ForEach and lists.body (precompute, cache, @State).equatable() or value wrappers for expensive subtrees.Look for these patterns during code review.
bodyvar body: some View {
let number = NumberFormatter() // slow allocation
let measure = MeasurementFormatter() // slow allocation
Text(measure.string(from: .init(value: meters, unit: .meters)))
}
Prefer cached formatters in a model or a dedicated helper:
final class DistanceFormatter {
static let shared = DistanceFormatter()
let number = NumberFormatter()
let measure = MeasurementFormatter()
}
var filtered: [Item] {
items.filter { $0.isEnabled } // runs on every body eval
}
Prefer precompute or cache on change:
@State private var filtered: [Item] = []
// update filtered when inputs change
body or ForEachList {
ForEach(items.sorted(by: sortRule)) { item in
Row(item)
}
}
Prefer sort once before view updates:
let sortedItems = items.sorted(by: sortRule)
ForEachForEach(items.filter { $0.isEnabled }) { item in
Row(item)
}
Prefer a prefiltered collection with stable identity.
ForEach(items, id: \.self) { item in
Row(item)
}
Avoid id: \.self for non-stable values; use a stable ID.
Image(uiImage: UIImage(data: data)!)
Prefer decode/downsample off the main thread and store the result.
@Observable class Model {
var items: [Item] = []
}
var body: some View {
Row(isFavorite: model.items.contains(item))
}
Prefer granular view models or per-item state to reduce update fan-out.
Ask the user to re-run the same capture and compare with baseline metrics.
Summarize the delta (CPU, frame drops, memory peak) if provided.
Provide:
Add Apple documentation and WWDC resources under references/ as they are supplied by the user.
references/optimizing-swiftui-performance-instruments.mdreferences/understanding-improving-swiftui-performance.mdreferences/understanding-hangs-in-your-app.mdreferences/demystify-swiftui-performance-wwdc23.mdGenerated Mar 1, 2026
An e-commerce app experiences janky scrolling and high CPU usage when users browse product listings with images and dynamic filters. The SwiftUI audit identifies heavy image decoding on the main thread and unstable identity in ForEach loops, leading to frequent view updates.
A social media app has slow rendering and excessive memory usage in its feed, which includes formatted timestamps, images, and real-time updates. The audit reveals expensive formatters in view bodies and broad observable state changes causing view invalidation storms.
A finance dashboard app shows laggy animations and layout thrash when displaying real-time charts and sorted transaction lists. The audit uncovers sorting operations within SwiftUI body evaluations and deep layout hierarchies using GeometryReader.
A health tracking app suffers from frame drops and high CPU during navigation and data updates, such as when filtering workout logs. The audit finds computed properties doing heavy filtering in views and over-animated hierarchies impacting performance.
Apps offer basic features for free with premium upgrades. Poor performance in free versions can deter upgrades, making SwiftUI audits crucial to optimize core features like scrolling and data display to retain users and drive subscription revenue.
Platforms provide tools for businesses via subscription. Performance issues in SwiftUI-based dashboards can reduce productivity and customer satisfaction, leading to churn. Audits help ensure smooth, efficient interfaces to support high-value contracts.
Apps generate revenue through in-app ads and rely on high user engagement. Slow rendering or janky scrolling can decrease ad views and user retention. SwiftUI audits optimize view updates and memory usage to maintain smooth interactions and ad impressions.
๐ฌ Integration Tip
Integrate this skill early in the development cycle by running audits during code reviews to catch performance issues before deployment, using the workflow decision tree to adapt to user input.
Full Windows desktop control. Mouse, keyboard, screenshots - interact with any Windows application like a human.
Control Android devices via ADB with support for UI layout analysis (uiautomator) and visual feedback (screencap). Use when you need to interact with Android apps, perform UI automation, take screenshots, or run complex ADB command sequences.
Build, test, and ship iOS apps with Swift, Xcode, and App Store best practices.
Control macOS GUI apps visually โ take screenshots, click, scroll, type. Use when the user asks to interact with any Mac desktop application's graphical interface.
Best practices and example-driven guidance for building SwiftUI views and components. Use when creating or refactoring SwiftUI UI, designing tab architecture with TabView, composing screens, or needing component-specific patterns and examples.
Write safe Swift code avoiding memory leaks, optional traps, and concurrency bugs.