/swift-modern-dev:swift-anti-pattern-guardfrom swift-modern-dev
Detects and replaces outdated Swift patterns including ObservableObject, DispatchQueue.main, NavigationView, and Core Data with modern SwiftUI equivalents.
Ships in swift-modern-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Detect and replace the highest-impact forbidden patterns. Advisory unless hooks already block them.
| ALWAYS | NEVER |
|---|---|
| Report file + pattern + replacement | Auto-rewrite entire modules without review |
| Align with repository guidance and deployment targets | Treat “legacy file” as a permanent exemption without explanation |
Forbidden: ObservableObject, @Published, @StateObject, @ObservedObject, @EnvironmentObject
Replace: @Observable + plain properties; own with @State / inject via @Environment
Forbidden: DispatchQueue.main.async, asyncAfter
Replace: @MainActor, await MainActor.run, Task { @MainActor in }
Forbidden: NavigationView
Replace: NavigationStack or NavigationSplitView
Forbidden: NSManagedObject, @FetchRequest, NSPersistentContainer
Replace: SwiftData @Model, @Query, ModelContext
rg -n "ObservableObject|@Published|@StateObject|@ObservedObject|DispatchQueue\\.main|NavigationView|NSManagedObject|@FetchRequest" --glob '*.swift' .
| Excuse | Reality |
|---|---|
| "Only one ObservableObject" | In greenfield Observation code, consistency avoids two state models |
| "DispatchQueue is clearer" | @MainActor is clearer under Swift 6 |
| "Core Data already works" | Preserve existing persistence during narrow fixes; scope a migration separately unless required and authorized |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub pstuart/pstuart --plugin swift-modern-dev7 skills in this plugin
/ios-accessibilityUse when implementing or auditing VoiceOver, Dynamic Type, accessibility labels, focus, contrast, or Hit-testing for SwiftUI iOS/macOS apps./memory-leak-diagnosisUse when investigating memory growth, retain cycles, leaks in Instruments, Task cancellation issues, or ARC problems in Swift 6 apps./swift-app-scaffoldUse when starting a new iOS or macOS app, bootstrapping Package.swift, or scaffolding a modern SwiftUI architecture with Observation, SwiftData, NavigationStack, and Swift Testing./swift-modern-architectureUse when writing Swift or SwiftUI code, designing iOS/macOS architecture, modernizing legacy patterns, or choosing ViewModels, SwiftData, navigation, or concurrency APIs./swift-performance-optimizationUse when profiling slow SwiftUI screens, optimizing lists, reducing main-thread work, improving memory/CPU, or using Instruments Time Profiler or Swift Concurrency tools./swift-test-scaffoldUse when adding Swift tests, creating test targets, scaffolding ViewModel or service tests, or choosing Swift Testing over XCTest.Other plugins' skills for the same job