home / skills / hoangnguyen0403 / agent-skills-standard / architecture
This skill enforces iOS MVVM, Coordinator, and VIPER architecture guidelines to improve modularity, testability, and clean separation of concerns.
npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill architectureReview the files below or copy the command above to add this skill to your agents.
---
name: iOS Architecture
description: Standards for MVVM, Coordinators, and Clean Architecture (VIP/VIPER).
metadata:
labels: [ios, architecture, mvvm, coordinator, vips]
triggers:
files:
[
'**/*ViewModel.swift',
'**/*Coordinator.swift',
'**/*ViewController.swift',
]
keywords: [MVVM, Coordinator, ViewState, Output, Input]
---
# iOS Architecture Standards
## **Priority: P0**
## Implementation Guidelines
### MVVM (Model-View-ViewModel)
- **ViewModel Responsibility**: Handle business logic, formatting, and state. No UIKit imports (except for platform types like `UIImage` if strictly necessary).
- **ViewState**: Use a single state object or discrete `@Published` properties for UI updates.
- **Inputs/Outputs**: Define explicit protocols or nested types for inputs (events from View) and outputs (state for View).
### Coordinator Pattern
- **Navigation Logic**: Decouple ViewControllers from navigation logic. The Coordinator handles instantiation and push/present.
- **Dependency Injection**: Pass dependencies (Services, Repositories) through the Coordinator into the ViewModels.
- **Child Coordinators**: Maintain a hierarchy; remove child coordinators when their flow is finished.
### Clean Architecture (VIP/VIPER)
- **VIP (Clean Swift)**: Use Interactor for logic, Presenter for UI formatting, and ViewController for display.
- **Unidirectional Flow**: Data flows: View -> Interactor -> Presenter -> View.
## Anti-Patterns
- **Massive View Controller**: `**No Logic in VC**: Move business logic to ViewModel/Interactor.`
- **Violating Encapsulation**: `**No Public ViewModel State**: Keep state private(set) or using publishers.`
- **Direct Navigation**: `**No self.navigationController?.push(...)**: Use a Coordinator.`
## References
- [MVVM-C & VIP Implementation](references/implementation.md)
This skill documents iOS architecture standards focused on MVVM, Coordinators, and Clean Architecture (VIP/VIPER). It defines responsibilities, anti-patterns, and wiring patterns to keep code modular, testable, and maintainable. The goal is to guide developers and agents to produce consistent, production-ready iOS code.
The skill inspects code and design decisions against a set of rules: ViewModels must contain business logic and state, Coordinators must own navigation, and VIP components must keep a unidirectional flow. It enforces separation of concerns by checking for UIKit usage inside ViewModels, direct navigation calls in view controllers, and public mutable state leaking from presentation layers. The rules also recommend dependency injection through coordinators and removing child coordinators when flows end.
When should I choose MVVM over VIP/VIPER?
Use MVVM for most screens where view logic and state are moderate; pick VIP/VIPER when you need strict separation, complex business rules, or multiple presenters and interactors for testability.
Can a ViewModel reference UIKit types like UIImage?
Avoid UIKit in ViewModels. Allow platform types only when strictly necessary and document why; prefer presenters/formatters to convert domain data into UI-safe types.