swiftui-performance
Skill117 starsChanged 5 months agoMITView on GitHub
Use this skill when reviewing or fixing SwiftUI performance issues, including unnecessary invalidation, unstable identity, broad state dependencies, expensive body work, heavy rows, scrolling hitches, layout/drawing cost, or async lifecycle work. Do not use it for general SwiftUI syntax, styling, UIKit-only performance, or generic profiling unless SwiftUI update behavior is central.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- dpearson2699/swift-ios-skillstheir own version, first seen Jul 13, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- dpearson2699/swift-ios-skills★ 1.2ksame name
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 repository5 other files it gives its agents.
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 11 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Use this skill to review and refactor SwiftUI code with a performance-first mental model focused on change locality.
- Distinctive: line 16
Use this skill for:
- Distinctive: line 22
Do not use this skill for:
- Distinctive: line 52
Check in this order:
- Distinctive: line 64
Prefer targeted refactors over architectural rewrites.
- Distinctive: line 77
Never invent timing numbers or claim profiling results unless the user provided evidence or a profiling command was actually run.
- Distinctive: line 106
Use the smallest fix that addresses the cause:
- Distinctive: line 114
prefer key-path bindings over custom closure bindings when no transformation is needed
- Very specific: line 115
use .equatable() only when visual equality is clear and cheaper than recomputing
- Very specific: line 116
use .task(id:) when work is tied to a changing input and should cancel/restart automatically
- Distinctive: line 117
consider UIKit only for genuinely hot paths that need lower-level control
- Very specific: line 119
Do not use .equatable(), memoization, or caching as blanket fixes.
- Distinctive: line 123
Read references only when the task needs more detail:
- Distinctive: line 153
Keep the answer concrete. Do not say “SwiftUI is slow.” Explain the specific identity, dependency, rendering, layout, drawing, animation, …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SwiftUI Performance
Purpose
Use this skill to review and refactor SwiftUI code with a performance-first mental model focused on change locality.
SwiftUI performance work should explain which change invalidates which part of the UI, why that work matters, and how to keep updates local.
Scope
Use this skill for:
- SwiftUI screen, list, row, layout, drawing, animation, and lifecycle reviews
- targeted refactors that reduce unnecessary updates or rendering work
- profiling plans only when they validate a SwiftUI performance hypothesis
Do not use this skill for:
- UIKit-only performance problems
- app launch performance unless the issue is inside SwiftUI root view or scene construction
- networking, backend latency, database performance, or caching unless they affect SwiftUI updates
- generic Instruments walkthroughs without a SwiftUI code path
- broad architecture rewrites without a concrete SwiftUI performance risk
Core Model
Answer three questions first:
- What changed?
- Which views depend on that change?
- How much UI work happens because of it?
Then inspect:
- Identity: does SwiftUI preserve the same logical view across updates?
- Lifetime: is state owned by the smallest stable component that needs it?
- Dependencies: does each view read only the data it needs to render?
- Rendering: is
bodycheap, predictable, and free from heavy transformation work? - Lifecycle: is async work tied to
.task,.onAppear, or explicit actions rather than started frombody?
A SwiftUI view is a value description of UI. Do not treat it as a long-lived UIKit-style object.
Review Workflow
Inspect the smallest relevant code path before suggesting broad changes.
Check in this order:
- Stable and intentional identity.
- Expensive work in
body. - Broad state or model reads.
- State ownership and lifetime.
- List, row, and pagination structure.
- Closure-heavy inputs, custom bindings, and unnecessary type erasure.
- Layout, drawing, and animation cost in repeated content.
- Async lifecycle, cancellation, and main-actor work.
- Profiling or debug probes when confirmation is useful.
Prefer targeted refactors over architectural rewrites.
Evidence Rule
Always separate:
- static code review findings
- likely risks
- hypotheses
- measured results
- user-provided evidence
- tool-generated evidence
Never invent timing numbers or claim profiling results unless the user provided evidence or a profiling command was actually run.
Prefer:
This parent view reads the whole model, so changes to that model can invalidate a large part of the screen.
Avoid:
This costs 500 ms.
Common Red Flags
Flag these patterns when they appear on an update or scrolling path:
- unstable IDs such as
.id(UUID())orvar id: UUID { UUID() } - index-based identity for mutable collections
- sorting, filtering, grouping, formatting, parsing, decoding, or database reads inside
body - filtering inside
ForEachinstead of preparing visible rows first - passing one giant model into every child view
- broad computed properties that hide many state reads
AnyViewin large repeated collections- custom
Binding(get:set:)when a key-path binding would work - many stored non-visual closures in row views
GeometryReader, preferences, heavy shadows, masks, blurs, or overlays in every row- async work started directly from
body - unguarded
.onAppearpagination triggers inside rows
Refactor Guidelines
Use the smallest fix that addresses the cause:
- keep identity stable
- move expensive transformations out of
body - prepare render-ready models outside repeated rendering paths
- move state closer to the component that owns it
- split large views into dependency-focused subviews
- simplify row inputs and repeated structure
- prefer key-path bindings over custom closure bindings when no transformation is needed
- use
.equatable()only when visual equality is clear and cheaper than recomputing - use
.task(id:)when work is tied to a changing input and should cancel/restart automatically - consider UIKit only for genuinely hot paths that need lower-level control
Do not use .equatable(), memoization, or caching as blanket fixes. Explain the invalidation or rendering issue first.
Reference Routing
Read references only when the task needs more detail:
references/identity-and-state.md— identity,.id,ForEach,@State,@StateObject,@ObservedObject, owned observable modelsreferences/observation-and-dependencies.md— Observation,ObservableObject, broad dependencies, environment readsreferences/body-cost-and-render-models.md— sorting, filtering, formatting, derived data, render modelsreferences/lists-pagination-and-rows.md—List,ScrollView,LazyVStack, rows, pagination, scrollingreferences/closures-bindings-and-equatable.md— closures, bindings,.equatable(), action handlersreferences/layout-drawing-and-animation.md— layout, drawing, modifiers, animation hitchesreferences/async-lifecycle-and-mainactor.md—.task,.onAppear, cancellation,MainActorreferences/profiling-validation.md— Instruments,xctrace, signposts, XCTest, MetricKit
Response Format
For code reviews, answer with:
- Main issue
- Why it matters in SwiftUI
- Risk level
- Suggested refactor
- Code example when useful
- What to measure if confirmation is needed
For profiling requests, answer with:
- Scenario
- Hypothesis
- Tool or probe
- What to look for
- How to compare before and after
Keep the answer concrete. Do not say “SwiftUI is slow.” Explain the specific identity, dependency, rendering, layout, drawing, animation, or lifecycle issue.
Final Principle
SwiftUI performance improves when code makes change locality obvious.
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.

