swiftui-view-refactor

Refactor SwiftUI view files for consistent structure and Observation framework usage.

Updated Feb 7, 2026
One-click install
npx skills add https://github.com/igor-kupczynski/foodbuddy --skill swiftui-view-refactor-igor-kupczynski
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-view-refactor
Source: https://github.com/igor-kupczynski/foodbuddy/tree/main/.skv/skills/swiftui-view-refactor
Command: npx skills add https://github.com/igor-kupczynski/foodbuddy --skill swiftui-view-refactor-igor-kupczynski

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the common challenge of maintaining consistent, readable, and performant SwiftUI code by providing clear guidelines for view structure, dependency management, and state handling.

Core Features & Use Cases

  • Standardized View Structure: Enforces a consistent ordering of properties and methods within SwiftUI views.
  • MV Pattern Adherence: Promotes a Model-View approach, keeping views lightweight and delegating logic to models and services.
  • Safe ViewModel Handling: Guides the safe and non-optional usage of ViewModels when they are necessary.
  • Observation Best Practices: Ensures correct implementation of @Observable and related state management.
  • Use Case: Refactor a complex, multi-hundred-line SwiftUI view to improve its organization, making it easier to understand, debug, and maintain.

Quick Start

Refactor the attached SwiftUI view file to adhere to the specified ordering and MV patterns.

Frequently Asked Questions about swiftui-view-refactor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor a SwiftUI view to use the Observation framework correctly?

To refactor a SwiftUI view with the Observation framework, ensure proper usage of `@Observable` and standardize state initialization. This promotes a consistent view structure and correct state passing, keeping views lightweight and performant.

What is the best way to structure SwiftUI views for better code quality?

The best way to structure SwiftUI views is by enforcing a consistent ordering of properties and methods. This approach promotes Model-View patterns, delegates logic to models, and makes complex views easier to debug and maintain.

How do I manage ViewModels safely in a SwiftUI refactoring process?

Managing ViewModels safely during SwiftUI refactoring involves guiding their non-optional usage and ensuring proper dependency injection. This keeps views lightweight while delegating business logic correctly to models and services.

When do I need to refactor SwiftUI views into MV patterns?

You need to refactor SwiftUI views into MV patterns when views become complex and multi-hundred-line files. This refactoring improves organization by keeping views lightweight and delegating logic to models and services for better maintainability.

Can I use this SwiftUI refactoring approach for complex view hierarchies?

Yes, you can use this SwiftUI refactoring approach for complex view hierarchies. It addresses view ordering, handles state initialization, and promotes Model-View patterns to make large views easier to understand, debug, and maintain.