ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified developer tools Safety 4/5

swiftui-view-refactor

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.

Why use this skill?

Standardize your SwiftUI codebase with the swiftui-view-refactor skill. Automatically organize views, manage dependencies, and apply modern @Observable patterns.

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/steipete/swiftui-view-refactor
Or

What This Skill Does

The swiftui-view-refactor skill is a specialized refactoring tool designed to standardize SwiftUI codebase architecture. It enforces a strict, industry-vetted structure for views, focusing on readability, maintainability, and modern observation patterns. The skill automates the organization of view properties, optimizes the use of dependency injection, and encourages the transition from bloated, monolithic views to modular, composable subviews. By applying these consistent patterns, it ensures that your SwiftUI files remain clean and easier to debug, even as feature complexity grows.

Installation

To integrate this skill into your environment, run the following command in your terminal: clawhub install openclaw/skills/skills/steipete/swiftui-view-refactor

Use Cases

This skill is ideal for:

  • Refactoring legacy SwiftUI code that uses outdated patterns like ObservableObject in favor of @Observable.
  • Cleaning up massive, unreadable View files that exceed hundreds of lines of code.
  • Standardizing dependency injection patterns across team projects to ensure consistency.
  • Improving the performance of complex views by breaking them into smaller, granular components.
  • Enforcing a uniform coding style across a team to facilitate faster onboarding and peer reviews.

Example Prompts

  1. "Refactor this HomeView file to follow the standard SwiftUI ordering guidelines and move the header section into a separate subview."
  2. "Review my ProfileView and suggest how to replace @ObservedObject with the new @Observable macro pattern while keeping dependency injection clean."
  3. "My body property in the DashboardView is too large; extract the logical sections into private computed view builders to improve readability."

Tips & Limitations

  • Manual Verification: While the skill is highly proficient at structural refactoring, always review the generated code to ensure that custom logic, particularly complex state binding transitions, remains intact after extraction.
  • Scope: This tool works best when applied file-by-file. Avoid running it on an entire directory at once to maintain better control over architectural changes.
  • Performance: When extracting complex views, ensure you are passing only the necessary data rather than the entire parent model, as this can trigger unnecessary view invalidations in SwiftUI. Use @Environment for cross-cutting concerns like theme or session state to keep initializer signatures concise.

Metadata

Author@steipete
Stars982
Views3
Updated2026-02-14
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-steipete-swiftui-view-refactor": {
      "enabled": true,
      "auto_update": true
    }
  }
}

Tags(AI)

#swiftui#refactoring#ios-development#clean-code
Safety Score: 4/5

Flags: file-read, file-write, code-execution