Swift refactor

From pproenca/dot-skills · View interactive version

Swift refactor is an AI agent skill from the GitHub repository pproenca/dot-skills. Swift and SwiftUI refactoring patterns aligned with the iOS 26 / Swift 6.2 clinic modular MVVM-C architecture (Airbnb + OLX SPM layout). Enforces @Observable ViewModels/coordinators, App-target `DependencyContainer` + route shells, Domain repository/coordinator/error-routing protocols, and Data-owne

How to use this skill

Skill file

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:

When to Apply

Reference these guidelines when:

Non-Negotiable Constraints (iOS 26 / Swift 6.2)

Rule Categories by Priority

| Priority | Category | Impact | Prefix | Rules |

|----------|----------|--------|--------|-------|

| 1 | View Identity & Diffing | CRITICAL | diff- | 4 |

| 2 | API Modernization | CRITICAL | api- | 7 |

| 3 | State Architecture | CRITICAL | state- | 6 |

| 4 | View Composition | HIGH | view- | 7 |

| 5 | Navigation & Coordination | HIGH | nav- | 5 |

| 6 | Layer Architecture | HIGH | layer- | 5 |

| 7 | Architecture Patterns | HIGH | arch- | 5 |

| 8 | Dependency Injection | MEDIUM-HIGH | di- | 2 |

| 9 | Type Safety & Protocols | MEDIUM-HIGH | type- | 4 |

| 10 | List & Collection Performance | MEDIUM | list- | 4 |

| 11 | Async & Data Flow | MEDIUM | data- | 3 |

| 12 | Swift Language Fundamentals | MEDIUM | swift- | 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

| File | Description |

|------|-------------|

| references/_sections.md | Category definitions and ordering |

| assets/templates/_template.md | Template for new rules |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.