concurrency-patterns

Resolve Swift concurrency issues including data races and actor isolation errors.

27|5|Updated Apr 18, 2026
One-click install
npx skills add https://github.com/bocan/bocan-music --skill concurrency-patterns-bocan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: concurrency-patterns
Source: https://github.com/bocan/bocan-music/tree/main/.claude/skills/swift/concurrency-patterns
Command: npx skills add https://github.com/bocan/bocan-music --skill concurrency-patterns-bocan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves common Swift concurrency pain points including data race crashes, actor isolation compiler errors, and the complexity of migrating legacy code to Swift 6 strict concurrency, eliminating hours of debugging and trial-and-error.

Core Features & Use Cases

  • Swift 6 Migration Guidance: Step-by-step incremental adoption path from minimal to complete strict concurrency checking, with fixes for common migration issues like global variables, non-Sendable closures, and protocol conformance errors.
  • Structured Concurrency Patterns: Best practices for async let, TaskGroup, .task modifiers, and task cancellation to replace error-prone unstructured Task {} usage.
  • Actor Isolation & Sendable Rules: Patterns for protecting shared mutable state with actors, avoiding reentrancy bugs, and correctly implementing Sendable conformance for types crossing isolation boundaries.
  • Legacy API Bridging: Patterns for wrapping callback, delegate, and notification-based APIs into async/await using continuations and AsyncStream.
  • Swift 6.2 Approachable Concurrency: Guidance for using @concurrent, isolated conformances, and infer main actor by default to reduce concurrency boilerplate.
  • Use Case: A developer working on a native macOS music player like Bòcan can use this Skill to fix data race errors in the audio playback DSP chain, migrate the library indexing code to Swift 6, and bridge legacy FFmpeg callback APIs to async/await.

Quick Start

Use the concurrency-patterns skill to resolve the strict concurrency compiler errors in your Swift 6 music player project and refactor the legacy audio session callback APIs to modern async/await.

Frequently Asked Questions about concurrency-patterns

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

FAQPage Schema
How do I fix Swift 6 data race errors and actor isolation compiler warnings?

Fix Swift 6 data races and actor isolation errors by applying structured concurrency patterns, conforming types to Sendable, and protecting shared mutable state with actors.

What is the best way to migrate legacy callback APIs to async/await in Swift?

Bridge legacy callback, delegate, and notification-based APIs to async/await by wrapping them with continuations and AsyncStream to eliminate callback complexity.

How does Sendable compliance work when crossing actor isolation boundaries?

Sendable compliance ensures types can safely cross actor isolation boundaries without causing data races by requiring immutable or thread-safe concurrent access patterns.

When should I use Swift TaskGroup instead of unstructured Task blocks?

Use Swift TaskGroup for structured concurrency to manage parallel async let operations and task cancellation safely, replacing error-prone unstructured Task {} usage.

Can I incrementally adopt Swift 6 strict concurrency checking without migrating everything at once?

Incrementally adopt Swift 6 strict concurrency by following a step-by-step path from minimal to complete checking, fixing global variables and non-Sendable closures progressively.

Why do I get reentrancy bugs in my Swift actors and how do I prevent them?

Actor reentrancy bugs occur when isolated state is modified across awaited calls; prevent them by applying strict actor isolation rules and structured concurrency patterns.