swift-concurrency-expert

Fix Swift 6.2+ concurrency compile-time data-race and actor-isolation errors.

330|47|Updated Aug 30, 2020
One-click install
npx skills add https://github.com/harperreed/dotfiles --skill swift-concurrency-expert-harperreed
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-concurrency-expert
Source: https://github.com/harperreed/dotfiles/tree/main/.claude/skills/swift-concurrency-expert
Command: npx skills add https://github.com/harperreed/dotfiles --skill swift-concurrency-expert-harperreed

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It resolves Swift Concurrency compile-time data-race and actor-isolation issues in Swift 6.2+ codebases by aligning the code with Swift’s stricter concurrency checking.

Core Features & Use Cases

  • Triage compiler diagnostics: identifies the exact error cause (actor context, isolation boundary, Sendable/data-race risk, and concurrency mode like approachable concurrency).
  • Minimal behavior-preserving remediation: applies the smallest safe changes such as adding @MainActor where UI-bound, using isolated conformances, protecting global/static state, and restructuring background work.
  • Sendable and offloading correctness: improves safety by preferring value/immutable patterns, avoiding unsafe Sendable, and using @concurrent/@MainActor/@isolated patterns to run expensive work off the main actor without introducing races.
  • Use case: Fix a Swift 6.2 compiler failure where a @MainActor model calls an async method on mutable state that the compiler flags as crossing isolation boundaries, then adjust isolation or conformance so the call is concurrency-correct.

Quick Start

Ask for a Swift 6.2+ concurrency review of the failing file by pasting the exact compiler diagnostics and the relevant code snippet to explain and fix the actor isolation and Sendable issues.

Frequently Asked Questions about swift-concurrency-expert

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

FAQPage Schema
How do I fix Swift 6.2 data-race safety and actor isolation compiler errors?

Fix Swift 6.2 data-race safety and actor isolation compiler errors by identifying the exact actor context, proposing minimal behavior-preserving edits like adding @MainActor to UI-bound models, and applying safe isolation boundaries to resolve concurrency diagnostics.

What causes a Swift 6.2 concurrency error when a @MainActor model crosses isolation boundaries?

A Swift 6.2 concurrency error crossing isolation boundaries occurs when a @MainActor model calls async methods on mutable state flagged by the compiler, requiring adjustments to isolation or protocol conformances to ensure Sendable compliance and correct data-race safety.

How do I make a Swift protocol conformance safe with main-actor types?

Make a Swift protocol conformance safe with main-actor types by applying isolated conformances that satisfy the compiler's stricter concurrency checking, ensuring the conformance aligns with the expected actor context without introducing data-race risks.

Can I use @concurrent patterns to offload background work without causing data races?

Use @concurrent and @isolated patterns to offload expensive background work from the main actor without causing data races by preferring value types or immutable patterns over unsafe Sendable declarations for protected state.

Does this approach work for global and static shared mutable state in Swift?

Yes, this approach works for global and static shared mutable state in Swift by identifying the isolation boundary and applying protected state mechanisms to satisfy Swift 6.2 data-race safety requirements during the concurrency triage process.