swift-concurrency-6-2 — ai-agents swift-concurrency-6-2, everything-claude-code, official, ai-agents, ide skills, anthropic, claude-code, developer-tools, Claude Code, Cursor, Windsurf

Verified
v1.0.0
GitHub

About this Skill

Ideal for iOS Development Agents requiring efficient concurrency management in Swift 6.2 projects Swift 6.2 Approachable Concurrency — single-threaded by default, @concurrent for explicit background offloading, isolated conformances for main actor types.

# Core Topics

affaan-m affaan-m
[60.6k]
[7501]
Updated: 3/5/2026

Agent Capability Analysis

The swift-concurrency-6-2 skill by affaan-m is an open-source official AI agent skill for Claude Code and other IDE workflows, helping agents execute tasks with better context, repeatability, and domain-specific guidance. Optimized for ai-agents, anthropic, claude-code.

Ideal Agent Persona

Ideal for iOS Development Agents requiring efficient concurrency management in Swift 6.2 projects

Core Value

Empowers agents to leverage Swift 6.2's approachable concurrency model, utilizing @concurrent for explicit background offloading and isolated conformances for main actor types, ensuring data-race safety without sacrificing performance, and seamlessly integrating with MainActor-based app architectures

Capabilities Granted for swift-concurrency-6-2

Migrating existing Swift projects to Swift 6.2
Resolving data-race safety compiler errors
Offloading CPU-intensive tasks to background threads
Implementing protocol conformances for concurrent operations

! Prerequisites & Limits

  • Requires Swift 6.2 or later
  • Limited to single-threaded execution by default
Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

swift-concurrency-6-2

Install swift-concurrency-6-2, an AI agent skill for AI agent workflows and automation. Works with Claude Code, Cursor, and Windsurf with one-command setup.

SKILL.md
Readonly

Swift 6.2 Approachable Concurrency

Patterns for adopting Swift 6.2's concurrency model where code runs single-threaded by default and concurrency is introduced explicitly. Eliminates common data-race errors without sacrificing performance.

When to Activate

  • Migrating Swift 5.x or 6.0/6.1 projects to Swift 6.2
  • Resolving data-race safety compiler errors
  • Designing MainActor-based app architecture
  • Offloading CPU-intensive work to background threads
  • Implementing protocol conformances on MainActor-isolated types
  • Enabling Approachable Concurrency build settings in Xcode 26

Core Problem: Implicit Background Offloading

In Swift 6.1 and earlier, async functions could be implicitly offloaded to background threads, causing data-race errors even in seemingly safe code:

swift
1// Swift 6.1: ERROR 2@MainActor 3final class StickerModel { 4 let photoProcessor = PhotoProcessor() 5 6 func extractSticker(_ item: PhotosPickerItem) async throws -> Sticker? { 7 guard let data = try await item.loadTransferable(type: Data.self) else { return nil } 8 9 // Error: Sending 'self.photoProcessor' risks causing data races 10 return await photoProcessor.extractSticker(data: data, with: item.itemIdentifier) 11 } 12}

Swift 6.2 fixes this: async functions stay on the calling actor by default.

swift
1// Swift 6.2: OK — async stays on MainActor, no data race 2@MainActor 3final class StickerModel { 4 let photoProcessor = PhotoProcessor() 5 6 func extractSticker(_ item: PhotosPickerItem) async throws -> Sticker? { 7 guard let data = try await item.loadTransferable(type: Data.self) else { return nil } 8 return await photoProcessor.extractSticker(data: data, with: item.itemIdentifier) 9 } 10}

Core Pattern — Isolated Conformances

MainActor types can now conform to non-isolated protocols safely:

swift
1protocol Exportable { 2 func export() 3} 4 5// Swift 6.1: ERROR — crosses into main actor-isolated code 6// Swift 6.2: OK with isolated conformance 7extension StickerModel: @MainActor Exportable { 8 func export() { 9 photoProcessor.exportAsPNG() 10 } 11}

The compiler ensures the conformance is only used on the main actor:

swift
1// OK — ImageExporter is also @MainActor 2@MainActor 3struct ImageExporter { 4 var items: [any Exportable] 5 6 mutating func add(_ item: StickerModel) { 7 items.append(item) // Safe: same actor isolation 8 } 9} 10 11// ERROR — nonisolated context can't use MainActor conformance 12nonisolated struct ImageExporter { 13 var items: [any Exportable] 14 15 mutating func add(_ item: StickerModel) { 16 items.append(item) // Error: Main actor-isolated conformance cannot be used here 17 } 18}

Core Pattern — Global and Static Variables

Protect global/static state with MainActor:

swift
1// Swift 6.1: ERROR — non-Sendable type may have shared mutable state 2final class StickerLibrary { 3 static let shared: StickerLibrary = .init() // Error 4} 5 6// Fix: Annotate with @MainActor 7@MainActor 8final class StickerLibrary { 9 static let shared: StickerLibrary = .init() // OK 10}

MainActor Default Inference Mode

Swift 6.2 introduces a mode where MainActor is inferred by default — no manual annotations needed:

swift
1// With MainActor default inference enabled: 2final class StickerLibrary { 3 static let shared: StickerLibrary = .init() // Implicitly @MainActor 4} 5 6final class StickerModel { 7 let photoProcessor: PhotoProcessor 8 var selection: [PhotosPickerItem] // Implicitly @MainActor 9} 10 11extension StickerModel: Exportable { // Implicitly @MainActor conformance 12 func export() { 13 photoProcessor.exportAsPNG() 14 } 15}

This mode is opt-in and recommended for apps, scripts, and other executable targets.

Core Pattern — @concurrent for Background Work

When you need actual parallelism, explicitly offload with @concurrent:

Important: This example requires Approachable Concurrency build settings — SE-0466 (MainActor default isolation) and SE-0461 (NonisolatedNonsendingByDefault). With these enabled, extractSticker stays on the caller's actor, making mutable state access safe. Without these settings, this code has a data race — the compiler will flag it.

swift
1nonisolated final class PhotoProcessor { 2 private var cachedStickers: [String: Sticker] = [:] 3 4 func extractSticker(data: Data, with id: String) async -> Sticker { 5 if let sticker = cachedStickers[id] { 6 return sticker 7 } 8 9 let sticker = await Self.extractSubject(from: data) 10 cachedStickers[id] = sticker 11 return sticker 12 } 13 14 // Offload expensive work to concurrent thread pool 15 @concurrent 16 static func extractSubject(from data: Data) async -> Sticker { /* ... */ } 17} 18 19// Callers must await 20let processor = PhotoProcessor() 21processedPhotos[item.id] = await processor.extractSticker(data: data, with: item.id)

To use @concurrent:

  1. Mark the containing type as nonisolated
  2. Add @concurrent to the function
  3. Add async if not already asynchronous
  4. Add await at call sites

Key Design Decisions

DecisionRationale
Single-threaded by defaultMost natural code is data-race free; concurrency is opt-in
Async stays on calling actorEliminates implicit offloading that caused data-race errors
Isolated conformancesMainActor types can conform to protocols without unsafe workarounds
@concurrent explicit opt-inBackground execution is a deliberate performance choice, not accidental
MainActor default inferenceReduces boilerplate @MainActor annotations for app targets
Opt-in adoptionNon-breaking migration path — enable features incrementally

Migration Steps

  1. Enable in Xcode: Swift Compiler > Concurrency section in Build Settings
  2. Enable in SPM: Use SwiftSettings API in package manifest
  3. Use migration tooling: Automatic code changes via swift.org/migration
  4. Start with MainActor defaults: Enable inference mode for app targets
  5. Add @concurrent where needed: Profile first, then offload hot paths
  6. Test thoroughly: Data-race issues become compile-time errors

Best Practices

  • Start on MainActor — write single-threaded code first, optimize later
  • Use @concurrent only for CPU-intensive work — image processing, compression, complex computation
  • Enable MainActor inference mode for app targets that are mostly single-threaded
  • Profile before offloading — use Instruments to find actual bottlenecks
  • Protect globals with MainActor — global/static mutable state needs actor isolation
  • Use isolated conformances instead of nonisolated workarounds or @Sendable wrappers
  • Migrate incrementally — enable features one at a time in build settings

Anti-Patterns to Avoid

  • Applying @concurrent to every async function (most don't need background execution)
  • Using nonisolated to suppress compiler errors without understanding isolation
  • Keeping legacy DispatchQueue patterns when actors provide the same safety
  • Skipping model.availability checks in concurrency-related Foundation Models code
  • Fighting the compiler — if it reports a data race, the code has a real concurrency issue
  • Assuming all async code runs in the background (Swift 6.2 default: stays on calling actor)

When to Use

  • All new Swift 6.2+ projects (Approachable Concurrency is the recommended default)
  • Migrating existing apps from Swift 5.x or 6.0/6.1 concurrency
  • Resolving data-race safety compiler errors during Xcode 26 adoption
  • Building MainActor-centric app architectures (most UI apps)
  • Performance optimization — offloading specific heavy computations to background

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is swift-concurrency-6-2?

Ideal for iOS Development Agents requiring efficient concurrency management in Swift 6.2 projects Swift 6.2 Approachable Concurrency — single-threaded by default, @concurrent for explicit background offloading, isolated conformances for main actor types.

How do I install swift-concurrency-6-2?

Run the command: npx killer-skills add affaan-m/everything-claude-code/swift-concurrency-6-2. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for swift-concurrency-6-2?

Key use cases include: Migrating existing Swift projects to Swift 6.2, Resolving data-race safety compiler errors, Offloading CPU-intensive tasks to background threads, Implementing protocol conformances for concurrent operations.

Which IDEs are compatible with swift-concurrency-6-2?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for swift-concurrency-6-2?

Requires Swift 6.2 or later. Limited to single-threaded execution by default.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add affaan-m/everything-claude-code/swift-concurrency-6-2. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use swift-concurrency-6-2 immediately in the current project.

Related Skills

Looking for an alternative to swift-concurrency-6-2 or another official skill for your workflow? Explore these related open-source skills.

View All

flags

Logo of facebook
facebook

Use when you need to check feature flag states, compare channels, or debug why a feature behaves differently across release channels.

243.6k
0
Developer

extract-errors

Logo of facebook
facebook

Use when adding new error messages to React, or seeing unknown error code warnings.

243.6k
0
Developer

fix

Logo of facebook
facebook

Use when you have lint errors, formatting issues, or before committing code to ensure it passes CI.

243.6k
0
Developer

flow

Logo of facebook
facebook

Use when you need to run Flow type checking, or when seeing Flow type errors in React code.

243.6k
0
Developer