swiftui-view-refactor

Installation
Summary

Refactor SwiftUI views toward small, explicit, stable types with MV-first defaults.

  • Enforces view ordering (environment, state, computed vars, init, body, helpers) and strongly prefers dedicated subview types over computed some View helpers for non-trivial sections
  • Defaults to Model-View architecture: local state in views, shared dependencies in environment, business logic in services/models, view models only when explicitly required or already present
  • Extracts actions and side effects out of view bodies into private methods; keeps body readable as UI layout and orchestration, not imperative logic
  • Maintains stable view trees by avoiding top-level conditional branching; moves conditions into localized sections and modifiers instead
  • Handles @Observable models as @State on iOS 17+; uses legacy @StateObject and @ObservedObject only when deployment target requires it
SKILL.md

SwiftUI View Refactor

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.

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

2) Default to MV, not MVVM

Related skills

More from dimillian/skills

Installs
1.5K
GitHub Stars
3.5K
First Seen
Jan 20, 2026