swift-concurrency-developer

Diagnose and fix Swift concurrency issues involving actors, Sendable, and task isolation.

514|79|Updated May 26, 2023
One-click install
npx skills add https://github.com/anyproto/anytype-swift --skill swift-concurrency-developer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-concurrency-developer
Source: https://github.com/anyproto/anytype-swift/tree/main/.claude/skills/swift-concurrency-developer
Command: npx skills add https://github.com/anyproto/anytype-swift --skill swift-concurrency-developer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Swift concurrency code often produces confusing compiler diagnostics like "Sending value of non-Sendable type" or "Main actor-isolated cannot be used from a nonisolated context", and incorrect fixes can introduce data races, deadlocks, or app rejections. This Skill provides structured guidance for reasoning about isolation domains, choosing correct fixes, and migrating to Swift 6 strict concurrency.

Core Features & Use Cases

  • Isolation-Aware Diagnosis: Identifies the isolation boundary (@MainActor, custom actor, nonisolated) before proposing fixes, and reads project build settings (Swift language mode, strict concurrency level, default isolation) from Package.swift or .pbxproj before interpreting diagnostics.
  • Triage Playbooks: Maps common errors (non-Sendable warnings, MainActor isolation errors, XCTest async errors, Core Data concurrency warnings) to targeted reference files with preferred fixes.
  • Migration Support: Provides a build-fix-rebuild-test validation loop for Swift 6 and strict-concurrency migration with minimal blast radius.
  • Use Case: A developer hits "Sending value of non-Sendable type risks causing data races" after enabling strict concurrency. The Skill traces where the value crosses an isolation boundary, then guides a fix using Sendable conformance or actor isolation rather than blanket @MainActor annotations.

Quick Start

Ask the assistant to explain and fix a Swift concurrency warning in your code, such as a data race error involving an actor or Sendable type.

Frequently Asked Questions about swift-concurrency-developer

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

FAQPage Schema
How do I fix "Sending value of non-Sendable type risks causing data races" in Swift?

First identify where the value crosses an isolation boundary, such as between actors or into a Task. Then either make the type Sendable (value types conform automatically), pass an immutable copy, or keep the value within a single isolation domain instead of sending it.

How do I fix "Main actor-isolated cannot be used from a nonisolated context"?

Decide whether the code truly belongs on @MainActor, such as UI state mutations. If yes, annotate the calling context or await the call; if not, mark the member nonisolated or move it off the main actor rather than applying @MainActor as a blanket fix.

Should I use an actor or Mutex for thread-safe state in Swift?

Use an actor when working in async contexts and needing logical isolation of mutable state. Use Mutex (iOS 18+, macOS 15+) when you need synchronous access, fine-grained locking, or integration with legacy non-async code.

Can I use Core Data NSManagedObject with Swift concurrency?

NSManagedObject is not Sendable and must not cross isolation boundaries. Pass NSManagedObjectID between contexts instead, wrap access in context.perform blocks, and use @MainActor for view context operations and background contexts for heavy work.

Why does my async code deadlock when using DispatchSemaphore?

DispatchSemaphore and DispatchGroup.wait block threads, violating the cooperative thread pool contract that threads must always make forward progress. Replace them with async/await so the runtime can schedule work without hidden blocking dependencies.

What is the difference between Task and Task.detached in Swift?

Task inherits the current actor context and priority, making it suitable for work related to the caller. Task.detached starts with no inherited context and should only be used when you explicitly need to break isolation, such as CPU-heavy background work.