swift-concurrency-6-2

Fixes Swift 6.2 concurrency migration issues causing data-race safety errors.

1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill swift-concurrency-6-2-khetansarvesh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-concurrency-6-2
Source: https://github.com/khetansarvesh/ai_skills_repo/tree/main/skills/swift-concurrency-6-2
Command: npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill swift-concurrency-6-2-khetansarvesh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you resolve Swift 6.2 concurrency migration issues where code that used to run “as expected” now fails with data-race safety errors due to implicit background offloading and ambiguous actor isolation.

Core Features & Use Cases

  • Single-threaded by default migration guidance: Clarifies how Swift 6.2 keeps async work on the calling actor by default to prevent accidental cross-thread access.
  • Isolated conformances for MainActor types: Shows how MainActor-isolated types can conform to non-isolated protocols safely, including why nonisolated contexts cannot use those conformances.
  • Explicit background offloading with @concurrent: Explains when and how to introduce real parallelism by marking functions with @concurrent and requiring await at call sites.
  • MainActor default inference mode: Provides an approach to reduce boilerplate by allowing MainActor inference for app targets and executable code paths.

Quick Start

Activate the swift-concurrency-6-2 Skill and ask it to propose a Swift 6.2-safe refactor for your specific data-race error in a @MainActor type by identifying where implicit offloading used to occur and what to change using isolated conformances or @concurrent.

Frequently Asked Questions about swift-concurrency-6-2

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

FAQPage Schema
Why does my Swift 6.2 migration trigger data race safety errors in MainActor types?

Swift 6.2 migration triggers data race safety errors because implicit background offloading and ambiguous actor isolation cause accidental cross-thread access. You can resolve this by adopting single-threaded default behavior and isolated conformances for MainActor types.

How do I conform a MainActor-isolated type to a non-isolated protocol safely in Swift 6.2?

To conform a MainActor-isolated type to a non-isolated protocol safely, use isolated conformances in Swift 6.2. This explicitly defines isolation boundaries so nonisolated contexts cannot incorrectly access those conformances and trigger data races.

When should I use @concurrent for explicit background offloading in Swift?

Use @concurrent in Swift 6.2 when you need real parallelism for CPU-intensive work. Marking functions with @concurrent deliberately offloads execution to the background, requiring await at call sites to maintain correct async behavior and prevent data races.

Does Swift 6.2 keep async work on the calling actor by default?

Yes, Swift 6.2 keeps async work on the calling actor by default. This single-threaded default behavior prevents accidental cross-thread access and implicit background offloading, ensuring data race safety during migration without explicit annotations.

What is MainActor default inference mode and how does it reduce boilerplate?

MainActor default inference mode allows MainActor inference for app targets and executable code paths in Swift 6.2. This approach reduces boilerplate by automatically applying MainActor isolation, reducing the need for explicit annotations while maintaining safe concurrency.