axiom-codex/skills/axiom-modernize/SKILL.md
Use when the user wants to modernize iOS code to iOS 17/18 patterns, migrate from ObservableObject to @Observable, update @StateObject to @State, or adopt modern SwiftUI APIs.
npx skillsauth add charleswiltgen/axiom axiom-modernizeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an expert at migrating iOS apps to modern iOS 17/18+ patterns.
Scan the codebase for legacy patterns and provide migration paths:
ObservableObject → @Observable@StateObject → @State with Observable@ObservedObject → Direct property or @Bindable@EnvironmentObject → @EnvironmentReport findings with:
Swift files: **/*.swift
Skip: *Tests.swift, *Previews.swift, */Pods/*, */Carthage/*, */.build/*, */DerivedData/*, */scratch/*, */docs/*, */.claude/*, */.claude-plugin/*
Why migrate: Better performance (view updates only when accessed properties change), simpler syntax, no @Published needed
Requirement: iOS 17+
Detection:
Grep: class.*ObservableObject
Grep: : ObservableObject
Grep: @Published
// ❌ LEGACY (iOS 14-16)
class ContentViewModel: ObservableObject {
@Published var items: [Item] = []
@Published var isLoading = false
@Published var errorMessage: String?
}
// ✅ MODERN (iOS 17+)
@Observable
class ContentViewModel {
var items: [Item] = []
var isLoading = false
var errorMessage: String?
// Use @ObservationIgnored for non-observed properties
@ObservationIgnored
var internalCache: [String: Any] = [:]
}
Migration steps:
: ObservableObject with @Observable macro@Published property wrappers@ObservationIgnored to properties that shouldn't trigger updatesWhy migrate: Simpler, consistent with value types, works with @Observable
Requirement: iOS 17+ with @Observable model
Detection:
Grep: @StateObject
// ❌ LEGACY
struct ContentView: View {
@StateObject private var viewModel = ContentViewModel()
var body: some View { ... }
}
// ✅ MODERN (with @Observable model)
struct ContentView: View {
@State private var viewModel = ContentViewModel()
var body: some View { ... }
}
Note: Only migrate after the model uses @Observable. If model still uses ObservableObject, keep @StateObject.
Why migrate: Simpler code, explicit binding when needed
Requirement: iOS 17+ with @Observable model
Detection:
Grep: @ObservedObject
// ❌ LEGACY
struct ItemView: View {
@ObservedObject var item: ItemModel
var body: some View {
Text(item.name)
}
}
// ✅ MODERN - Direct property (read-only access)
struct ItemView: View {
var item: ItemModel // No wrapper needed!
var body: some View {
Text(item.name)
}
}
// ✅ MODERN - @Bindable (for two-way binding)
struct ItemEditorView: View {
@Bindable var item: ItemModel
var body: some View {
TextField("Name", text: $item.name) // Binding works
}
}
Decision tree:
$item.property)? → Use @BindableWhy migrate: Type-safe, works with @Observable
Requirement: iOS 17+ with @Observable model
Detection:
Grep: @EnvironmentObject
Grep: \.environmentObject\(
// ❌ LEGACY - Setting
ContentView()
.environmentObject(settings)
// ❌ LEGACY - Reading
struct SettingsView: View {
@EnvironmentObject var settings: AppSettings
var body: some View { ... }
}
// ✅ MODERN - Setting
ContentView()
.environment(settings)
// ✅ MODERN - Reading
struct SettingsView: View {
@Environment(AppSettings.self) var settings
var body: some View { ... }
}
// ✅ MODERN - With binding
struct SettingsEditorView: View {
@Environment(AppSettings.self) var settings
var body: some View {
@Bindable var settings = settings
Toggle("Dark Mode", isOn: $settings.darkMode)
}
}
Why migrate: Deprecated modifier, new API has initial parameter
Requirement: iOS 17+
Detection:
Grep: \.onChange\(of:.*perform:
// ❌ DEPRECATED
.onChange(of: searchText) { newValue in
performSearch(newValue)
}
// ✅ MODERN (iOS 17+)
.onChange(of: searchText) { oldValue, newValue in
performSearch(newValue)
}
// ✅ With initial execution
.onChange(of: searchText, initial: true) { oldValue, newValue in
performSearch(newValue)
}
Why migrate: Cleaner code, better error handling, structured concurrency
Requirement: iOS 15+ (widely adopted in iOS 17+)
Detection:
Grep: completion:\s*@escaping
Grep: completionHandler:
Grep: DispatchQueue\.main\.async
// ❌ LEGACY
func fetchUser(id: String, completion: @escaping (Result<User, Error>) -> Void) {
URLSession.shared.dataTask(with: url) { data, response, error in
DispatchQueue.main.async {
if let error = error {
completion(.failure(error))
return
}
// Parse and return
completion(.success(user))
}
}.resume()
}
// ✅ MODERN
func fetchUser(id: String) async throws -> User {
let (data, _) = try await URLSession.shared.data(from: url)
return try JSONDecoder().decode(User.self, from: data)
}
Why migrate: Cleaner API, avoids closure
Requirement: iOS 17+
Detection:
Grep: withAnimation.*\{
// ❌ LEGACY
withAnimation(.spring()) {
isExpanded.toggle()
}
// ✅ MODERN (simple cases)
isExpanded.toggle()
// Apply animation to view:
.animation(.spring(), value: isExpanded)
// Or use new binding animation:
$isExpanded.animation(.spring()).wrappedValue.toggle()
Why migrate: Clearer, more efficient, modern Swift idioms
Detection:
Grep: Date\(\)
Grep: CGFloat
Grep: replacingOccurrences
Grep: DateFormatter\(\)
Grep: \.filter\(.*\)\.count
Grep: Task\.sleep\(nanoseconds:
Reference: See axiom-swift (skills/swift-modern.md) skill for the full modern API replacement table.
Report matches as LOW priority unless they appear in hot paths (then MEDIUM).
Glob: **/*.swift
ObservableObject:
Grep: ObservableObject
Grep: @Published
Property Wrappers:
Grep: @StateObject|@ObservedObject|@EnvironmentObject
Deprecated Modifiers:
Grep: onChange\(of:.*perform:
Completion Handlers:
Grep: completion:\s*@escaping
Grep: completionHandler:
HIGH Priority (significant benefits):
MEDIUM Priority (code quality):
LOW Priority (minor improvements):
# Modernization Analysis Results
## Summary
- **HIGH Priority**: [count] (Significant performance/maintainability gains)
- **MEDIUM Priority**: [count] (Deprecated APIs, code quality)
- **LOW Priority**: [count] (Minor improvements)
## Minimum Deployment Target Impact
- Current patterns support: iOS 14+
- After full modernization: iOS 17+
## HIGH Priority Migrations
### ObservableObject → @Observable
**Files affected**: 5
**Estimated effort**: 2-3 hours
#### Models to Migrate
1. `Models/ContentViewModel.swift:12`
```swift
// Current
class ContentViewModel: ObservableObject {
@Published var items: [Item] = []
@Published var isLoading = false
}
// Migrated
@Observable
class ContentViewModel {
var items: [Item] = []
var isLoading = false
}
Models/UserSettings.swift:8
[Similar migration...]| File | Change |
|------|--------|
| Views/ContentView.swift:15 | @StateObject → @State |
| Views/ItemList.swift:23 | @ObservedObject → plain property |
| Views/SettingsView.swift:8 | @EnvironmentObject → @Environment |
Views/RootView.swift:45
// Current
.environmentObject(settings)
// Migrated
.environment(settings)
Views/SettingsView.swift:12
// Current
@EnvironmentObject var settings: AppSettings
// Migrated
@Environment(AppSettings.self) var settings
Views/SearchView.swift:34
// Deprecated
.onChange(of: query) { newValue in
search(newValue)
}
// Modern
.onChange(of: query) { oldValue, newValue in
search(newValue)
}
Services/NetworkService.swift - 3 completion handler methods
fetchUser(completion:) → fetchUser() async throwsfetchItems(completion:) → fetchItems() async throwsuploadData(completion:) → uploadData() async throwsFirst: Migrate models to @Observable
ObservableObject → @Observable@PublishedSecond: Update view property wrappers
@StateObject → @State (for owned models)@ObservedObject → plain or @Bindable@EnvironmentObject → @EnvironmentThird: Update view modifiers
.environmentObject() → .environment()onChange syntaxFourth: Adopt async/await (optional, but recommended)
⚠️ Deployment Target: Full migration requires iOS 17+
If you need to support iOS 16 or earlier:
ObservableObject for those models#if os(iOS) && swift(>=5.9)
@Observable
class ViewModel { ... }
#else
class ViewModel: ObservableObject { ... }
#endif
After migration:
## When No Migration Needed
```markdown
# Modernization Analysis Results
## Summary
Codebase is already using modern patterns!
## Verified
- ✅ Using `@Observable` macro
- ✅ Using `@State` with Observable models
- ✅ Using `@Environment` for shared state
- ✅ No deprecated modifiers detected
## Optional Improvements
- Consider adopting iOS 18+ features when available
- Review remaining completion handlers for async/await conversion
Is model a class with published properties?
├─ YES: Does it conform to ObservableObject?
│ ├─ YES: Target iOS 17+?
│ │ ├─ YES → Migrate to @Observable
│ │ └─ NO → Keep ObservableObject
│ └─ NO: Already modern or not observable
└─ NO: Check if it's a struct (usually fine)
Is view using @StateObject?
├─ YES: Is the model @Observable?
│ ├─ YES → Change to @State
│ └─ NO → Keep @StateObject until model migrated
└─ NO: Check other wrappers
Is view using @ObservedObject?
├─ YES: Is the model @Observable?
│ ├─ YES: Need binding?
│ │ ├─ YES → Use @Bindable
│ │ └─ NO → Remove wrapper, use plain property
│ └─ NO → Keep @ObservedObject
└─ NO: Already modern
Is view using @EnvironmentObject?
├─ YES: Is the model @Observable?
│ ├─ YES → Change to @Environment(Type.self)
│ └─ NO → Keep @EnvironmentObject
└─ NO: Already modern
Not issues:
AppIntent, EntityQuery, AppEntity, WidgetConfiguration, TimelineProvider, or other App Intents / WidgetKit protocols are NOT ObservableObject and should not be flagged for @Observable migrationCheck before reporting:
ObservableObject — do not flag classes just because they are classesdevelopment
Use when building ANY watchOS app — app structure, independent apps, Watch Connectivity, Smart Stack widgets, complications, controls, RelevanceKit, background tasks, ClockKit migration.
development
Use when working with HealthKit, WorkoutKit, health data, workouts, or fitness features on iOS or watchOS. Covers permissions, queries, background delivery, custom workouts, multidevice coordination.
development
Use when building, fixing, or improving ANY SwiftUI UI — views, navigation, layout, animations, performance, architecture, gestures, debugging, iOS 26 features.
content-media
Use when working with camera, photos, audio, haptics, ShazamKit, or Now Playing. Covers AVCaptureSession, PHPicker, PhotosPicker, AVFoundation, Core Haptics, audio recognition, MediaPlayer, CarPlay, MusicKit.