swift-ui-best-practices
SKILL.md
Apple Design Patterns SwiftUI Best Practices
Comprehensive guide for building Apple-quality iOS app UIs with SwiftUI, designed for AI agents to achieve principal-level one-shot native app development. Contains 51 rules across 9 categories, prioritized by impact to guide automated refactoring and code generation.
When to Apply
Reference these guidelines when:
- Building new SwiftUI views and screens
- Implementing navigation flows and modal presentations
- Adding animations, haptics, and transitions
- Ensuring accessibility compliance (VoiceOver, Dynamic Type)
- Optimizing performance for smooth 120fps scrolling
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Data Flow & State Management | CRITICAL | state- |
| 2 | Visual Design System | CRITICAL | design- |
| 3 | Component Selection | HIGH | comp- |
| 4 | Navigation Patterns | HIGH | nav- |
| 5 | View Composition | HIGH | view- |
| 6 | Animation & Haptics | MEDIUM-HIGH | anim- |
| 7 | Accessibility | MEDIUM-HIGH | acc- |
| 8 | Lists & Scroll Performance | MEDIUM | perf- |
| 9 | Platform Integration | MEDIUM | platform- |
Quick Reference
1. Data Flow & State Management (CRITICAL)
state-observable-macro- Use @Observable for model classesstate-use-state-for-view-local- Use @State for view-local value typesstate-binding-for-child-mutation- Use @Binding for child view mutationsstate-environment-for-shared-data- Use @Environment for shared app datastate-avoid-state-in-body- Avoid creating state inside view bodystate-minimize-state-scope- Minimize state scope to reduce re-renders
2. Visual Design System (CRITICAL)
design-typography-system-fonts- Use system typography stylesdesign-spacing-hig-values- Use HIG-compliant spacing valuesdesign-colors-semantic-system- Use semantic system colorsdesign-safe-areas- Respect safe areas for content layoutdesign-visual-hierarchy- Establish clear visual hierarchydesign-padding-consistency- Apply consistent padding patternsdesign-dark-mode-support- Support Dark Mode from day onedesign-material-backgrounds- Use material backgrounds for depth
3. Component Selection (HIGH)
comp-list-vs-lazyvstack- Choose List vs LazyVStack by feature needscomp-sheet-vs-fullscreen- Choose sheet vs fullScreenCover by content typecomp-picker-variants- Choose the right picker stylecomp-grid-vs-lazygrid- Choose Grid vs LazyVGrid by data sizecomp-textfield-vs-texteditor- Choose TextField vs TextEditor by content lengthcomp-button-vs-toggle- Choose Button vs Toggle by interaction type
4. Navigation Patterns (HIGH)
nav-navigationstack-modern- Use NavigationStack for modern navigationnav-tabview-organization- Organize app sections with TabViewnav-sheet-item-binding- Use item binding for sheet presentationnav-dismiss-environment- Use environment dismiss for modal closurenav-toolbar-placement- Place toolbar items correctly
5. View Composition (HIGH)
view-extract-subviews- Extract subviews for compositionview-avoid-anyview- Avoid AnyView for type erasureview-equatable-conformance- Conform views to Equatable for diffingview-prefer-value-types- Prefer value types for view dataview-viewbuilder-composition- Use @ViewBuilder for flexible compositionview-modifier-order- Apply modifiers in correct order
6. Animation & Haptics (MEDIUM-HIGH)
anim-spring-default- Use spring animations as defaultanim-haptic-feedback- Add haptic feedback for interactionsanim-matchedgeometry- Use matchedGeometryEffect for shared transitionsanim-transition-modifiers- Use semantic transitions for appearing viewsanim-gesture-driven- Make animations gesture-drivenanim-loading-states- Animate loading and empty states
7. Accessibility (MEDIUM-HIGH)
acc-accessibility-labels- Add accessibility labels to interactive elementsacc-dynamic-type-support- Support Dynamic Type for all textacc-touch-targets- Ensure minimum touch target sizeacc-color-contrast- Maintain sufficient color contrastacc-reduce-motion- Respect reduce motion preference
8. Lists & Scroll Performance (MEDIUM)
perf-lazy-loading- Use lazy containers for large collectionsperf-async-image- Use AsyncImage for remote imagesperf-task-modifier- Use task modifier for async workperf-drawinggroup- Use drawingGroup for complex graphicsperf-instruments-profiling- Profile SwiftUI with Instruments
9. Platform Integration (MEDIUM)
platform-sf-symbols- Use SF Symbols for consistent iconographyplatform-system-features- Integrate system features nativelyplatform-app-storage- Use AppStorage for user preferencesplatform-scene-phase- Respond to app lifecycle with ScenePhaseplatform-widget-integration- Design for widget and Live Activity integration
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Full Compiled Document
For a complete compiled guide with all rules in a single document, see AGENTS.md.
Reference Files
| File | Description |
|---|---|
| AGENTS.md | Complete compiled guide with all rules |
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
Weekly Installs
5
Repository
pproenca/dot-skillsGitHub Stars
71
First Seen
Feb 5, 2026
Security Audits
Installed on
opencode5
gemini-cli5
claude-code5
codex5
antigravity4
windsurf4