Skip to content
Back to skills

Swift Concurrency Expert

ASecurity

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.

  • 14 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 10, 2026
ai-agentsswiftgitapi

Works with

  • api

Security analysis

A100/100

Scanned November 10, 2026

npx -y skills add mouadja02/skills --skill swift-concurrency-expert --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Swift Concurrency Expert?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Swift Concurrency Expert
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mouadja02-swift-concurrency-expert/badge)](https://www.skillsdirectory.com/skills/mouadja02-swift-concurrency-expert)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: swift-concurrency-expert
description: >-
  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.
source: "https://github.com/steipete/agent-scripts"
attribution: "steipete/agent-scripts by Peter Steinberger — originally by @Dimillian (Dimillian/Skills)"
version: "1.0.0"
platform: apple
license: MIT
---

# Swift Concurrency Expert

> **Attribution:** Sourced from [steipete/agent-scripts](https://github.com/steipete/agent-scripts) by [Peter Steinberger](https://github.com/steipete). Originally created by [@Dimillian](https://github.com/Dimillian) from [Dimillian/Skills](https://github.com/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

- Fixing Swift 6 strict concurrency compiler errors
- Reviewing Sendable conformance, actor isolation, and data race safety
- Migrating pre-Swift 6 async code to strict concurrency
- Choosing between actors, `@MainActor`, `nonisolated`, and `@Sendable`

## Workflow

### 1. Triage the issue

- Capture the exact compiler diagnostics and the offending symbol(s).
- Identify the current actor context (`@MainActor`, `actor`, `nonisolated`) and whether a default actor isolation mode is enabled.
- Confirm whether the code is UI-bound or intended to run off the main actor.

### 2. Apply the smallest safe fix

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

Common fixes:
- **UI-bound types**: annotate the type or relevant members with `@MainActor`.
- **Protocol conformance on main actor types**: make the conformance isolated (e.g., `extension Foo: @MainActor SomeProtocol`).
- **Global/static state**: protect with `@MainActor` or move into an actor.
- **Background work**: move expensive work into a `@concurrent` async function on a `nonisolated` type or use an `actor` to guard mutable state.
- **Sendable errors**: prefer immutable/value types; add `Sendable` conformance only when correct; avoid `@unchecked Sendable` unless you can prove thread safety.

## Key Patterns

### @MainActor annotation

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

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

### Actor for shared mutable state

```swift
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

```swift
// 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

- [ ] Compiler diagnostic captured exactly
- [ ] Actor context identified (`@MainActor`, `actor`, `nonisolated`, implicit)
- [ ] Fix preserves existing behavior
- [ ] No `@unchecked Sendable` without proven thread safety
- [ ] No unnecessary `await` or `Task { }` wrappers added

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.