home / skills / fusengine / agents / swiftui-core

This skill helps you build and optimize SwiftUI views across Apple platforms with cohesive navigation, state management, and modern data persistence.

npx playbooks add skill fusengine/agents --skill swiftui-core

Review the files below or copy the command above to add this skill to your agents.

Files (6)
SKILL.md
2.6 KB
---
name: swiftui-core
description: SwiftUI fundamentals for all Apple platforms. Use when building views, navigation, data persistence, or state management with SwiftUI across iOS, macOS, iPadOS, watchOS, visionOS.
versions:
  swiftui: 6
  ios: 26
user-invocable: false
references: references/views-modifiers.md, references/navigation.md, references/data-swiftdata.md, references/state-management.md, references/liquid-glass.md
related-skills: swift-core, solid-swift, ios, macos, ipados, watchos, visionos, tvos
---

# SwiftUI Core

SwiftUI fundamentals shared across all Apple platforms.

## Agent Workflow (MANDATORY)

Before ANY implementation, use `TeamCreate` to spawn 3 agents:

1. **fuse-ai-pilot:explore-codebase** - Analyze existing SwiftUI patterns
2. **fuse-ai-pilot:research-expert** - Verify latest SwiftUI docs via Context7/Exa
3. **mcp__apple-docs__search_apple_docs** - Check SwiftUI view patterns

After implementation, run **fuse-ai-pilot:sniper** for validation.

---

## Overview

### When to Use

- Building SwiftUI views and components
- Implementing navigation (NavigationStack, SplitView)
- Data persistence with SwiftData
- State management (@State, @Observable)
- Custom view modifiers and layouts

### Why SwiftUI Core

| Feature | Benefit |
|---------|---------|
| Declarative UI | Less code, automatic updates |
| Cross-platform | Same code for iOS/macOS/watchOS/visionOS |
| @Observable | Simple reactive state |
| SwiftData | Modern persistence with minimal code |

---

## Key Concepts

### Views & Modifiers
Composable UI building blocks. Extract subviews at 30+ lines.

### Navigation
NavigationStack for stack-based, NavigationSplitView for multi-column.

### SwiftData
Modern persistence with @Model. Replaces Core Data for most use cases.

### State Management
@State for local, @Observable for shared, @Environment for injection.

---

## Reference Guide

| Need | Reference |
|------|-----------|
| Views, modifiers, layouts | [views-modifiers.md](references/views-modifiers.md) |
| NavigationStack, deep linking | [navigation.md](references/navigation.md) |
| SwiftData, @Query, CloudKit | [data-swiftdata.md](references/data-swiftdata.md) |
| @State, @Observable, Environment | [state-management.md](references/state-management.md) |
| Liquid Glass all platforms | [liquid-glass.md](references/liquid-glass.md) |

---

## Best Practices

1. **Small views** - Extract at 30+ lines
2. **Composition** - Use ViewBuilder and modifiers
3. **Preview-driven** - Always include #Preview
4. **Semantic colors** - Use .primary, .secondary
5. **Accessibility** - Add labels to icons
6. **Platform adaptation** - Check sizeClass for responsive layouts

Overview

This skill provides SwiftUI fundamentals and cross-platform patterns for building views, navigation, data persistence, and state management across iOS, macOS, iPadOS, watchOS, and visionOS. It focuses on composable views, modern SwiftData persistence, and concise reactive state using @State and @Observable. Follow the included agent workflow for automated analysis and validation when integrating or updating code.

How this skill works

Before any implementation, spawn three agents to analyze code patterns, verify latest SwiftUI docs, and check view patterns: fuse-ai-pilot:explore-codebase, fuse-ai-pilot:research-expert, and mcp__apple-docs__search_apple_docs. Implement views, navigation, state, and SwiftData models using the shared guidelines, then run fuse-ai-pilot:sniper to validate behavior and platform adaptation. The skill inspects view size, architecture choices, navigation patterns, and persistence annotations to ensure consistency.

When to use it

  • When building reusable SwiftUI views and composing larger interfaces
  • When implementing navigation patterns like NavigationStack or NavigationSplitView
  • When adding data persistence with SwiftData and @Model/@Query
  • When establishing state management across components using @State, @Observable, or @Environment
  • When adapting UI across Apple platforms (size class, platform-specific APIs)

Best practices

  • Keep views small; extract subviews once a view exceeds ~30 lines
  • Favor composition: use ViewBuilder, modifiers, and reusable view modifiers
  • Drive design with previews; include #Preview for components
  • Use semantic colors (.primary, .secondary) and add accessibility labels for controls
  • Adapt layouts by checking size class and platform APIs for responsive behavior

Example use cases

  • Create a cross-platform settings screen with shared components and platform-specific adjustments
  • Implement deep-linked navigation using NavigationStack and maintain state across routes
  • Persist user data and preferences with SwiftData models and @Query for lists
  • Build observable app state for shared data using @Observable and inject via @Environment
  • Compose complex layouts by extracting subviews and testing each with previews

FAQ

Which platforms does this skill target?

All Apple platforms: iOS, macOS, iPadOS, watchOS, and visionOS with shared SwiftUI patterns and platform adaptation guidance.

When should I use SwiftData instead of Core Data?

Use SwiftData for modern persistence in most apps; it simplifies models with @Model and integrates naturally with SwiftUI. Reserve Core Data only for legacy needs or complex migration scenarios.