
modern-swift
Use when writing async/await code, enabling strict concurrency, fixing Sendable errors, migrating from completion handlers, managing shared state with actors, or using Task/TaskGroup for concurrency.
- Installs
- 180
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/johnrogers/claude-swift-engineering --skill modern-swift- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads modern-swift automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Modern Swift (6.2+)
Swift 6.2 introduces strict compile-time concurrency checking with async/await, actors, and Sendable constraints that prevent data races at compile time instead of runtime. This is the foundation of safe concurrent Swift.
Overview
Modern Swift replaces older concurrency patterns (completion handlers, DispatchQueue, locks) with compiler-enforced safety. The core principle: if it compiles with strict concurrency enabled, it cannot have data races.
Quick Reference
| Need | Use | NOT |
|---|---|---|
| Async operation | async/await | Completion handlers |
| Main thread work | @MainActor | DispatchQueue.main |
| Shared mutable state | actor | Locks, serial queues |
| Parallel tasks | TaskGroup | DispatchGroup |
| Thread safety | Sendable | @unchecked everywhere |
Core Workflow
When writing async Swift code:
- Mark async functions with
async, call withawait - Apply
@MainActorto view models and UI-updating code - Use
actorinstead of locks for shared mutable state - Check
Task.isCancelledor callTask.checkCancellation()in loops - Enable strict concurrency in Package.swift for compile-time safety
Reference Loading Guide
ALWAYS load reference files if there is even a small chance the content may be required. It's better to have the context than to miss a pattern or make a mistake.
| Reference | Load When |
|---|---|
| Concurrency Essentials | Writing async code, converting completion handlers, using await |
| Swift 6 Concurrency | Using @concurrent, nonisolated(unsafe), or actor patterns |
| Task Groups | Running multiple async operations in parallel |
| Task Cancellation | Implementing long-running or cancellable operations |
| Strict Concurrency | Enabling Swift 6 strict mode or fixing Sendable errors |
| Macros | Using or understanding Swift macros like @Observable |
| Modern Attributes | Migrating legacy code or using @preconcurrency, @backDeployed |
| Migration Patterns | Modernizing delegate patterns or UIKit views |
Common Mistakes
-
@unchecked Sendableas a quick fix — Using@unchecked Sendableto silence compiler errors means you've opted out of safety. If the error persists after@unchecked, your code has a potential data race. Fix the underlying issue instead. -
Missing
awaitat call sites — Forgettingawaitwhen calling async functions is a compiler error, but checkingTask.isCancelledin a loop without callingTask.checkCancellation()silently ignores cancellation. -
Capturing
selfin async blocks withoutweak— Holding a strong reference toselfin a long-running async task prevents deinit. Always use[weak self]in closures or use.taskwhich auto-manages the lifecycle. -
Not checking task cancellation — Long-running operations should regularly check
Task.isCancelledor callTask.checkCancellation(), otherwise cancellation signals are ignored. -
Forgetting
@MainActoron UI code and test suites — Main test struct and view models that update@Publishedproperties need@MainActor. Forgetting it silently allows cross-thread mutations. Apply@MainActorto: view models, view structs, main test structs, and any type that touches UI. -
Actor re-entrancy surprises —
awaitinside an actor method can release the lock temporarily. Another task may modify actor state. Design actor methods assuming state can change betweenawaitpoints.
FAQ
What does the modern-swift skill do?
Use when writing async/await code, enabling strict concurrency, fixing Sendable errors, migrating from completion handlers, managing shared state with actors, or using Task/TaskGroup for concurrency.
How do I install modern-swift?
Run npx skills add https://github.com/johnrogers/claude-swift-engineering --skill modern-swift in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/modern-swift/ (personal) or .claude/skills/modern-swift/ (project).
Which AI agents can use modern-swift?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is modern-swift safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains modern-swift?
It is published by johnrogers in johnrogers/claude-swift-engineering. It has 180 recorded installs.
More from johnrogers/claude-swift-engineering
swift-style
johnrogers/claude-swift-engineering
Swift code style conventions for clean, readable code. Use when writing Swift code to ensure consistent formatting, naming, organization, and idiomatic patterns.
ios-hig
johnrogers/claude-swift-engineering
Open the skill to read its SKILL.md instructions.
swiftui-patterns
johnrogers/claude-swift-engineering
Open the skill to read its SKILL.md instructions.
ios-26-platform
johnrogers/claude-swift-engineering
Use when implementing iOS 26 features (Liquid Glass, new SwiftUI APIs, WebView, Chart3D), deploying iOS 26+ apps, or supporting backward compatibility with iOS 17/18.
composable-architecture
johnrogers/claude-swift-engineering
Use when building features with TCA (The Composable Architecture), structuring reducers, managing state, handling effects, navigation, or testing TCA features. Covers @Reducer, Store, Effect, TestStore, reducer composition, and TCA patterns.
swift-testing
johnrogers/claude-swift-engineering
Use when writing tests with Swift Testing (@Test,
Popular mobile skills
design-mobile-apps
designed-by-ai/skills
Design mobile app screens with Sleek, edit Sleek projects, and implement their designs in React Native or HTML.
ios-design
uizze.sh
Design and review iOS UI/UX for iPhone apps in SwiftUI, UIKit, or React Native. Use for mobile app design, screen redesigns, navigation flows, typography, forms, keyboard and safe-area layout, and accessibility checks. Apply Apple Human Interface Guidelines and consult real product references through the optional Uizze connection.
vercel-react-native-skills
vercel-labs/agent-skills
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
animate-expo
emilkowalski/skills
Build animations in React Native and Expo, making the decisions in the order that determines whether they feel right — should it animate, which thread it runs on, which properties, spring or timing, how the gesture hands off, how it degrades. Writes the implementation with Reanimated, Gesture Handler, Expo Router and expo-haptics. Use when animating anything in an Expo app, adding gestures, sheets, screen transitions, press feedback or haptics, or fixing motion that stutters on device. For web animation use animate.
xcode-project-setup
firebase/agent-skills
Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).
firebase-remote-config-basics
firebase/agent-skills
Manages Firebase Remote Config templates, feature flags, loading strategies, and SDKs (Android, iOS). Use when downloading/deploying remoteconfig JSON templates, managing version history/feature flags, setting in-app defaults, fetchAndActivate(), real-time listeners, or SDK setup. Don't use for Firebase Hosting, Auth, Firestore, Data Connect, Crashlytics, or App Hosting.