| name | swiftui-view-refactor |
| description | ALWAYS use this when the request matches Swiftui View Refactor: Refactor SwiftUI views into smaller components with stable, explicit data flow. |
SwiftUI View Refactor
Selective Reading Rule
Start with:
references/usage-routing.md
references/quality-checklist.md
Then load only the inherited docs, scripts, assets, or examples that match the user's actual task.
Selective Reading Rule
Start with:
references/senior-master-standard.md
Then load only the references, scripts, assets, or examples needed for the user's actual task.
Overview
Refactor SwiftUI views toward small, explicit, stable view types. Default to vanilla SwiftUI: local state in the view, shared dependencies in the environment, business logic in services/models, and view models only when the request or existing code clearly requires one.
When to Use
- When cleaning up a large SwiftUI view or splitting long
body implementations.
- When you need smaller subviews, explicit dependency injection, or better Observation usage.
Core Guidelines
1) View ordering (top → bottom)
- Enforce this ordering unless the existing file has a stronger local convention you must preserve.
- Environment
private/public let
@State / other stored properties
- computed
var (non-view)
init
body
- computed view builders / other view helpers
- helper / async functions