swift-concurrency

Diagnose Swift Concurrency issues and guide async/await refactoring and Swift 6 migration.

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/RavitejaKarra24/dotfiles --skill swift-concurrency-ravitejakarra24
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-concurrency
Source: https://github.com/RavitejaKarra24/dotfiles/tree/main/agents/.agents/skills/swift-concurrency
Command: npx skills add https://github.com/RavitejaKarra24/dotfiles --skill swift-concurrency-ravitejakarra24

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Swift Concurrency introduces strict data-race checking, actor isolation, and Sendable requirements that produce confusing compiler diagnostics and risky migration decisions. This Skill helps developers interpret those diagnostics, choose the smallest safe fix, and refactor callback-based code to async/await without introducing data races. ## Core Features & Use Cases - Diagnostic Triage: Maps common compiler and SwiftLint errors (actor isolation, Sendable violations, async_without_await, XCTest waits) to the smallest behavior-preserving fix. - Swift 6 Migration Guidance: Walks through strict concurrency settings, default isolation, upcoming features, and a build-fix-rebuild-test validation loop. - Deep Reference Library: Routes questions to focused references on actors, Sendable, tasks, AsyncSequence, AsyncAlgorithms, Core Data, testing, performance, and memory management. - Use Case: A developer hits "Sending value of non-Sendable type risks causing data races" while migrating a view model. The Skill checks the project's isolation settings, identifies the boundary being crossed, and recommends keeping access inside one actor or converting the value to an immutable type. ## Quick Start Ask the assistant to diagnose a Swift concurrency compiler error or refactor a specific callback-based function to async/await, pasting the exact diagnostic and relevant code.

Frequently Asked Questions about swift-concurrency

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix 'Main actor-isolated cannot be used from a nonisolated context' in Swift?

First confirm the code is truly UI-bound. If so, isolate the caller with @MainActor or wrap the call in await MainActor.run. If the work is not UI-related, move it off the main actor instead of adding isolation as a blanket fix.

How do I convert callback-based Swift code to async/await?

Add a new async method alongside the old one, replace completion handlers with return values or throws, and bridge with withCheckedThrowingContinuation when the underlying API is still closure-based. Remove optional unwrapping since async APIs return non-optional values.

When should I use an actor vs Mutex in Swift?

Use an actor in async contexts when you need logical isolation of mutable state. Use Mutex (iOS 18+, macOS 15+) for synchronous access, legacy non-async code, or fine-grained locking where async overhead is unnecessary.

Does Swift Concurrency work with Core Data NSManagedObject?

NSManagedObject is not Sendable and must not cross context or actor boundaries. Pass NSManagedObjectID instead, access contexts through perform, and mark manually generated subclasses as nonisolated when default MainActor isolation is enabled.

Why does my Swift 6 migration keep producing Sendable warnings?

Sendable warnings appear when values cross isolation boundaries without safe transfer semantics. Prefer immutable value types, keep access inside one actor, and reserve @unchecked Sendable for cases with a documented safety invariant and removal plan.

What is the difference between AsyncStream and AsyncChannel?

AsyncStream bridges callbacks and delegates to async iteration but supports only a single consumer. AsyncChannel from the AsyncAlgorithms package provides backpressure and point-to-point delivery for producer-consumer scenarios with multiple senders.