agentsclimarketplace

Swift refactor

Skill ComeOnOliver/skillshub/skills/pproenca/dot-skills/swift-refactor

🧠 The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.

Install
npx -y skills add ComeOnOliver/skillshub --skill swift-refactor

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

12.0 KB, as published. Nobody here has run it

Swift/SwiftUI Refactor (Modular MVVM-C)

Comprehensive refactoring guide for migrating Swift/SwiftUI code to modular MVVM-C with local SPM package boundaries and App-target composition root wiring.

Mandated Architecture Stack

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ App target: DependencyContainer, Coordinators, Route Shells   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Feature modules: View + ViewModel (Domain + DesignSystem deps)β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Data package: repositories, remote/local stores, sync, retry  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Domain package: models, repository/coordinator/error protocols β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Dependency Rule: Feature modules never import Data and never import sibling features.

Clinic Architecture Contract (iOS 26 / Swift 6.2)

All guidance in this skill assumes the clinic modular MVVM-C architecture:

  • Feature modules import Domain + DesignSystem only (never Data, never sibling features)
  • App target is the convergence point and owns DependencyContainer, concrete coordinators, and Route Shell wiring
  • Domain stays pure Swift and defines models plus repository, *Coordinating, ErrorRouting, and AppError contracts
  • Data owns SwiftData/network/sync/retry/background I/O and implements Domain protocols
  • Read/write flow defaults to stale-while-revalidate reads and optimistic queued writes
  • ViewModels call repository protocols directly (no default use-case/interactor layer)

When to Apply

Reference these guidelines when:

  • Migrating from deprecated SwiftUI APIs (ObservableObject, NavigationView, old onChange)
  • Restructuring state management to use @Observable ViewModels
  • Adding @Equatable diffing to views for performance
  • Decomposing large views into 10-node maximum bodies
  • Refactoring navigation to coordinator + route shell pattern
  • Refactoring to Domain/Data/Feature/App package boundaries
  • Setting up dependency injection through DependencyContainer
  • Improving list/collection scroll performance
  • Replacing manual Task management with .task(id:) and cancellable loading

Non-Negotiable Constraints (iOS 26 / Swift 6.2)

  • @Observable ViewModels/coordinators, ObservableObject / @Published never
  • NavigationStack is owned by App-target route shells and coordinators
  • @Equatable macro on every view, AnyView never
  • Domain defines repository/coordinator/error-routing protocols; no framework-coupled I/O
  • No dedicated use-case/interactor layer; ViewModels call repository protocols directly
  • Views never access repositories directly

Rule Categories by Priority

PriorityCategoryImpactPrefixRules
1View Identity & DiffingCRITICALdiff-4
2API ModernizationCRITICALapi-7
3State ArchitectureCRITICALstate-6
4View CompositionHIGHview-7
5Navigation & CoordinationHIGHnav-5
6Layer ArchitectureHIGHlayer-5
7Architecture PatternsHIGHarch-5
8Dependency InjectionMEDIUM-HIGHdi-2
9Type Safety & ProtocolsMEDIUM-HIGHtype-4
10List & Collection PerformanceMEDIUMlist-4
11Async & Data FlowMEDIUMdata-3
12Swift Language FundamentalsMEDIUMswift-8

Quick Reference

1. View Identity & Diffing (CRITICAL)

2. API Modernization (CRITICAL)

3. State Architecture (CRITICAL)

4. View Composition (HIGH)

5. Navigation & Coordination (HIGH)

6. Layer Architecture (HIGH)

7. Architecture Patterns (HIGH)

8. Dependency Injection (MEDIUM-HIGH)

9. Type Safety & Protocols (MEDIUM-HIGH)

10. List & Collection Performance (MEDIUM)

11. Async & Data Flow (MEDIUM)

12. Swift Language Fundamentals (MEDIUM)

How to Use

Read individual reference files for detailed explanations and code examples:

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.