swift-concurrency-expert
Install this skill
npx skills add dimillian/skillsWorks across Claude Code, Cursor, Codex, Copilot & Antigravity
The Swift Concurrency Expert skill provides precise remediation for concurrency diagnostic errors found in Swift 6.2+ projects. It focuses on resolving isolation violations, data races, and Sendable conformance issues. By auditing actor contexts, the skill identifies whether code belongs on the MainActor or requires independent actor protection. It prioritizes non-intrusive refactoring that maintains existing runtime performance while satisfying the strict demands of the Swift compiler. The skill understands nuances such as approachable concurrency settings and protocol conformance isolation, ensuring that developers can migrate legacy codebases to modern asynchronous standards without introducing regressions. It serves as an automated auditor for thread safety, transforming complex compiler diagnostics into actionable, code-level updates that align with the latest Apple memory safety standards.
When to Use This Skill
- β’Fixing 'non-sendable' warnings occurring during cross-actor task passing
- β’Eliminating runtime warnings about MainActor isolation in UIKit or SwiftUI views
- β’Securing global variables against concurrent access
- β’Updating legacy callback-based networking layers to modern async/await
How to Invoke This Skill
Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:
- βFix Swift concurrency data race errors
- βResolve Sendable warnings in my project
- βAdd appropriate actor isolation to these view models
- βConvert this completion handler to async/await correctly
- βWhy is my variable not main actor isolated?
Pro Tips
- π‘Always provide the exact compiler error messages and line numbers for the most precise fixes.
- π‘Clearly indicate whether the code is part of a UI-bound component (e.g., `UIView`, `UIViewController`) or background processing.
- π‘Mention your project's Swift language version and strict concurrency checking level for tailored advice.
What this skill does
- β’Refactor shared mutable state into isolated actors
- β’Resolve Sendable conformance errors for custom types
- β’Apply correct MainActor annotations to UI-bound codebases
- β’Fix isolation mismatches in protocol extensions
- β’Migrate legacy completion handlers to structured async patterns
When not to use it
- βProjects using Swift versions earlier than 6.0
- βWhen rewriting code to use third-party reactive frameworks like RxSwift
Example workflow
- Scan project logs for Swift compiler diagnostic errors
- Determine the project's concurrency strictness level settings
- Identify types requiring Sendable conformance or actor protection
- Apply minimal code edits to annotate types or isolate functions
- Verify build stability under strict concurrency compiler flags
Prerequisites
- βSwift 6.2 or later compiler environment
- βAccess to project compiler logs
Pitfalls & limitations
- !Over-reliance on @unchecked Sendable can mask actual data races
- !Moving code to MainActor can create main thread bottlenecks if used excessively
- !Incorrectly nesting tasks can lead to unexpected execution orderings
FAQ
How it compares
Generic LLM prompts often suggest broad code changes that introduce regressions; this skill focuses on surgical, compiler-compliant updates that preserve specific concurrency patterns.
π Full skill instructions β original source: dimillian/skills
## 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.
## Workflow
### 1. Triage the issue
- Capture the exact compiler diagnostics and the offending symbol(s).
- Check project concurrency settings: Swift language version (6.2+), strict concurrency level, and whether approachable concurrency (default actor isolation / main-actor-by-default) is enabled.
- 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.## Reference material
- See
references/swift-6-2-concurrency.md for Swift 6.2 changes, patterns, and examples.- See
references/approachable-concurrency.md when the project is opted into approachable concurrency mode.- See
references/swiftui-concurrency-tour-wwdc.md for SwiftUI-specific concurrency guidance.How to Use This Skill Unit
Option A: Project-Specific (Recommended)
- Click "Download" above
- In your project, create the directory:
.agent/skills/swift-concurrency-expert/ - Save the file as
SKILL.md - The agent will automatically discover the skill based on its description.
Option B: Global Installation (All Agents)
Save the file to these locations to make it available across all projects:
- Claude Code:
~/.claude/skills/dimillian/skills/swift-concurrency-expert/SKILL.md - Cursor:
~/.cursor/skills/dimillian/skills/swift-concurrency-expert/SKILL.md - Antigravity:
~/.gemini/antigravity/skills/dimillian/skills/swift-concurrency-expert/SKILL.md
π Install with CLI:npx skills add dimillian/skills