Swift concurrency expert

From mouadja02/skills · View interactive version

Swift concurrency expert is an AI agent skill from the GitHub repository mouadja02/skills. Reviews and fixes Swift concurrency: Swift 6 strict-concurrency compiler errors, Sendable conformance, actor isolation, @MainActor, and data-race safety. Use when migrating async code to Swift 6 or resolving concurrency diagnostics.

How to use this skill

Skill file

Swift Concurrency Expert

Attribution: Sourced from steipete/agent-scripts by Peter Steinberger. Originally created by @Dimillian from Dimillian/Skills (2025-12-31).

Overview

Review and fix Swift Concurrency issues in Swift 6.2+ codebases by applying actor isolation, Sendable safety, and modern concurrency patterns with minimal behavior changes.

When to Use

Workflow

1. Triage the issue

2. Apply the smallest safe fix

Prefer edits that preserve existing behavior while satisfying data-race safety.

Common fixes:

Key Patterns

@MainActor annotation

// UI-bound type
@MainActor
class ViewModel: ObservableObject {
    @Published var items: [Item] = []
}

// Protocol conformance
extension MyView: @MainActor SomeProtocol { ... }

Actor for shared mutable state

actor DataCache {
    private var cache: [String: Data] = [:]
    
    func store(_ data: Data, for key: String) {
        cache[key] = data
    }
    
    func retrieve(for key: String) -> Data? {
        cache[key]
    }
}

Sendable conformance

// Immutable value type - safe
struct Config: Sendable {
    let apiKey: String
    let baseURL: URL
}

// Only use @unchecked when you can manually guarantee thread safety
final class ThreadSafeCache: @unchecked Sendable {
    private let lock = NSLock()
    private var cache: [String: Any] = [:]
}

Diagnostic Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.