SwiftUI View Refactor for Openclaw

A professional tool for refactoring SwiftUI code to enforce consistent structure, proper dependency injection, and modern Observation usage.

steipete
v1.0.0
Jan 6, 2026
6
4k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install swiftui-view-refactor

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install swiftui-view-refactor using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is SwiftUI View Refactor?

The SwiftUI View Refactor skill is designed to automate the technical debt cleanup process within SwiftUI projects. It focuses on transforming cluttered view files into modular, maintainable code by enforcing a strict property ordering and prioritizing Model-View (MV) patterns. This skill is a core part of the Openclaw Skills ecosystem, helping developers maintain idiomatic Swift code while ensuring that business logic is properly decoupled from the UI layer.

By leveraging this skill, teams can ensure that their SwiftUI views remain lightweight expressions of state. It handles complex tasks such as splitting oversized view bodies into composable subviews and standardizing how dependencies and @Observable state are initialized. Whether you are working on a small prototype or a large-scale enterprise application, this skill provides the architectural guardrails necessary for high-quality iOS and macOS development.

SwiftUI View Refactor Use Cases

  • Standardizing the internal organization of SwiftUI files for team-wide consistency.
  • Migrating legacy @StateObject or @ObservedObject patterns to the modern Observation framework.
  • Reducing the complexity of massive view files by extracting logic into subviews or computed properties.
  • Refactoring optional view models into non-optional, properly initialized state properties.
  • Improving code reviews by automatically applying architectural best practices before submission.

How SwiftUI View Refactor Works

  1. The skill analyzes the target SwiftUI file to identify Environment variables, stored properties, computed variables, and the view body.
  2. It reorders all components following a top-to-bottom hierarchy: Environment, Constants, State, Computed Vars, Init, Body, and finally View Helpers.
  3. It evaluates the complexity of the body property and extracts logical sections into private computed view builders or standalone structs where necessary.
  4. It optimizes state management by ensuring @Observable reference types are stored as @State in the root view and passed down explicitly.
  5. It refines dependency injection by moving service orchestration into the view's initializer, ensuring view models are non-optional whenever possible.

SwiftUI View Refactor Setup

To integrate this capability into your workflow, ensure your agent has access to the Openclaw Skills repository. Add the refactor configuration to your local environment:

# Navigate to your skills directory
cd ~/openclaw/skills

# Clone or add the swiftui-view-refactor.md file
# Ensure your AI agent is pointed to this directory in your configuration

Once installed, you can trigger the refactor by asking your AI agent to clean up a specific SwiftUI view using the standards defined in Openclaw Skills.

SwiftUI View Refactor Data Schema & Taxonomy

The skill organizes SwiftUI code based on a strict metadata taxonomy and property lifecycle:

Section Description Key Wrapper
Properties Environment, Private/Public Let, @State @Environment, @State
Initialization Dependency injection and ViewModel setup init()
View Body The primary UI declaration var body: some View
View Helpers Computed view properties and sub-structs private var helper: some View
Actions Helper functions and asynchronous logic func performAction()

SwiftUI View Refactor Advanced Features

  • Intelligent subview extraction that identifies high-complexity UI blocks for automatic modularization.
  • Support for the modern Observation framework, converting legacy state wrappers to the new @Observable standard.
  • Dependency injection mapping that enforces non-optional view models via view initializers.
  • Context-aware refactoring that preserves existing business logic and layout behavior while improving code structure within Openclaw Skills.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*