swiftui-view-refactor
Standardize SwiftUI code structure, property ordering, and state management patterns.
Install
mkdir -p .claude/skills/swiftui-view-refactor-hot666666 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14220" && unzip -o skill.zip -d .claude/skills/swiftui-view-refactor-hot666666 && rm skill.zipInstalls to .claude/skills/swiftui-view-refactor-hot666666
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Refactor and review SwiftUI view files for consistent structure, dependency injection, and Observation usage. Use when asked to clean up a SwiftUI view’s layout/ordering, handle view models safely (non-optional when possible), or standardize how dependencies and @Observable state are initialized and passed.Key capabilities
- →Reorder SwiftUI view properties for consistent structure
- →Apply Model-View (MV) patterns to SwiftUI views
- →Split large view bodies into smaller subviews or computed view properties
- →Handle view models as non-optional when possible
- →Ensure correct usage of `@Observable` state
How it works
The skill refactors SwiftUI view files by reordering properties, applying MV patterns, splitting large view bodies, and ensuring correct view model and Observation usage.
Inputs & outputs
When to use swiftui-view-refactor
- →Clean up a large view body
- →Implement dependency injection for views
- →Standardize SwiftUI view property ordering
- →Transition to Observable state
About swiftui-view-refactor
Applies a standard structure and Model-View patterns to SwiftUI views. It enforces cleaner dependency injection, proper `@Observable` state handling, and provides guidance on splitting large views into composable subviews.
Refactor and review SwiftUI view files for consistent structure, dependency injection, and Observation usage. Use when asked to clean up a SwiftUI view’s layout/ordering, handle view models safely (non-optional when possible), or standardize how dependencies and @Observable state are initialized and
When not to use it
- →When the request is to introduce a view model without clear necessity
- →When the focus is on business logic rather than view structure
- →When the view is already small and well-structured
Limitations
- →The skill does not introduce a view model unless explicitly requested or clearly present
- →The skill focuses on view structure and state handling, not business logic changes
- →The skill recommends splitting large view files exceeding ~300 lines
How it compares
This skill provides a structured approach to refactoring SwiftUI views for consistency and maintainability, focusing on explicit ordering and MV patterns, unlike ad-hoc code cleanup.
Compared to similar skills
swiftui-view-refactor side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| swiftui-view-refactor (this skill) | 0 | 7mo | No flags | Intermediate |
| feature-toggle-developer | 1 | 6mo | Review | Intermediate |
| swiftdata-pro | 0 | 3mo | Review | Intermediate |
| swift-coding | 0 | 1mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
feature-toggle-developer
anyproto
Guides systematic removal of feature toggles from the codebase with automated cleanup detection. Use when removing feature flags, enabling toggles permanently, or cleaning up unused code after toggle removal.
swiftdata-pro
sobchak-security
Writes, reviews, and improves SwiftData code using modern APIs and best practices. Use when reading, writing, or reviewing projects that use SwiftData.
swift-coding
Dynokostya
Apply when writing or editing Swift (.swift) files. Behavioral corrections for error handling, concurrency, memory management, type safety, protocol-oriented design, security defaults, and common antipatterns. Project conventions always override these defaults.
swift-concurrency
AvdLee
Expert guidance on Swift Concurrency best practices, patterns, and implementation. Use when developers mention: (1) Swift Concurrency, async/await, actors, or tasks, (2) "use Swift Concurrency" or "modern concurrency patterns", (3) migrating to Swift 6, (4) data races or thread safety issues, (5) refactoring closures to async/await, (6) @MainActor, Sendable, or actor isolation, (7) concurrent code architecture or performance optimization, (8) concurrency-related linter warnings (SwiftLint or similar; e.g. async_without_await, Sendable/actor isolation/MainActor lint).
swift-concurrency-expert
Dimillian
Swift Concurrency review and remediation for Swift 6.2+. Use when asked to review Swift Concurrency usage, improve concurrency compliance, or fix Swift concurrency compiler errors in a feature or file.
ios-dev-guidelines
anyproto
Context-aware routing to Swift/iOS development patterns, architecture, and best practices. Use when working with .swift files, ViewModels, Coordinators, refactoring, or discussing Swift/SwiftUI patterns.