swift-concurrency-6-2
A Claude Code skill from Affaan M's everything-claude-code repo for adopting Swift 6.2's Approachable Concurrency model — single-threaded by default, async stays on the calling actor, @concurrent for explicit background offloading, isolated conformances let MainActor types conform to non-isolated protocols safely. Covers Xcode 26 build settings and migration from 6.0 / 6.1.
Migrate Swift code to 6.2 Approachable Concurrency without losing data-race safety or hand-tuning isolation
Trigger phrases
Phrases that activate this skill when typed to Claude Code:
migrate to Swift 6.2 concurrencyfix Sending data race errorisolated conformance for MainActor type
What it does
swift-concurrency-6-2 is the Swift 6.2 concurrency migration skill in Affaan M’s everything-claude-code — see skills/swift-concurrency-6-2. Swift 6.2 introduces Approachable Concurrency: code runs single-threaded by default, concurrency is introduced explicitly via @concurrent, and the “implicit background offloading” data races that plagued 6.0 / 6.1 go away.
The pre-6.2 problem the skill names directly: an async function on a @MainActor type could be implicitly offloaded to a background thread, producing Sending 'self.photoProcessor' risks causing data races even in seemingly safe code. Swift 6.2 fixes this — async stays on the calling actor by default. The migration is often as simple as recompiling, but the skill ships the patterns for the non-trivial cases.
Isolated conformances are the second wedge. Pre-6.2, a @MainActor type couldn’t conform to a plain Sendable-aware protocol without crossing into main-actor-isolated code. 6.2 allows extension StickerModel: @MainActor Exportable {} — the conformance is statically restricted to the main actor and the compiler enforces it. Non-isolated contexts can’t use the conformance, which surfaces architectural mistakes at compile time. The skill also covers global / static state protection (@MainActor on the variable), explicit @concurrent offloading for CPU-intensive work, and Xcode 26’s Approachable Concurrency build setting.
When to use it
- Migrating a Swift 5.x or 6.0 / 6.1 codebase to 6.2 — the data-race errors fall into a few canonical patterns
- Resolving
Sending 'self.x' risks causing data racescompiler errors on@MainActortypes - Designing MainActor-based app architecture where most code runs on main and only specific paths offload to background
- Offloading CPU-intensive work to background threads explicitly via
@concurrent - Implementing protocol conformances on
@MainActor-isolated types (isolated conformances) - Enabling Approachable Concurrency build settings in Xcode 26
When not to reach for it:
- Swift Server-side code that’s already structured-concurrency-native — the migration patterns are mostly Apple-platform-shaped
- Pre-Swift-6 codebases — the skill assumes Swift 6 strict concurrency is in scope
- SwiftUI composition patterns specifically — that’s
swiftui-patterns - Liquid Glass material work — that’s
liquid-glass-design
Install
From affaan-m/everything-claude-code at skills/swift-concurrency-6-2/. Drop the folder into ~/.claude/skills/swift-concurrency-6-2/. The skill is markdown patterns; the runtime is Xcode 26+ with the Swift 6.2 toolchain and the Approachable Concurrency build setting enabled.
What a session looks like
- Open the diagnostic. Compiler error reads
Sending 'self.photoProcessor' risks causing data races. Skill picks the implicit-background-offload pattern. - Verify the actor isolation.
StickerModelis@MainActor. The async call tophotoProcessor.extractSticker(...)was being offloaded in 6.1 — 6.2 keeps it on the main actor. - Confirm the migration is a no-op for this case. Many 6.1 errors disappear under 6.2 without code changes. The skill is explicit that this is often the path.
- Add an isolated conformance.
StickerModelneeds to conform toExportable.extension StickerModel: @MainActor Exportable {}lets the conformance exist while statically restricting use to the main actor. - Verify caller contexts. Using the conformance from a
@MainActorImageExporteris OK. Using it from anonisolatedcontext produces a compile error — the type system catches the mistake. - Add
@concurrentwhere actual background work is needed. CPU-heavy image processing gets explicit offloading rather than the implicit kind 6.1 inflicted. - Enable the build setting. Xcode 26 Approachable Concurrency on for the target.
The discipline that makes it work: trust the compiler. 6.2’s wedge is that the type system catches isolation mistakes that 6.1 would silently miscompile or produce data races for at runtime. The migration pattern is usually “let it compile, fix what fails.”
Receipts
TODO — to be filled in from a real session. Once a real Swift project has been migrated to 6.2, this section will capture: how many of the 6.1 Sending errors disappeared on recompile without code changes vs. how many needed actual isolation work, which patterns required @MainActor Exportable-style isolated conformances vs. which restructured to a different shape entirely, whether any 6.1 code that compiled cleanly broke under 6.2’s stricter rules, and the wall-time cost of the migration vs. the operator’s estimate.
Source and attribution
From Affaan M’s everything-claude-code — an MIT-licensed skill collection covering harness construction, agent ops, video, payments, and platform-specific patterns.
License: MIT.