Swift Architecture Skill
Overview
Use this skill to pick the best Swift architecture playbook for SwiftUI/UIKit codebases and apply it to the user’s task.
Workflow
Step 1: Analyze the Request Context
Before selecting an architecture, capture:
- task type (new feature, refactor, PR review, debugging)
- UI stack (SwiftUI, UIKit, or mixed)
- scope (single screen, multi-screen, app-wide)
- existing conventions to preserve
Step 2: Select the Architecture
If the user explicitly names an architecture, treat it as the initial candidate and run a fit check before committing:
- validate against UI stack fit (SwiftUI/UIKit/mixed), state complexity, effect orchestration needs, team familiarity, and existing codebase conventions
- if it fits, proceed with the requested architecture
- if it mismatches key constraints, explicitly explain the mismatch and recommend the closest-fit alternative from
references/selection-guide.md
- if the user still insists on a mismatched architecture, proceed with a risk-mitigated plan and state the risks up front
When no architecture is named, load references/selection-guide.md and infer the best fit from stated constraints (state complexity, team familiarity, testing goals, effect orchestration needs, and framework preferences). Explain the recommendation briefly.
Architecture reference mapping:
- MVVM →
references/mvvm.md
- MVI →
references/mvi.md
- TCA →
references/tca.md
- Clean Architecture →
references/clean-architecture.md
- VIPER →
references/viper.md
- Reactive →
references/reactive.md
- MVP →
references/mvp.md
- Coordinator →
references/coordinator.md
Step 3: Analyze Existing Codebase (When Applicable)
When code already exists:
- detect current architecture and DI style
- note concurrency model (async/await, Combine, GCD, mixed)
- align recommendations to local conventions
Step 4: Produce Concrete Deliverables
Read the selected architecture reference and convert its guidance into deliverables tailored to the user's request:
- File and module structure: directory layout with file names specific to the feature
- State and dependency boundaries: concrete types, protocols, and injection points
- Async strategy: cancellation, actor isolation, and error paths
- Testing strategy: what to test, how to stub dependencies, and example test structure
- Migration path (for refactors): incremental steps to move from current to target architecture
- UI stack adaptation: where SwiftUI and UIKit guidance should differ for the chosen architecture
Step 5: Validate with Checklist
End with the architecture-specific PR review checklist from the reference file, adapted to the user's feature.
Output Requirements
- Keep recommendations scoped to the requested feature or review task.
- Prefer protocol-based dependency injection and explicit state modeling.
- Flag anti-patterns found in existing code and provide direct fixes.
- Include cancellation and error handling in all async flows.
- For explicit architecture requests, include a short fit result (
fit or mismatch) with 1-2 reasons.
- For mismatch cases, include one closest-fit alternative and why it better matches the stated constraints.
- When writing code, include only the patterns relevant to the task — do not dump entire playbooks.
- Treat reference snippets as illustrative by default; add full compile scaffolding only if the user asks for runnable code.
- Ask only minimum blocking questions; otherwise proceed with explicit assumptions stated up front.
- When reviewing PRs, use the architecture-specific checklist and call out specific violations with line-level fixes.
1---2name: swift-architecture-skill3description: Swift architecture patterns and playbooks for MVVM, TCA, Clean Architecture, and more.4license: MIT5---67# Swift Architecture Skill89## Overview1011Use this skill to pick the best Swift architecture playbook for SwiftUI/UIKit codebases and apply it to the user’s task.1213## Workflow1415### Step 1: Analyze the Request Context1617Before selecting an architecture, capture:18- task type (new feature, refactor, PR review, debugging)19- UI stack (SwiftUI, UIKit, or mixed)20- scope (single screen, multi-screen, app-wide)21- existing conventions to preserve2223### Step 2: Select the Architecture2425If the user explicitly names an architecture, treat it as the initial candidate and run a fit check before committing:26- validate against UI stack fit (SwiftUI/UIKit/mixed), state complexity, effect orchestration needs, team familiarity, and existing codebase conventions27- if it fits, proceed with the requested architecture28- if it mismatches key constraints, explicitly explain the mismatch and recommend the closest-fit alternative from `references/selection-guide.md`29- if the user still insists on a mismatched architecture, proceed with a risk-mitigated plan and state the risks up front3031When no architecture is named, load `references/selection-guide.md` and infer the best fit from stated constraints (state complexity, team familiarity, testing goals, effect orchestration needs, and framework preferences). Explain the recommendation briefly.3233Architecture reference mapping:34- MVVM → `references/mvvm.md`35- MVI → `references/mvi.md`36- TCA → `references/tca.md`37- Clean Architecture → `references/clean-architecture.md`38- VIPER → `references/viper.md`39- Reactive → `references/reactive.md`40- MVP → `references/mvp.md`41- Coordinator → `references/coordinator.md`4243### Step 3: Analyze Existing Codebase (When Applicable)4445When code already exists:46- detect current architecture and DI style47- note concurrency model (async/await, Combine, GCD, mixed)48- align recommendations to local conventions4950### Step 4: Produce Concrete Deliverables5152Read the selected architecture reference and convert its guidance into deliverables tailored to the user's request:5354- **File and module structure**: directory layout with file names specific to the feature55- **State and dependency boundaries**: concrete types, protocols, and injection points56- **Async strategy**: cancellation, actor isolation, and error paths57- **Testing strategy**: what to test, how to stub dependencies, and example test structure58- **Migration path** (for refactors): incremental steps to move from current to target architecture59- **UI stack adaptation**: where SwiftUI and UIKit guidance should differ for the chosen architecture6061### Step 5: Validate with Checklist6263End with the architecture-specific PR review checklist from the reference file, adapted to the user's feature.6465## Output Requirements6667- Keep recommendations scoped to the requested feature or review task.68- Prefer protocol-based dependency injection and explicit state modeling.69- Flag anti-patterns found in existing code and provide direct fixes.70- Include cancellation and error handling in all async flows.71- For explicit architecture requests, include a short fit result (`fit` or `mismatch`) with 1-2 reasons.72- For mismatch cases, include one closest-fit alternative and why it better matches the stated constraints.73- When writing code, include only the patterns relevant to the task — do not dump entire playbooks.74- Treat reference snippets as illustrative by default; add full compile scaffolding only if the user asks for runnable code.75- Ask only minimum blocking questions; otherwise proceed with explicit assumptions stated up front.76- When reviewing PRs, use the architecture-specific checklist and call out specific violations with line-level fixes.