/ios-swift-skills:view-refactorfrom ios-swift-skills
Refactors SwiftUI view files for consistent structure, dependency injection, and Observation usage. Helps clean up layout, handle view models safely, and standardize dependency patterns.
Ships in ios-swift-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Apply consistent structure and dependency patterns to SwiftUI views, focusing on ordering, MV patterns, careful view model handling, and correct Observation usage.
private/public let constants@State / other stored propertiesvar (non-view)initbody@State, @Environment, @Query, task, and onChange for orchestration@EnvironmentIf body grows beyond a screen or has multiple logical sections, split it:
var body: some View {
VStack(alignment: .leading, spacing: 16) {
HeaderSection(title: title, isPinned: isPinned)
DetailsSection(details: details)
ActionsSection(onSave: onSave, onCancel: onCancel)
}
}
Or use computed view properties in the same file:
var body: some View {
List {
header
filters
results
footer
}
}
private var header: some View {
VStack(alignment: .leading, spacing: 6) {
Text(title).font(.title2)
Text(subtitle).font(.subheadline)
}
}
private var filters: some View {
ScrollView(.horizontal, showsIndicators: false) {
HStack {
ForEach(filterOptions, id: \.self) { option in
FilterChip(option: option, isSelected: option == selectedFilter)
.onTapGesture { selectedFilter = option }
}
}
}
}
init, then into the view model@State private var viewModel: SomeViewModel
init(dependency: Dependency) {
_viewModel = State(initialValue: SomeViewModel(dependency: dependency))
}
@Observable reference types, store them as @State in the root view@State, @Environment, task, onChange@State initialized in init@State for root @Observable, no redundant wrappersWhen a SwiftUI view file exceeds ~300 lines:
private extensions// MARK: - comments (e.g., // MARK: - Actions, // MARK: - Subviews)struct focused on stored properties, init, and bodystruct LargeView: View {
@Environment(Store.self) private var store
@State private var items: [Item] = []
var body: some View {
List {
content
}
.task { await loadItems() }
}
}
// MARK: - Subviews
private extension LargeView {
var content: some View {
ForEach(items) { item in
ItemRow(item: item)
}
}
}
// MARK: - Actions
private extension LargeView {
func loadItems() async {
items = await store.fetchItems()
}
}
@Observable types stored as @State in root view@EnvironmentWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
swiftui, view-refactoring, mv-pattern, observation, dependency-injection
Generated from the plugin's indexed repository (patrickserrano/skills) — no native marketplace selected
npx claudepluginhub p/patrickserrano-ios-swift-skills10 skills in this plugin
/issue-fix-flowEnd-to-end GitHub issue fix workflow using gh CLI, local code changes, builds/tests, and git push. Use when asked to take an issue number, implement a fix, run builds/tests, commit with a closing message, and push./debugger-agentBuild, run, and debug iOS apps on a simulator. Use when asked to run an iOS app, interact with the simulator UI, capture logs, or diagnose runtime behavior./native-app-profilingProfile native macOS/iOS apps using Time Profiler via CLI (xctrace). Use when asked to identify performance hotspots, profile CPU usage, or diagnose slow code paths without opening Instruments./app-store-changelogCreate user-facing App Store release notes from git history. Use when asked to generate release changelog, App Store "What's New" text, or release notes based on git tags./macos-spm-app-packagingScaffold, build, and package SwiftPM-based macOS apps without Xcode project. Use when you need a from-scratch macOS app layout, SwiftPM targets/resources, custom .app bundle assembly, or signing/notarization steps outside Xcode./concurrency-expertSwift 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.Other plugins' skills for the same job