swiftui-architecture

Separate logic from SwiftUI views with MVVM, TCA, or Coordinator patterns.

1.1k|81|Updated Nov 30, 2025
One-click install
npx skills add https://github.com/CharlesWiltgen/Axiom --skill swiftui-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-architecture
Source: https://github.com/CharlesWiltgen/Axiom/tree/main/.claude-plugin/plugins/axiom/skills/swiftui-architecture
Command: npx skills add https://github.com/CharlesWiltgen/Axiom --skill swiftui-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps decide where to place logic in SwiftUI apps, comparing MVVM, TCA, and native SwiftUI patterns, and provides refactoring workflows to improve testability.

Core Features & Use Cases

  • Architecture decision help: Guidance on MVVM, TCA, and Coordinator patterns.
  • Refactoring workflows: Step-by-step patterns to move logic out of views.
  • Testability focus: Patterns that improve testability without heavy coupling.

Quick Start

Outline a plan to extract business logic from a SwiftUI view into a ViewModel using MVVM or TCA.

Frequently Asked Questions about swiftui-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract logic from SwiftUI views into a separate layer?

Extract logic from SwiftUI views by moving state and business logic into a ViewModel (MVVM) or Store (TCA). This separation keeps views focused on UI rendering and improves testability by isolating logic for unit testing without view dependencies.

What's the difference between MVVM, TCA, and native SwiftUI patterns for organizing code?

MVVM centralizes state in a ViewModel class; TCA uses a unidirectional architecture with explicit state, actions, and effects; native SwiftUI relies on @State and @ObservedObject. Each trades complexity for predictability—MVVM is familiar, TCA scales large apps, native SwiftUI minimizes boilerplate for simple features.

How do I refactor a SwiftUI view for better testability?

Refactor by extracting view logic into a separate observable object or reducer, injecting dependencies, and replacing direct state mutations with explicit action handlers. This decouples view rendering from business logic, enabling isolated unit tests without UI frameworks.

Can I use the Coordinator pattern with SwiftUI?

Yes. The Coordinator pattern manages navigation and view lifecycle in SwiftUI by centralizing navigation logic outside views. It pairs well with MVVM or TCA to coordinate multiple screens and handle deep linking while keeping views stateless.

What property wrappers should I use for different state scenarios in SwiftUI?

Use @State for local view state, @ObservedObject for external observable models, @EnvironmentObject for app-wide shared state, and @Binding for two-way connections. Choosing correctly prevents unnecessary re-renders and keeps state flow explicit and testable.

When should I avoid putting business logic directly in SwiftUI views?

Avoid inline logic when code needs unit testing, reuse across multiple views, or depends on external APIs and database calls. Direct view logic couples rendering to side effects, making tests slow and brittle; extraction enables fast, focused tests.