Diagnoses SwiftUI performance issues using Instruments — render cost, memory leaks, retain cycles, slow lists, and launch time.
How this skill is triggered — by the user, by Claude, or both
Slash command
/swift-performance-pro:swift-performance-proThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Find and fix performance problems with evidence, not guesses. Measure first.
Find and fix performance problems with evidence, not guesses. Measure first.
Trigger: /swift-performance-pro.
body cheap and pure; recomputation is frequent.Keep body free of side effects and heavy compute.
❌ Sorting on every render
var body: some View {
List(items.sorted { $0.date > $1.date }) { Row($0) } // re-sorts each pass
}
✅ Sort once in the model
// model exposes already-sorted `items`
var body: some View { List(model.items) { Row($0) } }
Narrow observation so unrelated changes don't redraw everything. Split big views into small subviews so SwiftUI can diff precisely.
LazyVStack/List for long content, not eager VStack in a ScrollView.Identifiable IDs — index-based identity forces full rebuilds.AnyView in row builders; it defeats SwiftUI's diffing.❌ Strong self capture in a stored closure
manager.onUpdate = { self.refresh() } // cycle: manager → closure → self
✅
manager.onUpdate = { [weak self] in self?.refresh() }
Verify deinit runs. Use Instruments → Leaks / Allocations to confirm.
❌
let image = UIImage(data: hugeData) // decode on main → dropped frames
✅
let image = await Task.detached { UIImage(data: hugeData) }.value
Downsample large images to the display size instead of loading full-resolution.
init/onAppear; load it in .task.body.VStack where LazyVStack/List is needed.AnyView in hot row builders.self in stored closures (retain cycle).Per issue: file:line, the cost, before/after, and which Instrument confirms it. Lead with main-thread blockers.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub laxrajpurohit/swift-skills-pro --plugin swift-performance-pro