swift-refactor
БесплатноБез исполняемых скриптовНе проверенSwift and SwiftUI refactoring patterns aligned with the iOS 26 / Swift 6.2 clinic modular MVVM-C architecture (Airbnb + OLX SPM layout). Enforces @Observable…
от pproenca★ 231 звезда на GitHubОб этом скилле
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+DesignSystemonly (neverData, never sibling features) - App target is the convergence point and owns
DependencyContainer, concrete coordinators, and Route Shell wiring Domainstays pure Swift and defines models plus repository,*Coordinating,ErrorRouting, andAppErrorcontractsDataowns 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)
@ObservableViewModels/coordinators,ObservableObject/@PublishedneverNavigationStackis owned by App-target route shells and coordinators@Equatablemacro on every view,AnyViewnever- 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
| 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)
diff-equatable-views- Add @Equatable macro to every SwiftUI viewdiff-closure-skip- Use @EquatableIgnored for closure propertiesdiff-identity-stability- Use stable O(1) identifiers in ForEachdiff-printchanges-debug- Use _printChanges() to diagnose re-renders
2. API Modernization (CRITICAL)
api-observable-macro- Migrate ObservableObject to @Observable macroapi-navigationstack-migration- Replace NavigationView with NavigationStackapi-onchange-signature- Migrate to new onChange signatureapi-environment-object-removal- Replace @EnvironmentObject with @Environmentapi-alert-confirmation-dialog- Migrate Alert to confirmationDialog APIapi-list-foreach-identifiable- Replace id: .self with Identifiable conformanceapi-toolbar-migration- Replace navigationBarItems with toolbar modifier
3. State Architecture (CRITICAL)
- [
state-scope-minimization](referenc
Установить swift-refactor в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл swift-refactor?
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-owned I/O with stale-while-revalidate plus optimistic queued sync boundaries. Use when refactoring existing SwiftUI code into the clinic architecture.
Как установить скилл swift-refactor?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл swift-refactor запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic