Skillshub axiom-swift-modern
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
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/CharlesWiltgen/Axiom/axiom-swift-modern" ~/.claude/skills/comeonoliver-skillshub-axiom-swift-modern && rm -rf "$T"
manifest:
skills/CharlesWiltgen/Axiom/axiom-swift-modern/SKILL.mdsource content
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 |
| with | 5.5 | Respects locale name ordering |
with DateFormatter | | 5.6 | Modern parsing (throws); use "y" not "yyyy" for display |
on user input | | 5.0 | Required for correct text search/filtering |
Modern Syntax
| Old Pattern | Modern Swift | Since |
|---|---|---|
| | 5.7 |
Explicit in single-expression | Omit ; / are expressions | 5.9 |
in modifiers | (static member lookup) | 5.5 |
alongside | Often not needed — SwiftUI re-exports most UIKit/AppKit types. Retain for UIKit-only APIs (, etc.) | 5.5 |
Foundation Modernization
| Old Pattern | Modern Foundation | Since |
|---|---|---|
| | 5.7 |
| | 5.7 |
(repeated) | Conform to , call | — |
in date format for display | — correct in all calendar systems | — |
SwiftUI Convenience APIs Claude Misses
(iOS 17+) automatically includes the search term — no need to compose a custom stringContentUnavailableView.search(text: searchText)
in Forms (iOS 16+) provides consistent label alignment without manual HStack layoutLabeledContent
must attach to triggering UI — Liquid Glass morphing animations depend on the source elementconfirmationDialog()
Common Claude Hallucinations
These patterns appear frequently in Claude-generated code:
- Creates
instances inline — UseDateFormatter
or.formatted()
instead. If a formatter must exist, make itFormatStyle
.static let - Uses
— UseDispatchQueue.main.async
or@MainActor
. Never GCD. (SeeMainActor.run
for full guidance.)axiom-swift-concurrency - Uses
for SwiftUI parameters —CGFloat
works everywhere since Swift 5.5 implicit bridging.Double - Generates
— Useguard let x = x else
shorthand.guard let x else - Returns explicitly in single-expression computed properties — Omit
.return
Resources
Skills: axiom-swift-performance, axiom-swift-concurrency, axiom-swiftui-architecture