swiftui-engineering
Skill0 starsChanged 3 months agoMITView on GitHub
Procedure for reviewing SwiftUI code for state-ownership, view-identity, lifecycle, and rendering correctness — distinct from ios-ux-reviewer's visual/HIG review. Use when the task involves SwiftUI state, @StateObject/@ObservedObject, view identity, body recomputation, navigation, UIKit interop, or a question like "why is this view re-rendering".
1 other project uses a version of this.
Adopted by
Most recently taken up by
- onuryildriim/idebox-claude-codetheir own version, first seen Oct 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- onuryildriim/idebox-claude-code★ 2same 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 repository10 other files it gives its agents.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 34
If ios-agent MCP is configured, mcp__ios-agent__review_swiftui alongside the manual read — STATIC_ANALYSIS tier, same as reading the code, …
- Distinctive: line 79
Read the actual view/state code.
- Distinctive: line 80
Check which detection patterns above apply, confirming each hit against the real surrounding code before reporting it.
- Very specific: line 86
If the finding is about rendering/performance, note whether it's STATIC_ANALYSIS-only or whether ios-memory-performance-engineer should …
- Very specific: line 89
If the task involves a deprecated API (NavigationView, an old-style .onChange signature, etc.), check against ios-api-availability rather …
- Very specific: line 127
Never say a view "will render correctly" from reading the code alone — say what the code's logic implies, and mark rendering behavior …
- Very specific: line 130
Never claim a rendering-performance fix "improved performance" without a measurement — that claim belongs to ios-performance-measurement, …
- Very specific: line 133
Never claim full UIKit-interop correctness from reading updateUIView alone — confirm the actual diffing/guard logic handles the specific …
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 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 Engineering
Purpose
Review SwiftUI code for state-ownership and lifecycle correctness — a
different lens from ios-ux-reviewer's visual/HIG review. This skill
asks "is this pattern correct," not "does this look right."
Distinguish sharply throughout: "this SwiftUI pattern looks correct" (a static read) is not the same claim as "this runtime behavior has been verified" (something was actually observed running).
When to Use
Any task touching SwiftUI state (@State, @Binding, @StateObject,
@ObservedObject, @Environment, @Observable), view identity, body
recomputation/rendering performance, SwiftUI navigation, or
UIKit-SwiftUI interop (UIViewRepresentable,
UIViewControllerRepresentable).
Inputs
- The actual view code — read it; don't reason about SwiftUI state ownership in the abstract.
knowledge/architecture-patterns.mdfor the underlying state- ownership and view-identity decision criteria this skill's checks are built on.- If
ios-agentMCP is configured,mcp__ios-agent__review_swiftuialongside the manual read —STATIC_ANALYSIStier, same as reading the code, never higher.
Core Knowledge
@StateObjectis for a reference type the view creates and owns — SwiftUI keeps the same instance alive across re-renders.@ObservedObjectis for one passed in from a parent — using it for an owned instance is the most common SwiftUI state bug, because a parent re-render can recreate the object and silently reset it.- View identity (same type, same explicit
.id(), same stable position in a container) is what lets@Statesurvive a body re-evaluation. Losing identity — switching between different view types in the same slot, or aForEachkeyed on something unstable — resets state and can produce visible animation glitches. bodyre-evaluates often, on any state change anywhere in its dependency graph. Expensive work insidebody(formatting, sorting, filtering, date math) re-runs every time, not just when its inputs actually change.@EnvironmentObject/@Environmentvalues must actually be injected somewhere up the view hierarchy — a required@EnvironmentObjectwith no.environmentObject(...)ancestor is a runtime crash, not a compile error.UIViewRepresentable/UIViewControllerRepresentable'supdateUIView(_:context:)runs on every relevant parent re-render — not just when something it actually cares about changed, unless the implementation explicitly diffs.
Detection Patterns
| Pattern | Risk | Detect by |
@ObservedObject for an object the view itself instantiates | Parent re-render recreates it, silently resetting all its state | Find where the object is constructed — if it's = SomeClass(...) inside the view rather than passed via an initializer parameter, it should be @StateObject |
ForEach keyed on array index or another unstable value | Reordering/inserting scrambles which row "is" which — state and animations attach to the wrong item | Check id: parameter or Identifiable conformance — index-as-id is the classic version of this bug |
| Conditional branch switching between different concrete view types in the same slot | Loses identity on the branch that changes — resets state, can glitch animations | Look for if/switch returning genuinely different view types without a shared .id() |
Expensive computation directly inside body | Re-runs on every re-render, not just when inputs change | Look for sorting/filtering/formatting/date math written inline in body rather than computed once and stored, or wrapped for memoization |
Required @EnvironmentObject with no visible .environmentObject() ancestor in this view tree | Runtime crash: "No ObservableObject of type X found" | Trace the view hierarchy up from the declaration site for the matching injection |
Binding.constant(...) wrapping a value that's actually meant to be mutable | Two-way binding silently becomes one-way — edits from the child are dropped | grep .constant( and check whether the wrapped value has a real, mutable source of truth elsewhere |
updateUIView/updateUIViewController doing unconditional expensive work | Runs on every parent re-render; without a diff guard this repeats real cost needlessly | Check whether the implementation compares new vs. current state before doing work |
Eagerly-constructed NavigationLink(destination:) inside a List with many rows (pre-value-based pattern) | Builds every destination view upfront instead of lazily — real performance cost that scales with row count | grep NavigationLink(destination: inside a List/ForEach; prefer value-based navigation with .navigationDestination(for:) |
GeometryReader nested inside already-constrained layout, used just to read a size | Forces an extra, often unnecessary layout pass; a common way to get surprising size/position bugs | Check whether the same information is available from a fixed frame or a .background(GeometryReader)-only read pattern instead |
Procedure
- Read the actual view/state code.
- Check which detection patterns above apply, confirming each hit against the real surrounding code before reporting it.
- For a state-ownership or identity finding, name the concrete consequence in this specific view, not the pattern in the abstract ("this will reset the search text every time the parent list reloads" not "this could cause issues").
- If the finding is about rendering/performance, note whether it's
STATIC_ANALYSIS-only or whetherios-memory-performance-engineershould measure the actual re-render cost. - If the task involves a deprecated API (
NavigationView, an old-style.onChangesignature, etc.), check againstios-api-availabilityrather than assuming the newest replacement is automatically correct for this project's deployment target.
Common Mistakes
- Assuming a
@StateObject/@ObservedObjectswap fixes a state-reset bug without confirming the object's actual construction site changed accordingly. - Reporting a rendering-performance finding as a memory-improvement
claim — they're related but distinct; hand off performance-impact
measurement to
ios-memory-performance-engineer/ios-performance-measurementrather than asserting it yourself. - Recommending the newest SwiftUI API reflexively without checking the project's actual minimum deployment target first.
Verification
- A state-ownership, identity, or
EnvironmentObject-injection finding from reading code isSTATIC_ANALYSIS. - Confirming the actual crash/reset/behavior by running the app
(simulator or device) is
RUNTIME_VERIFIED. - A quantified re-render cost (body evaluation count, timing) requires
ios-performance-measurement's workflow —RUNTIME_MEASURED, not claimable from this skill alone.
Evidence Requirements
"SwiftUI pattern looks correct" (STATIC_ANALYSIS) and "runtime
behavior has been verified" (RUNTIME_VERIFIED) are different claims —
never report the first as if it were the second. A fix for a
state-reset bug is STATIC_ANALYSIS until the actual screen has been
observed (manually, or via ios-ui-test-engineer) to retain its state
correctly under the reported conditions.
Claim Restrictions
- Never say a view "will render correctly" from reading the code alone
— say what the code's logic implies, and mark rendering behavior
itself
HUMAN_VERIFICATION/RUNTIME_VERIFIEDuntil actually seen. - Never claim a rendering-performance fix "improved performance"
without a measurement — that claim belongs to
ios-performance-measurement, not this skill. - Never claim full UIKit-interop correctness from reading
updateUIViewalone — confirm the actual diffing/guard logic handles the specific re-render triggers this project has, not a generic case.
Output Format
One finding per issue: pattern name, file:line, concrete user-facing
or developer-facing consequence, and the fix as a diff. Close with the
ios-evidence-reporting status block, distinguishing
STATIC_ANALYSIS pattern findings from anything actually
RUNTIME_VERIFIED.
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.

