swiftui
Skill0 starsChanged 2 months agoMITView on GitHub
Use for anything SwiftUI on iOS or macOS -- writing, reviewing, or refactoring views; state management (@State/@Observable/@Bindable/environment); gesture composition (simultaneous/sequenced/exclusive); adaptive layout (ViewThatFits/AnyLayout/size classes); architecture choice (MVVM vs TCA vs vanilla); navigation and presentation (NavigationStack, sheets, Inspector); modern API adoption and Liquid Glass; accessibility and HIG compliance; performance and maintainability review; or Instruments `.trace` capture/analysis for hangs, hitches, and excessive view updates. Reach for this before improvising SwiftUI guidance from memory -- it consolidates five prior overlapping skills and is more current and more complete than ad hoc knowledge.
10 other projects use a version of this.
Adopted by
Most recently taken up by
- turkeryildirim/ai-skillstheir own version, first seen Nov 1, 2026
- sreejithraman/SreeStacktheir own version, first seen Oct 27, 2026
- g-cqd/skillstheir own version, first seen Oct 23, 2026
- caglarbaranbora/Apple-Agent-Kittheir own version, first seen Oct 13, 2026
- FradSer/skillstheir own version, first seen Oct 13, 2026
- G1Joshi/Agent-Skillstheir own version, first seen Oct 13, 2026
Other versions10 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 10
- Prisma-Labs-Dev/apple-skills★ 336same name
- G1Joshi/Agent-Skills★ 15same name
- FradSer/skills★ 4same name
- moasq/ios-dev-agent★ 4same name
- turkeryildirim/ai-skills★ 4same name
- 31Carlton7/skills★ 2same name
- g-cqd/skills★ 2same name
- caglarbaranbora/Apple-Agent-Kit★ 1same name
- sreejithraman/SreeStack★ 1same name
- Chaeguevara/Skills★ 0same 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 repository21 other files it gives its agents.
- animateSkill
- composable-architectureSkill
- find-animation-opportunitiesSkill
- generating-swift-package-docsSkill
- hapticsSkill
- improve-animationsSkill
- ios-26-platformSkill
- ios-higSkill
- ios-simulator-skillSkill
- localizationSkill
- review-animationsSkill
- spm-build-analysisSkill
- storekitSkill
- swift-concurrencySkill
- swift-dataSkill
- swift-diagnosticsSkill
- swift-networkingSkill
- swift-styleSkill
- swift-testingSkill
- write-swiftSkill
- xcode-buildSkill
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 4 are distinctive, and 7 are very specific to this project.
0
Common
Most of the 9 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
Prefer native SwiftUI APIs over UIKit/AppKit bridging unless bridging is genuinely necessary (references/uikit-interop.md).
- Very specific: line 16
Follow Apple's Human Interface Guidelines and API design idioms (references/design-and-hig.md).
- Very specific: line 17
Only adopt Liquid Glass when explicitly requested (references/liquid-glass.md).
- Very specific: line 19
Use #available gating with sensible fallbacks for version-specific APIs.
- Distinctive: line 21
Don't introduce third-party frameworks without asking first.
- Distinctive: line 27
Read the code under review and identify which topics apply.
- Distinctive: line 29
Run the Topic Router below for each relevant topic.
- Very specific: line 45
Use Button for all tappable elements.
- Very specific: line 46
If the feature needs multi-gesture interaction or must adapt across window sizes, go straight to references/gestures-and-layout.md — it's …
- Distinctive: line 93
Only edit code if the user asked for edits.
- Very specific: line 100
Only one should win? -> .exclusively
“Common” is measured: kept by at least 6 in 10 of the 9 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
This skill merges five previously-overlapping SwiftUI skills into one. It covers the full span from "write this view" to "review this PR" to "why is this list janky" to "compose these two gestures" to "should this be MVVM or TCA." Consult the reference files aggressively — they hold the actual patterns, code, and decision detail; this file is a router plus the handful of rules that apply everywhere.
Operating Rules
- Consult
references/latest-apis.mdat the start of every task to avoid deprecated APIs. - Prefer native SwiftUI APIs over UIKit/AppKit bridging unless bridging is genuinely necessary (
references/uikit-interop.md). - Focus on correctness and performance; don't force a specific architecture (MVVM, TCA, vanilla) — help the user choose one deliberately instead (
references/architecture.md). - Encourage separating business logic from views for testability, without mandating exactly how.
- Follow Apple's Human Interface Guidelines and API design idioms (
references/design-and-hig.md). - Only adopt Liquid Glass when explicitly requested (
references/liquid-glass.md). - Present performance optimizations as suggestions, not blanket requirements — profile before optimizing prematurely.
- Use
#availablegating with sensible fallbacks for version-specific APIs. - iOS 26 is a reasonable default deployment target for new apps; target Swift 6.2+ with modern concurrency (
references/swift-language-conventions.md). - Don't introduce third-party frameworks without asking first.
- This skill's guidance is opinionated by design, but where two merged sources genuinely disagreed, the reference files say so explicitly rather than presenting a false consensus — see the "Flagged conflict" notes in
references/state-management.mdandreferences/view-structure.md.
Task Workflow
Review existing SwiftUI code
- Read the code under review and identify which topics apply.
- Flag deprecated APIs (compare against
references/latest-apis.md). - Run the Topic Router below for each relevant topic.
- Validate
#availablegating and fallback paths for iOS 26+ features. - For a comprehensive review (not a single-topic look), follow the full process, output format, and hygiene checklist in
references/review-checklist.mdinstead of ad hoc commentary.
Improve existing SwiftUI code
- Audit the current implementation against the Topic Router topics.
- Replace deprecated APIs with modern equivalents from
references/latest-apis.md. - Refactor hot paths to reduce unnecessary state updates (
references/performance-patterns.md). - Extract complex view bodies into separate subviews, not
@ViewBuildercomputed properties (references/view-structure.md— flagged-conflict note explains why). - Suggest image downsampling when
UIImage(data:)is encountered (optional,references/image-optimization.md).
Implement a new SwiftUI feature
- Design data flow first: identify owned vs. injected state (
references/state-management.md). - Structure views for optimal diffing (extract subviews early).
- Pick an architecture deliberately if the feature is non-trivial (
references/architecture.md). - Apply correct animation patterns (implicit vs. explicit, transitions —
references/animation-basics.md,references/animation-transitions.md,references/animation-advanced.md). - Use
Buttonfor all tappable elements; add accessibility grouping and labels (references/accessibility-patterns.md). - If the feature needs multi-gesture interaction or must adapt across window sizes, go straight to
references/gestures-and-layout.md— it's the dedicated reference for both. - Gate version-specific APIs with
#availableand provide fallbacks.
Record a new Instruments trace
Trigger when the user asks to "record a trace", "profile the app", "capture a session", etc. Full reference: references/trace-recording.md.
- Confirm target — attach to a running app, launch an app, or record all processes? If unstated, ask. List connected devices when useful:
python3 "${SKILL_DIR}/scripts/record_trace.py" --list-devices - Pick a template based on target kind — the
SwiftUItemplate populates the SwiftUI lane on any real device (physical iOS/iPadOS device or the host Mac). The exception is the iOS Simulator, where the SwiftUI lane comes back empty — switch to--template "Time Profiler"there (still gives Time Profiler + Hangs + Animation Hitches).--list-devices:simulatorskind ->Time Profiler;deviceskind -> defaultSwiftUI. Full decision table inreferences/trace-recording.md. - Start the recording. For agent-driven sessions where the user says "I'll tell you when I'm done", start in the background with a stop-file:
For interactive sessions, tell the user to press Ctrl+C when done.python3 "${SKILL_DIR}/scripts/record_trace.py" \ --device "<name|udid>" --attach "<AppName>" \ --stop-file /tmp/stop-trace --output ~/Desktop/session.trace - Signal stop —
touch /tmp/stop-traceonce the user says they're finished exercising the app. The script cleanly SIGINTs xctrace and waits up to 60s for finalisation. - Analyse the resulting trace (flows into "Trace-driven improvement" below).
For a lighter-weight, no-file-required alternative for a quick look, see the built-in Xcode "SwiftUI Instrument" workflow (Cmd-I) documented in references/performance-patterns.md.
Trace-driven improvement (Instruments .trace provided)
Trigger whenever the user's request references a .trace file. A target SwiftUI source file is optional — if given, cite specific lines; if not, recommend where to look based on view names and symbols the trace already reveals.
Full reference: references/trace-analysis.md. Summary of the composition pattern:
- Scope the analysis. "focus on X / after X / between X and Y / during X" -> resolve a window first (step 2). No scoping cue -> analyse the whole trace.
- Resolve a window (only if scoped).
Both acceptpython3 "${SKILL_DIR}/scripts/analyze_trace.py" --trace <path> \ --list-logs --log-message-contains "loaded feed" --log-limit 5 # or python3 "${SKILL_DIR}/scripts/analyze_trace.py" --trace <path> \ --list-signposts --signpost-name-contains "ImageDecode"--window START_MS:END_MSto scope discovery; build a window like--window 10400:11700. - Run the main analysis:
python3 "${SKILL_DIR}/scripts/analyze_trace.py" --trace <path> \ --json-only --top 10 [--window START_MS:END_MS] - Interpret with
references/trace-analysis.md— key diagnostics:main_running_coverage_pct(<25% = blocked; >=75% = CPU-bound);swiftui-causes.top_sourcesreveals why updates keep happening. - When a specific view is expensive, ask who's invalidating it —
--fanin-for "<view name>". - Optionally ground in source. Match view/symbol names against the file if one was given; otherwise recommend which files to open.
- Return a prioritised plan citing evidence and routing each recommendation to a Topic Router reference.
- Only edit code if the user asked for edits.
Decision Trees
Gesture Composition
- Both gestures at the same time? ->
.simultaneously - One must complete before the next? ->
.sequenced - Only one should win? ->
.exclusively
Full patterns, @GestureState vs @State, and pitfalls: references/gestures-and-layout.md.
Layout Adaptation
- Pick the best-fitting static variant? ->
ViewThatFits - Animated H/V switch driven by a known condition? ->
AnyLayout - Need actual container dimensions? ->
onGeometryChange
Full patterns, size-class table, and anti-patterns: references/gestures-and-layout.md.
Architecture Selection
- Small app, comfortable with Apple's own patterns? ->
@Observable+ State-as-Bridge - Complex presentation logic, team knows MVVM? -> MVVM with
@Observableview models - Rigorous testability, large team? -> TCA (defer to the
composable-architectureskill for TCA specifics)
Full decision tree, State-as-Bridge pattern, and anti-patterns: references/architecture.md.
Topic Router
| Topic | Reference |
| Read first, every task | references/latest-apis.md -- deprecated-to-modern API transitions (iOS 15+ through 26+) |
| State management | references/state-management.md |
| View composition / structure | references/view-structure.md |
| Architecture (MVVM / TCA / vanilla) | references/architecture.md |
| Gestures & adaptive layout | references/gestures-and-layout.md |
| Performance | references/performance-patterns.md |
| Lists and ForEach | references/list-patterns.md |
| Layout (non-gesture) | references/layout-best-practices.md |
| Sheets, navigation, Inspector | references/sheet-navigation-patterns.md |
| ScrollView | references/scroll-patterns.md |
| Focus management | references/focus-patterns.md |
Async patterns (.task, .refreshable, cancellation) | references/async-patterns.md |
| UIKit/AppKit interop | references/uikit-interop.md |
| Migrating iOS 16 -> 17+ code | references/migration-guide.md |
| Animations (basics) | references/animation-basics.md |
| Animations (transitions) | references/animation-transitions.md |
Animations (advanced / @Animatable) | references/animation-advanced.md |
| Accessibility | references/accessibility-patterns.md |
| Design & Human Interface Guidelines | references/design-and-hig.md |
| Swift Charts | references/charts.md |
| Charts accessibility | references/charts-accessibility.md |
| Image optimization | references/image-optimization.md |
| Liquid Glass (iOS 26+) | references/liquid-glass.md |
| macOS scenes | references/macos-scenes.md |
| macOS window styling | references/macos-window-styling.md |
| macOS views | references/macos-views.md |
| Text patterns | references/text-patterns.md |
| Swift language conventions | references/swift-language-conventions.md |
| Previews | references/previews.md |
| Comprehensive code review (process + output format) | references/review-checklist.md |
| Instruments trace analysis | references/trace-analysis.md |
| Instruments trace recording | references/trace-recording.md |
Correctness Checklist
These are hard rules — violations are always bugs:
@Stateproperties areprivate@Bindingonly where a child modifies parent state- Passed values never declared as
@Stateor@StateObject(they ignore updates) @StateObjectfor view-owned objects;@ObservedObjectfor injected (legacy, pre-iOS 17)- iOS 17+:
@Statewith@Observable;@Bindablefor injected observables needing bindings ForEachuses stable identity (never.indicesfor dynamic content)- Constant number of views per
ForEachelement .animation(_:value:)always includes thevalueparameter@FocusStateproperties areprivate- No redundant
@FocusStatewrites inside tap gesture handlers on.focusable()views - iOS 26+ APIs gated with
#availableand fallback provided import Chartspresent in files using chart types- Previews use self-contained mock data; no dependency on live services or network
@ObservationIgnoredon every property-wrapper property inside an@Observableclass (@AppStorage,@SceneStorage,@Query, etc.) — and don't assume@AppStoragethere still triggers view updates (seereferences/state-management.md)@AppStorage/UserDefaultsnever used for secrets — Keychain onlynavigationDestination(for:)andNavigationLink(destination:)are never mixed in the same navigation hierarchy
For the fuller review process (output format, prioritized findings, hygiene pass), see references/review-checklist.md.
References
references/latest-apis.md— Read first for every task. Deprecated-to-modern API transitions (iOS 15+ through iOS 26+), plus a flat list of additional modern-API rules.references/api-refresh.md— Maintenance workflow for refreshinglatest-apis.mdafter a new Xcode/iOS release: scan Apple's docs via the Sosumi MCP (seereferences/api-refresh-scan-manifest.md) for new deprecations, then update the file.references/state-management.md— Property wrappers, data flow,@Observablemigration,@AppStorage-in-@Observablecaveat, numericTextFieldbinding, SwiftData quick notes.references/view-structure.md— View extraction, container patterns,@ViewBuilder, the extract-to-struct-vs-computed-property conflict, UIKit interop essentials.references/architecture.md— MVVM vs TCA vs vanilla decision tree, State-as-Bridge, worked MVVM example, anti-patterns.references/gestures-and-layout.md— Gesture composition (simultaneous/sequenced/exclusive),@GestureState,ViewThatFits/AnyLayout/onGeometryChange, size classes, iOS 26 layout changes.references/performance-patterns.md— Hot-path optimization, update control,_logChanges(), Instruments 26 SwiftUI template protocol, debounced search, pagination.references/list-patterns.md— ForEach identity, Table (iOS 16+), inline filtering pitfalls.references/layout-best-practices.md— Layout patterns, GeometryReader alternatives.references/sheet-navigation-patterns.md— Sheets, NavigationStack/NavigationSplitView, Inspector, navigation coordinator pattern.references/scroll-patterns.md— ScrollViewReader, programmatic scrolling.references/focus-patterns.md— Focus state, focusable views, focused values, default focus, common pitfalls.references/async-patterns.md—.task/.task(id:)/.refreshable/background tasks, nested-Task cancellation.references/uikit-interop.md—UIViewRepresentable/UIViewControllerRepresentableworked examples, delegate-cycle leaks.references/migration-guide.md— iOS 16 -> 17+ migration checklist with before/after.references/accessibility-patterns.md— VoiceOver, Dynamic Type, grouping, traits, named actions, Reduce Motion, Differentiate Without Color.references/design-and-hig.md— Uniform design tokens, HIG compliance, tap targets, system styling.references/animation-basics.md— Implicit/explicit animations, timing, performance.references/animation-transitions.md— View transitions,matchedGeometryEffect,Animatable.references/animation-advanced.md— Phase/keyframe animations (iOS 17+),@Animatablemacro (iOS 26+).references/charts.md— Swift Charts marks, axes, selection, styling, Chart3D (iOS 26+).references/charts-accessibility.md— Charts VoiceOver, Audio Graph, fallback strategies.references/image-optimization.md— AsyncImage, downsampling, caching.references/liquid-glass.md— iOS 26+ Liquid Glass effects and fallback patterns.references/macos-scenes.md— Settings, MenuBarExtra, WindowGroup, multi-window.references/macos-window-styling.md— Toolbar styles, window sizing, Commands.references/macos-views.md— HSplitView, Table, PasteButton, AppKit interop.references/text-patterns.md— Text initializer selection, verbatim vs. localized.references/swift-language-conventions.md— Swift-native API choices and concurrency conventions for SwiftUI codebases.references/previews.md—#Previewmacro,@Previewable(iOS 18+), preview traits, mock data patterns.references/review-checklist.md— Full comprehensive-review process, output format, Core Instructions, hygiene checklist.references/trace-analysis.md— Parse Instruments.tracefiles viascripts/analyze_trace.py; interpret main-thread coverage, high-severity SwiftUI updates, hitch narratives, map findings back to source.references/trace-recording.md— Record a new trace viascripts/record_trace.py: attach, launch, or capture a manually-stopped session; supports stop-file for agent-driven flows.
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.

