swift-concurrency

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

2|Updated Sep 8, 2026
One-click install
npx skills add https://github.com/hanshi-notes/hanshi --skill swift-concurrency-hanshi-notes
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: swift-concurrency
Source: https://github.com/hanshi-notes/hanshi/tree/main/.agents/skills/swift-concurrency
Command: npx skills add https://github.com/hanshi-notes/hanshi --skill swift-concurrency-hanshi-notes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Swift Concurrency introduces compiler diagnostics around actors, Sendable, and isolation that are hard to interpret, and migrating callback-based or legacy code to async/await and Swift 6 often produces confusing data-race and isolation errors. ## Core Features & Use Cases - Diagnostic Triage: Maps common compiler and SwiftLint errors (MainActor isolation, Sendable violations, async_without_await, Core Data warnings) to the smallest safe fix. - Refactoring Guidance: Converts callback-based code to async/await, chooses between Task, async let, task groups, actors, and Mutex, and advises on Task entry isolation. - Swift 6 Migration: Provides a build-fix-rebuild-test validation loop and deep reference files covering actors, Sendable, AsyncStream, AsyncAlgorithms, Core Data, testing, and performance. - Use Case: When a build fails with "Sending value of non-Sendable type risks causing data races", the skill checks project concurrency settings, identifies the isolation boundary, and proposes a minimal behavior-preserving fix. ## Quick Start Ask the assistant to fix the Swift concurrency compiler errors in your project using the swift-concurrency skill.

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, then either isolate the caller with @MainActor or wrap the call in await MainActor.run. Avoid applying @MainActor as a blanket fix without justifying main-actor ownership.

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

Add a new async method alongside the old one, remove the completion parameter, and replace closure calls with await. For delegate or callback APIs, bridge them with AsyncStream or withCheckedContinuation.

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 code integration, or fine-grained locking with short critical sections.

Does Swift 6 enable strict concurrency checking by default?▼

Yes, Swift 6 enables strict concurrency checking and complete data-race safety at compile time, enforcing Sendable requirements and isolation checking across async boundaries. Migration should proceed one error category at a time with build and test validation.

Why does passing NSManagedObject across actors cause warnings?▼

NSManagedObject is not Sendable and is bound to its context's queue, so crossing isolation boundaries risks data races. Pass NSManagedObjectID instead, or map the object to a Sendable value type, and never use @unchecked Sendable on managed objects.

When should I avoid Task.detached in Swift concurrency?▼

Avoid Task.detached unless you have a documented reason, since it drops the caller's isolation and priority. Prefer structured concurrency with async let or task groups, and use Task { @concurrent in } when the synchronous prefix needs no main-actor access.