modern-swift
Modern Swift equips you with patterns for Swift 6.2's compiler-enforced concurrency model, replacing legacy approaches like completion handlers and DispatchQueue with async/await, actors for shared state, and Sendable constraints. Learn to enable strict concurrency checking, migrate existing code, and avoid common pitfalls like misused @unchecked Sendable and forgotten @MainActor annotations.
Modern Swift helps you write safe concurrent code using async/await, actors, and compile-time Sendable checking.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-01-18
Modern Swift helps you write safe concurrent code using async/await, actors, and compile-time Sendable checking. Modern Swift equips you with patterns for Swift 6.2's compiler-enforced concurrency model, replacing legacy approaches like completion handlers and DispatchQueue with async/await, actors for shared state, and Sendable constraints. Learn to enable strict concurrency checking, migrate existing code, and avoid common pitfalls like misused @unchecked Sendable and forgotten @MainActor annotations.
Use it when
- Modern Swift's migration path replaces callback-based APIs with async/await syntax.
- Modern Swift requires types crossing actor boundaries to conform to Sendable.
Verify before relying
Read SKILL.md below before installing (9 files). Open directory: indexed for reading, not audited.
Install
johnrogers/claude-swift-engineering/modern-swift · repository language: Python
Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I enable strict concurrency checking in my Swift package?
Modern Swift supports strict concurrency mode through your Package.swift configuration. Add `.upcomingFeature("StrictConcurrency")` to your target's swiftSettings, or use the `-strict-concurrency=complete` compiler flag. This enforces Sendable conformance and catches potential data races at compile time, aligning with Swift 6.2's compiler-enforced safety model.
What's the best way to migrate completion handlers to async await?
Modern Swift's migration path replaces callback-based APIs with async/await syntax. Convert completion handler parameters into return values or throws, wrap legacy callbacks using withCheckedThrowingContinuation, and update call sites to use await. This eliminates callback hell and makes error handling clearer while preparing code for strict concurrency checking.
How can I fix Sendable errors in Modern Swift?
Modern Swift requires types crossing actor boundaries to conform to Sendable. Ensure all captured variables are Sendable, use value types instead of classes where possible, and mark UI-bound types with @MainActor. Avoid @unchecked Sendable unless absolutely necessary; instead, refactor to use immutable data or proper actor isolation to satisfy the compiler's safety guarantees.
What is the actor pattern for managing shared mutable state?
Modern Swift's actor model isolates mutable state behind a single serial executor. Define an actor type, mark properties as private, and expose them through async methods. Actors prevent concurrent access automatically—the compiler enforces that only one task can modify state at a time, eliminating data races without manual locks.
How do I use async await in Swift 6 for concurrent operations?
Modern Swift's async/await syntax lets you write concurrent code that reads sequentially. Mark functions with async, use await at call sites, and leverage TaskGroup or async let for parallel work. This replaces DispatchQueue and completion handlers, making concurrency safer and more readable while enabling strict concurrency checking.
When should I use @MainActor for UI updates in Modern Swift?
Modern Swift requires all UI updates on the main thread. Annotate your view controller or view model class with @MainActor, or mark individual methods with @MainActor to enforce main-thread execution. The compiler prevents accidental background UI mutations, catching threading bugs early and integrating seamlessly with async/await and actor isolation.
SKILL.md
Rendered from the published skill. Quoted content, verbatim.
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:
1. Mark async functions with async, call with await
2. Apply @MainActor to
(truncated - see the full file via the links below)
File tree — 9 files
plugins/swift-engineering/skills/modern-swift/SKILL.md
plugins/swift-engineering/skills/modern-swift/references/concurrency-essentials.md
plugins/swift-engineering/skills/modern-swift/references/macros.md
plugins/swift-engineering/skills/modern-swift/references/migration-patterns.md
plugins/swift-engineering/skills/modern-swift/references/modern-attributes.md
plugins/swift-engineering/skills/modern-swift/references/strict-concurrency.md
plugins/swift-engineering/skills/modern-swift/references/swift6-concurrency.md
plugins/swift-engineering/skills/modern-swift/references/task-cancellation.md
plugins/swift-engineering/skills/modern-swift/references/task-groups.md
Let your AI agent find skills like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.
wish › “Write safe concurrent Swift code using async/await and actors”
Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →
Related skills
Navigate Swift's modern concurrency model with patterns for async/await, structured task management, actor-based isolation, and Swift 6.2 features. This skill guides you through compiler errors, data race prevention, and migration strategies—whether you're bridging legacy APIs or adopting strict concurrency in new code.
This skill guides developers through converting legacy iOS applications from Objective-C to Swift, covering the technical and architectural decisions needed for a successful transition. Learn strategies for managing dependencies, refactoring code patterns, and maintaining app stability during the migration process.
This skill guides you through Swift 6.2's "Approachable Concurrency" features that simplify strict concurrency adoption. Discover how default MainActor inference eliminates manual annotations, how async functions now stay on their calling actor, and how to use @concurrent for explicit background execution. Perfect for migrating from Swift 6.0/6.1 or resolving data-race errors with the latest toolchain.
Swift Development provides language-level guidance for writing correct, performant Swift across iOS, macOS, and other Apple platforms. It covers concurrency architecture with async/await and actors, Swift 6 strict concurrency migration, memory optimization through InlineArray and Span, and code complexity standards via SwiftLint thresholds. Use it to review code for data races, actor isolation, and modern idioms.
axiom-concurrency equips AI coding assistants with expert-level Swift 6 concurrency knowledge to eliminate data races and isolation violations. This skill covers modern async/await patterns, actor isolation, and sendability constraints—essential for building robust Apple OS applications. Prevent crashes and memory issues before they reach users.
This skill systematically scans Swift codebases for concurrency anti-patterns that cause data races, UI freezes, and resource leaks. It maps isolation architecture, identifies unsafe task captures and delegate patterns, verifies actor boundaries, and flags missing concurrency safeguards—then cross-references findings to surface compound risks that static analysis alone might miss.
More skills swift-concurrency (MIT) · swift-concurrency-expert (MIT) · Swift (unlicensed) · Swift Concurrency Expert Guide (unlicensed)