axiom-swift-modern
Original:🇺🇸 English
Translated
Use when reviewing or generating Swift code for modern idiom correctness — catches outdated APIs, pre-Swift 5.5 patterns, and Foundation legacy usage that Claude defaults to
2installs
Sourcecharleswiltgen/axiom
Added on
NPX Install
npx skill4agent add charleswiltgen/axiom axiom-swift-modernTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Modern Swift Idioms
Purpose
Claude frequently generates outdated Swift patterns from its training data. This skill corrects the most common ones — patterns that compile fine but use legacy APIs when modern equivalents are clearer, more efficient, or more correct.
Philosophy: "Don't repeat what LLMs already know — focus on edge cases, surprises, soft deprecations." (Paul Hudson)
Modern API Replacements
| Old Pattern | Modern Swift | Since | Why |
|---|---|---|---|
| | 5.6 | Clearer intent |
| | 5.0 | Single pass, no intermediate allocation |
| | 5.7 | Swift native, no Foundation bridge |
| | 5.5 | Implicit bridging; exceptions: optionals, inout, ObjC-bridged APIs |
| | 5.7 | Type-safe Duration API |
| | 5.5 | No instance management, localizable by default |
| | 5.5 | Type-safe, localized |
| | 5.0 | Handles diacritics, ligatures, width variants |
| | 5.5 | Respects locale name ordering |
| | 5.6 | Modern parsing (throws); use "y" not "yyyy" for display |
| | 5.0 | Required for correct text search/filtering |
Modern Syntax
| Old Pattern | Modern Swift | Since |
|---|---|---|
| | 5.7 |
Explicit | Omit | 5.9 |
| | 5.5 |
| Often not needed — SwiftUI re-exports most UIKit/AppKit types. Retain for UIKit-only APIs ( | 5.5 |
Foundation Modernization
| Old Pattern | Modern Foundation | Since |
|---|---|---|
| | 5.7 |
| | 5.7 |
| Conform to | — |
| | — |
SwiftUI Convenience APIs Claude Misses
- (iOS 17+) automatically includes the search term — no need to compose a custom string
ContentUnavailableView.search(text: searchText) - in Forms (iOS 16+) provides consistent label alignment without manual HStack layout
LabeledContent - must attach to triggering UI — Liquid Glass morphing animations depend on the source element
confirmationDialog()
Common Claude Hallucinations
These patterns appear frequently in Claude-generated code:
- Creates instances inline — Use
DateFormatteror.formatted()instead. If a formatter must exist, make itFormatStyle.static let - Uses — Use
DispatchQueue.main.asyncor@MainActor. Never GCD. (SeeMainActor.runfor full guidance.)axiom-swift-concurrency - Uses for SwiftUI parameters —
CGFloatworks everywhere since Swift 5.5 implicit bridging.Double - Generates — Use
guard let x = x elseshorthand.guard let x else - Returns explicitly in single-expression computed properties — Omit .
return
Resources
Skills: axiom-swift-performance, axiom-swift-concurrency, axiom-swiftui-architecture