Swiftui View Refactor

Refactor SwiftUI view files into stable, testable structure. Use when splitting large views, tightening data flow, or cleaning Observation ownership.

49 stars 5 forksMobile Development

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add robinebers/skills --skill swiftui-view-refactor
Manual install
git clone --depth 1 https://github.com/robinebers/skills.git /tmp/skills
mkdir -p ~/.claude/skills
cp -r /tmp/skills/skills/swiftui-view-refactor ~/.claude/skills/swiftui-view-refactor

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# 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.
Read the full skill on GitHub

Details

Skill name
swiftui-view-refactor
Path
skills/swiftui-view-refactor/SKILL.md
Repo updated
25 June 2026

FAQ

What does the Swiftui View Refactor skill do?

Refactor SwiftUI view files into stable, testable structure. Use when splitting large views, tightening data flow, or cleaning Observation ownership.

How do I install the Swiftui View Refactor skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add robinebers/skills --skill swiftui-view-refactor. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Swiftui View Refactor popular?

It lives in robinebers/skills, which has 49 GitHub stars and 5 forks.

Related skills

Browse the most popular Claude skills, all mobile development skills, or write your own with the skills generator.