Selects, reviews, and migrates Apple-platform app architectures across MV with Observation, MVVM, MVI, TCA, Clean Architecture, Coordinator, and legacy VIPER. Use when choosing module and dependency boundaries, escalating a feature beyond simple SwiftUI MV, planning incremental architecture migration, or auditing state ownership and test seams.
Choose the smallest architecture that makes state ownership, dependencies, side effects, and tests explicit. Default new SwiftUI features to MV; escalate only for observed complexity.
This skill owns pattern selection, module boundaries, dependency direction, migration strategy, and architecture-level test seams. Route SwiftUI property-wrapper wiring and view composition to swiftui-patterns, navigation APIs and route models to swiftui-navigation, isolation diagnostics to swift-concurrency, and test syntax/fixtures to swift-testing.
Decision Workflow
Record the feature's state owner, inputs, outputs, dependencies, side effects, navigation handoffs, and current tests.
Identify the concrete pressure: complex state machine, shared derived state, dependency control, feature composition, team ownership, or UIKit navigation.
Select the smallest pattern that addresses that pressure; write down what it adds and what remains unchanged.
Implement one vertical slice with injected dependencies and observable state transitions.
Run existing behavior tests plus state-transition and dependency-failure tests. If behavior changes, restore the fixture, fix the smallest boundary, and rerun before migrating another slice.
Pattern Selection
Pattern
Choose when
Main cost
MV
SwiftUI feature has straightforward state and orchestration
Logic can drift into large views without decomposition
MVVM
Presentation logic needs an independently testable adapter
Extra layer can become a forwarding shell
MVI
A feature is best modeled as explicit state + intents + reducer/effects
Boilerplate and centralized transition design
TCA
Many composable features need deterministic effects, dependencies, and testing
Framework learning and architectural commitment
Clean Architecture
Large product needs strict dependency direction across domain/data/UI
Protocol and mapping overhead
Coordinator
UIKit or hybrid navigation needs a separate flow owner
Another lifecycle and routing owner
VIPER
Maintaining an existing UIKit module with established VIPER boundaries
Very high ceremony; poor default for new SwiftUI work
Use Coordinator alongside another state pattern when navigation complexity is the pressure; it is not a replacement for domain/state architecture.
MV Default
Keep views as state expressions and put business operations in observable models and injected services:
@MainActor
@Observable
final class TripStore {
private let client: TripClient
var trips: [Trip] = []
var error: Error?
init(client: TripClient) { self.client = client }
func load() async {
do { trips = try await client.fetchTrips() }
catch { self.error = error }
}
}
struct TripList: View {
@State private var store: TripStore
init(client: TripClient) {
_store = State(initialValue: TripStore(client: client))
}
var body: some View {
List(store.trips) { Text($0.name) }
.task { await store.load() }
}
}
Load Architecture Pattern Recipes for MVVM, MVI, TCA, Clean Architecture, Coordinator, and VIPER structure.
Escalation Signals
Choose MVVM when substantial presentation transformation must be tested without rendering and the adapter has real behavior.
Choose MVI when transitions, invalid states, and effects need one auditable reducer-like path.
Choose TCA when feature composition, dependency overrides, cancellation, and deterministic effect tests recur across modules.
Choose Clean Architecture when independent domain rules and dependency direction matter across multiple delivery/data layers.
Add Coordinator for UIKit/hybrid route ownership, deep flow composition, or conditional navigation outside view controllers.
Keep VIPER for compatible legacy modules or deliberate migrations; do not start a new SwiftUI feature with it by habit.
Do not escalate merely because a view is long. First extract subviews, services, and focused observable models.
Migration
Migrate one feature boundary at a time:
Freeze behavior with tests and a dependency/state inventory.
Introduce the target boundary around existing operations.
Move one state transition or dependency at a time without rewriting UI and persistence simultaneously.
Compare behavior, navigation, cancellation, error, and persistence results after each slice.
Remove the old path only after no callers or tests depend on it.
For ObservableObject to Observation, preserve the same owner and mutation isolation before replacing wrappers. For MVVM to MV, delete forwarding view-model members only after views bind to the same model/service behavior. For TCA adoption, wrap one feature's state/actions/effects and migrate dependencies incrementally.
Common Mistakes
Mistake
Fix
Pattern chosen by popularity
Tie it to an observed feature pressure.
View model only forwards properties
Remove it and use MV.
One object owns navigation, networking, formatting, persistence, and UI state
Split by responsibility and dependency direction.
TCA or Clean Architecture applied to trivial screens
Start with MV and preserve an escalation seam.
Coordinator used as a state architecture
Keep it focused on route/lifecycle ownership.
Multiple patterns mixed inside one feature
Define one local state/effect model and migrate at feature boundaries.
Big-bang migration
Move one tested vertical slice and rerun the same proof matrix.
Review Checklist
Choice is justified by concrete feature/team pressures
State owner, mutation path, dependencies, effects, and navigation owner are explicit
Dependencies are injected and replaceable in tests
Pattern cost is proportional to feature complexity
UI mechanics, navigation APIs, isolation, and test syntax route to sibling skills
Migration preserves behavior one vertical slice at a time
Failure, cancellation, navigation, and persistence behavior are verified after each slice
1---2name: swift-architecture3description: Selects, reviews, and migrates Apple-platform app architectures across MV with Observation, MVVM, MVI, TCA, Clean Architecture, Coordinator, and legacy VIPER. Use when choosing module and dependency boundaries, escalating a feature beyond simple SwiftUI MV, planning incremental architecture migration, or auditing state ownership and test seams.4---56# Swift Architecture78Choose the smallest architecture that makes state ownership, dependencies, side effects, and tests explicit. Default new SwiftUI features to MV; escalate only for observed complexity.910## Contents1112- [Scope Boundary](#scope-boundary)13- [Decision Workflow](#decision-workflow)14- [Pattern Selection](#pattern-selection)15- [MV Default](#mv-default)16- [Escalation Signals](#escalation-signals)17- [Migration](#migration)18- [Common Mistakes](#common-mistakes)19- [Review Checklist](#review-checklist)20- [References](#references)2122## Scope Boundary2324This skill owns pattern selection, module boundaries, dependency direction, migration strategy, and architecture-level test seams. Route SwiftUI property-wrapper wiring and view composition to `swiftui-patterns`, navigation APIs and route models to `swiftui-navigation`, isolation diagnostics to `swift-concurrency`, and test syntax/fixtures to `swift-testing`.2526## Decision Workflow27281. Record the feature's state owner, inputs, outputs, dependencies, side effects, navigation handoffs, and current tests.292. Identify the concrete pressure: complex state machine, shared derived state, dependency control, feature composition, team ownership, or UIKit navigation.303. Select the smallest pattern that addresses that pressure; write down what it adds and what remains unchanged.314. Implement one vertical slice with injected dependencies and observable state transitions.325. Run existing behavior tests plus state-transition and dependency-failure tests. If behavior changes, restore the fixture, fix the smallest boundary, and rerun before migrating another slice.3334## Pattern Selection3536| Pattern | Choose when | Main cost |37|---|---|---|38| MV | SwiftUI feature has straightforward state and orchestration | Logic can drift into large views without decomposition |39| MVVM | Presentation logic needs an independently testable adapter | Extra layer can become a forwarding shell |40| MVI | A feature is best modeled as explicit state + intents + reducer/effects | Boilerplate and centralized transition design |41| TCA | Many composable features need deterministic effects, dependencies, and testing | Framework learning and architectural commitment |42| Clean Architecture | Large product needs strict dependency direction across domain/data/UI | Protocol and mapping overhead |43| Coordinator | UIKit or hybrid navigation needs a separate flow owner | Another lifecycle and routing owner |44| VIPER | Maintaining an existing UIKit module with established VIPER boundaries | Very high ceremony; poor default for new SwiftUI work |4546Use Coordinator alongside another state pattern when navigation complexity is the pressure; it is not a replacement for domain/state architecture.4748## MV Default4950Keep views as state expressions and put business operations in observable models and injected services:5152```swift53@MainActor54@Observable55final class TripStore {56 private let client: TripClient57 var trips: [Trip] = []58 var error: Error?5960 init(client: TripClient) { self.client = client }6162 func load() async {63 do { trips = try await client.fetchTrips() }64 catch { self.error = error }65 }66}6768struct TripList: View {69 @State private var store: TripStore7071 init(client: TripClient) {72 _store = State(initialValue: TripStore(client: client))73 }7475 var body: some View {76 List(store.trips) { Text($0.name) }77 .task { await store.load() }78 }79}80```8182Load [Architecture Pattern Recipes](references/architecture-patterns.md) for MVVM, MVI, TCA, Clean Architecture, Coordinator, and VIPER structure.8384## Escalation Signals8586- Choose MVVM when substantial presentation transformation must be tested without rendering and the adapter has real behavior.87- Choose MVI when transitions, invalid states, and effects need one auditable reducer-like path.88- Choose TCA when feature composition, dependency overrides, cancellation, and deterministic effect tests recur across modules.89- Choose Clean Architecture when independent domain rules and dependency direction matter across multiple delivery/data layers.90- Add Coordinator for UIKit/hybrid route ownership, deep flow composition, or conditional navigation outside view controllers.91- Keep VIPER for compatible legacy modules or deliberate migrations; do not start a new SwiftUI feature with it by habit.9293Do not escalate merely because a view is long. First extract subviews, services, and focused observable models.9495## Migration9697Migrate one feature boundary at a time:98991. Freeze behavior with tests and a dependency/state inventory.1002. Introduce the target boundary around existing operations.1013. Move one state transition or dependency at a time without rewriting UI and persistence simultaneously.1024. Compare behavior, navigation, cancellation, error, and persistence results after each slice.1035. Remove the old path only after no callers or tests depend on it.104105For `ObservableObject` to Observation, preserve the same owner and mutation isolation before replacing wrappers. For MVVM to MV, delete forwarding view-model members only after views bind to the same model/service behavior. For TCA adoption, wrap one feature's state/actions/effects and migrate dependencies incrementally.106107## Common Mistakes108109| Mistake | Fix |110|---|---|111| Pattern chosen by popularity | Tie it to an observed feature pressure. |112| View model only forwards properties | Remove it and use MV. |113| One object owns navigation, networking, formatting, persistence, and UI state | Split by responsibility and dependency direction. |114| TCA or Clean Architecture applied to trivial screens | Start with MV and preserve an escalation seam. |115| Coordinator used as a state architecture | Keep it focused on route/lifecycle ownership. |116| Multiple patterns mixed inside one feature | Define one local state/effect model and migrate at feature boundaries. |117| Big-bang migration | Move one tested vertical slice and rerun the same proof matrix. |118119## Review Checklist120121- [ ] Choice is justified by concrete feature/team pressures122- [ ] State owner, mutation path, dependencies, effects, and navigation owner are explicit123- [ ] Dependencies are injected and replaceable in tests124- [ ] Pattern cost is proportional to feature complexity125- [ ] UI mechanics, navigation APIs, isolation, and test syntax route to sibling skills126- [ ] Migration preserves behavior one vertical slice at a time127- [ ] Failure, cancellation, navigation, and persistence behavior are verified after each slice128- [ ] No forwarding-only layers or god objects remain129130## References131132- Detailed pattern structures: [references/architecture-patterns.md](references/architecture-patterns.md)133- Apple: [Observation](https://sosumi.ai/documentation/observation) · [Migrating from ObservableObject to Observable](https://sosumi.ai/documentation/swiftui/migrating-from-the-observable-object-protocol-to-the-observable-macro)134- TCA: [ComposableArchitecture](https://sosumi.ai/external/https://swiftpackageindex.com/pointfreeco/swift-composable-architecture/main/documentation/composablearchitecture)
Run npx skillmds add om-scogo/swift-architecture in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Selects, reviews, and migrates Apple-platform app architectures across MV with Observation, MVVM, MVI, TCA, Clean Architecture, Coordinator, and legacy VIPER. Use when choosing module and dependency boundaries, escalating a feature beyond simple SwiftUI MV, planning incremental architecture migration, or auditing state ownership and test seams. It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Capability flags: makes network calls. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
om-scogo (@om-scogo) published this skill. Their other Agent Skills are listed on their SkillMD profile.