guide-swiftui-view-refactor
Refactor and review SwiftUI view files with strong defaults for small dedicated subviews, MV-over-MVVM data flow, stable view trees, explicit dependency…
Skill by Prisma-Labs-Dev
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/prisma-labs-dev-guide-swiftui-view-refactor
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: data
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/guide-swiftui-view-refactor
What's inside
- Skill name
guide-swiftui-view-refactor- Description
- Refactor and review SwiftUI view files with strong defaults for small dedicated subviews, MV-over-MVVM data flow, stable view trees, explicit dependency injection, and correct Observation usage. Use when cleaning up a SwiftUI view, splitting long bodies, removing inline actions or side effects, reducing computed `some View` helpers, or standardizing `@Observable` and view model initialization patterns.
- License
- MIT
- Instructions
- 203 lines in SKILL.md · view on GitHub
Files (2)
- SKILL.md
- mv-patterns.md · references/
SKILL.md (first lines)
> **Guide Skill** — This is an expert workflow/pattern guide, not API reference documentation.
> Originally from [Dimillian/Skills](https://github.com/Dimillian/Skills) by Thomas Ricouard. MIT License.
# 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
- Views should be lightweight state expressions and orchestration points, not containers for business logic.
- Favor `@State`, `@Environment`, `@Query`, `.task`, `.task(id:)`, and `onChange` before reaching for a view model.
- Inject services and shared models via `@Environment`; keep domain logic in services/models, not in the view body.
- Do not introduce a view model just to mirror local view state or wrap environment dependencies.
- If a screen is getting large, split the UI into subviews before inventing a new view model layer.
### 3) Strongly prefer dedicated subview types over computed `some View` helpers
- Flag `body` properties that are longer than roughly one screen or contain multiple logical sections.
- Prefer extracting dedicated `View` types for non-trivial sections, especially when they have state, async work, branching, or deserve their own preview.
- Keep computed `some View` helpers rare and small. Do not build an entire screen out of `private var header: some View`-style fragments.
- Pass small, explicit inputs (data, bindings, callbacks) into extracted subviews instead of handing down the entire parent state.
- If an extracted subview becomes reusable or independently meaningful, move it to its own file.
Prefer:
```swift
var body: some View {
List {
HeaderSection(title: title, subtitle: subtitle)
FilterSection(
filterOptions: filterOptions,
selectedFilter: $selectedFilter
)
ResultsSection(items: filteredItems)
FooterSection()
}
}
private struct HeaderSection: View {
let title: String
let subtitle: String
var body: some View {
VStack(alignment: .leading, spacing: 6) {
Text(title).font(.title2)
Text(subtitle).font(.subheadline)
}
}
}
private struct FilterSection: View {
let filterOptions: [FilterOption]
@Binding var selectedFilter: FilterOption
var body: some View {
ScrollView(.horizontal, showsIndicators: false) {
HStack {
ForEach(filterOptions, id: \.self) { option in
FilterChip(option: option, isSelected: option == selectedFilter)
.onTapGesture { selectedFilter = option }
}
}
}
}
}
```
Avoid:
```swift
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)
}
}
```
### 3b) Extract actions and side effects out of `body`
- Do not keep non-trivial button actions inline in the view body.
- Do not bury business logic inside `.task`, `.onAppear`, `.onChange`, or `.refreshable`.
- Prefer calling small private methods from the view, and move real business logic into services/models.
- The body should read like UI, not like a view controller.
```swift
Button("Save", action: save)
.disabled(isSaving)
.task(id: searchText) {
await reload(for: searchText)
}
private func save() {
Task { await saveAsync() }
}
private func reload(for searchText: String) async {From Prisma-Labs-Dev/apple-skills, MIT.
More from Prisma-Labs-Dev/apple-skills
- 0.797score
ios-dev
Prisma-Labs-Dev
Start here for any iOS or SwiftUI task.
SkillAFreshness: A★ 349Claude Code +9 - 0.760score
guide-swiftui-ui-patterns
Prisma-Labs-Dev
Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive…
SkillBFreshness: B★ 349Claude Code +9 - 0.760score
guide-swiftdata
Prisma-Labs-Dev
SwiftData patterns — autosave, relationships, dangerous predicates, CloudKit constraints, indexing, class inheritance.
SkillBFreshness: B★ 349Claude Code +9 - 0.754score
guide-swiftui-animations
Prisma-Labs-Dev
SwiftUI animation patterns — implicit/explicit animations, transitions, phase/keyframe animations, the Animatable protocol, and the @Animatable macro.
SkillBFreshness: B★ 349Claude Code +9 - 0.751score
core-animation
Prisma-Labs-Dev
API reference: Core Animation (QuartzCore).
SkillBFreshness: B★ 349Claude Code +9 - 0.697score
apple-docs-index
Prisma-Labs-Dev
Index of Apple developer documentation for iOS, macOS, and related frameworks.
SkillCFreshness: C★ 349Claude Code +9 - 0.697score
ios-design-consultant
Prisma-Labs-Dev
UX and visual design consultant for iOS apps using Apple's Liquid Glass design system (iOS 26+).
SkillCFreshness: C★ 349Claude Code +9 - 0.697score
ios-ui-craft
Prisma-Labs-Dev
Production-grade SwiftUI with Apple Design Award-quality aesthetics.
SkillCFreshness: C★ 349Claude Code +9 - 0.693score
uikit
Prisma-Labs-Dev
API reference: UIKit.
SkillCFreshness: C★ 349Claude Code +9 - 0.693score
hig
Prisma-Labs-Dev
Fact lookup: Apple Human Interface Guidelines corpus (greppable markdown).
SkillCFreshness: C★ 349Claude Code +9 - 0.693score
ios-liquid-glass
Prisma-Labs-Dev
API reference: Liquid Glass (iOS 26+).
SkillCFreshness: C★ 349Claude Code +9 - 0.693score
swiftui
Prisma-Labs-Dev
API reference: SwiftUI.
SkillCFreshness: C★ 349Claude Code +9
Signals
- Stars
- 349
- Forks
- 21
- Open issues
- 1
- Last commit (this folder)
- Jul 4, 2026 (3 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/Prisma-Labs-Dev/apple-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from Prisma-Labs-Dev
- 0.797score
ios-dev
Prisma-Labs-Dev
Start here for any iOS or SwiftUI task.
SkillAFreshness: A★ 349Claude Code +9 - 0.760score
guide-swiftdata
Prisma-Labs-Dev
SwiftData patterns — autosave, relationships, dangerous predicates, CloudKit constraints, indexing, class inheritance.
SkillBFreshness: B★ 349Claude Code +9 - 0.760score
guide-swiftui-ui-patterns
Prisma-Labs-Dev
Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive…
SkillBFreshness: B★ 349Claude Code +9 - 0.754score
guide-swiftui-animations
Prisma-Labs-Dev
SwiftUI animation patterns — implicit/explicit animations, transitions, phase/keyframe animations, the Animatable protocol, and the @Animatable macro.
SkillBFreshness: B★ 349Claude Code +9 - 0.751score
core-animation
Prisma-Labs-Dev
API reference: Core Animation (QuartzCore).
SkillBFreshness: B★ 349Claude Code +9 - 0.697score
ios-design-consultant
Prisma-Labs-Dev
UX and visual design consultant for iOS apps using Apple's Liquid Glass design system (iOS 26+).
SkillCFreshness: C★ 349Claude Code +9
Cite this page
guide-swiftui-view-refactor skill. Agent Mart. https://agentmart.dev/skills/prisma-labs-dev-guide-swiftui-view-refactor (last updated 2026-10-24)