swiftui-performance-audit
Skill430 starsChanged 6 months agoMITView on GitHub
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.
17 other projects use a version of this, 16 of them edited.
Adopted by
Most recently taken up by
- MMACABRE/SKILLSedited, first seen Nov 8, 2026
- tornikegomareli/Skillsedited, first seen Nov 8, 2026
- VelimirMueller/claude-skillsedited, first seen Nov 1, 2026
- VelimirMueller/ai-development-skillsedited, first seen Nov 1, 2026
- steipete/agent-scriptsedited, first seen Oct 20, 2026
- spokvulcan/claude-code-build-ios-appsedited, first seen Oct 17, 2026
Other versions17 projects use a version of this.
Word for word · 1
- ramybarsoum/claude-skills★ 0100% same
Edited · 16
- openai/plugins★ 7.8k21% same
- steipete/agent-scripts★ 7.4k95% same
- Dimillian/Skills★ 4k27% same
- omarshahine/HomeClaw★ 19126% same
- robinebers/skills★ 4821% same
- VelimirMueller/ai-development-skills★ 725% same
- VelimirMueller/claude-skills★ 725% same
- Adhamxon/claude-code-skills★ 227% same
- ParkerRex/Skills★ 299% same
- spokvulcan/claude-code-build-ios-apps★ 226% same
6 more not listed
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- macos/AGENTS.mdAGENTS.md
- sandbox-vm/AGENTS.mdAGENTS.md
- web/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- macos/CLAUDE.mdCLAUDE.md
- sandbox-vm/CLAUDE.mdCLAUDE.md
- app-store-changelogSkill
- bridge-agent-log-analyzerSkill
- gh-issue-fix-flowSkill
- githubSkill
- react-component-performanceSkill
- swift-concurrency-expertSkill
- swift-concurrencySkill
- swift-testing-expertSkill
- swiftui-expert-skillSkill
- swiftui-ui-patternsSkill
- swiftui-view-refactorSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. 2 are common, 11 are distinctive, and 4 are very specific to this project.
2
Common
Most of the 16 edited versions we read keep these.
11
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
If the user provides code, start with "Code-First Review."
- Distinctive: line 15
If the user only describes symptoms, ask for minimal code/context, then do "Code-First Review."
- Distinctive: line 16
If code review is inconclusive, go to "Guide the User to Profile" and ask for a trace or screenshots.
- Common: line 37
If needed, a minimal repro or instrumentation suggestion.
- Distinctive: line 42
Use the SwiftUI template in Instruments (Release build).
- Very specific: line 70
Use equatable() or value wrappers for expensive subtrees.
- Distinctive: line 76
Look for these patterns during code review.
- Distinctive: line 88
Prefer cached formatters in a model or a dedicated helper:
- Distinctive: line 106
Prefer precompute or cache on change:
- Distinctive: line 123
Prefer sort once before view updates:
- Distinctive: line 137
Prefer a prefiltered collection with stable identity.
- Very specific: line 147
Avoid id: \.self for non-stable values.
- Very specific: line 161
Prefer one stable base view and localize conditions to sections/modifiers (for example inside toolbar, row content, overlay, or disabled).
- Distinctive: line 169
Prefer decode/downsample off the main thread and store the result.
- Distinctive: line 183
Prefer granular view models or per-item state to reduce update fan-out.
- Common: line 187
Ask the user to re-run the same capture and compare with baseline metrics.
- Very specific: line 199
Add Apple documentation and WWDC resources under references/ as they are supplied by the user.
“Common” is measured: kept by at least 6 in 10 of the 16 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SwiftUI Performance Audit
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 (
idchurn,UUID()per render). - Top-level conditional view swapping (
if/elsereturning different root branches). - 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/build configuration.
3. Analyze and Diagnose
Prioritize likely SwiftUI culprits:
- View invalidation storms from broad state changes.
- Unstable identity in lists (
idchurn,UUID()per render). - Top-level conditional view swapping (
if/elsereturning different root branches). - 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).
Summarize findings with evidence from traces/logs.
4. Remediate
Apply targeted fixes:
- Narrow state scope (
@State/@Observablecloser to leaf views). - Stabilize identities for
ForEachand lists. - Move heavy work out of
body(precompute, cache,@State). - Use
equatable()or value wrappers for expensive subtrees. - Downsample images before rendering.
- Reduce layout complexity or use fixed sizing where possible.
Common Code Smells (and Fixes)
Look for these patterns during code review.
Expensive formatters in body
var 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()
}Computed properties that do heavy work
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 changeSorting/filtering in body or ForEach
List {
ForEach(items.sorted(by: sortRule)) { item in
Row(item)
}
}Prefer sort once before view updates:
let sortedItems = items.sorted(by: sortRule)Inline filtering in ForEach
ForEach(items.filter { $0.isEnabled }) { item in
Row(item)
}Prefer a prefiltered collection with stable identity.
Unstable identity
ForEach(items, id: \.self) { item in
Row(item)
}Avoid id: \.self for non-stable values; use a stable ID.
Top-level conditional view swapping
var content: some View {
if isEditing {
editingView
} else {
readOnlyView
}
}Prefer one stable base view and localize conditions to sections/modifiers (for example inside toolbar, row content, overlay, or disabled). This reduces root identity churn and helps SwiftUI diffing stay efficient.
Image decoding on the main thread
Image(uiImage: UIImage(data: data)!)Prefer decode/downsample off the main thread and store the result.
Broad dependencies in observable models
@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.
5. Verify
Ask the user to re-run the same capture and compare with baseline metrics. Summarize the delta (CPU, frame drops, memory peak) if provided.
Outputs
Provide:
- A short metrics table (before/after if available).
- Top issues (ordered by impact).
- Proposed fixes with estimated effort.
References
Add Apple documentation and WWDC resources under references/ as they are supplied by the user.
- Optimizing SwiftUI performance with Instruments:
references/optimizing-swiftui-performance-instruments.md - Understanding and improving SwiftUI performance:
references/understanding-improving-swiftui-performance.md - Understanding hangs in your app:
references/understanding-hangs-in-your-app.md - Demystify SwiftUI performance (WWDC23):
references/demystify-swiftui-performance-wwdc23.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

