Agent skill

SwiftUI Best Practices Enforcer

Audit and fix SwiftUI anti-patterns in Leavn - @State in wrong places, heavy View body computation, missing @MainActor, improper property wrappers

Stars 163
Forks 31

Install this agent skill to your Project

npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/swiftui-best-practices

SKILL.md

SwiftUI Best Practices Enforcer

Fix SwiftUI anti-patterns:

  1. @State for ViewModels: Move to ViewModel property

  2. Heavy View body: Extract to ViewModel computed property

  3. Missing @MainActor: Add to ViewModels

  4. Property wrapper mistakes:

    • @Observable → @State or @Bindable
    • ObservableObject → @StateObject or @ObservedObject
  5. Leavn patterns:

    • ViewModels: @Observable + @MainActor
    • Services: Protocol-based, injected via DIContainer
    • State: In ViewModel, not View
    • Bindings: Use @Bindable for @Observable types

Use when: SwiftUI issues, performance problems, architecture violations

Didn't find tool you were looking for?

Be as detailed as possible for better results