
Swift Concurrency Expert
FreeResolve Swift concurrency issues effectively and safely.
Free · Opens the source repo
What Swift Concurrency Expert does
The Swift Concurrency Expert skill is designed to assist developers in reviewing and fixing concurrency issues in Swift 6.2 and later codebases. It focuses on applying actor isolation, ensuring Sendable safety, and implementing modern concurrency patterns while maintaining the existing behavior of the code. This skill is particularly useful for developers who are transitioning their applications to adopt Swift's concurrency model or who are encountering compiler diagnostics related to concurrency.
The skill's workflow begins with triaging the specific concurrency issues present in the code. It involves capturing compiler diagnostics, checking project concurrency settings, and identifying the current actor context. By understanding the context and the nature of the code (whether UI-bound or background processing), the skill provides tailored recommendations for fixes that are both safe and minimal.
Once the issues are identified, the skill guides users through applying the smallest safe fixes. This includes annotating UI-bound types with @MainActor, ensuring protocol conformance is correctly isolated, and managing global or static state appropriately. The focus is on preserving existing functionality while ensuring compliance with Swift's concurrency model, which is crucial for avoiding data races and ensuring thread safety.
Finally, the skill emphasizes the importance of verifying fixes through rebuilding the project and running tests to catch any regressions. This iterative approach ensures that all concurrency diagnostics are resolved without introducing new warnings, making it an essential tool for developers working with Swift's concurrency features.
When to use it
Use this skill when you need to review Swift concurrency usage or resolve compiler diagnostics related to concurrency issues.
When not to use it
This skill may not be suitable for projects that do not use Swift 6.2 or later, or for those not implementing concurrency features.
What you can build with it
Fixing Actor Isolation Issues
When encountering actor isolation issues in your Swift code, this skill helps identify and apply the necessary annotations.
Resolving Sendable Violations
If your codebase has Sendable violations, the skill guides you through making the appropriate changes to ensure safety.
Migrating to Swift Concurrency
Use this skill when migrating existing code to adopt Swift's concurrency model, ensuring compliance with best practices.
How to install Swift Concurrency Expert
View source1. Install with the skills CLI
npx skills add davila7/claude-code-templates/swift-concurrency-expert --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by davila7Swift Concurrency Expert
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
- When the user asks to review Swift concurrency usage or fix compiler diagnostics.
- When you need guidance on actor isolation,
Sendable,@MainActor, or async migration.
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
@MainActoror move into an actor. - Background work: move expensive work into a
@concurrentasync function on anonisolatedtype or use anactorto guard mutable state. - Sendable errors: prefer immutable/value types; add
Sendableconformance only when correct; avoid@unchecked Sendableunless you can prove thread safety.
3. Verify the fix
- Rebuild and confirm all concurrency diagnostics are resolved with no new warnings introduced.
- Run the test suite to check for regressions — concurrency changes can introduce subtle runtime issues even when the build is clean.
- If the fix surfaces new warnings, treat each one as a fresh triage (return to step 1) and resolve iteratively until the build is clean and tests pass.
Examples
UI-bound type — adding @MainActor
// Before: data-race warning because ViewModel is accessed from the main thread
// but has no actor isolation
class ViewModel: ObservableObject {
@Published var title: String = ""
func load() { title = "Loaded" }
}
// After: annotate the whole type so all stored state and methods are
// automatically isolated to the main actor
@MainActor
class ViewModel: ObservableObject {
@Published var title: String = ""
func load() { title = "Loaded" }
}
Protocol conformance isolation
// Before: compiler error — SomeProtocol method is nonisolated but the
// conforming type is @MainActor
@MainActor
class Foo: SomeProtocol {
func protocolMethod() { /* accesses main-actor state */ }
}
// After: scope the conformance to @MainActor so the requirement is
// satisfied inside the correct isolation context
@MainActor
extension Foo: SomeProtocol {
func protocolMethod() { /* safely accesses main-actor state */ }
}
Background work with @concurrent
// Before: expensive computation blocks the main actor
@MainActor
func processData(_ input: [Int]) -> [Int] {
input.map { heavyTransform($0) } // runs on main thread
}
// After: hop off the main actor for the heavy work, then return the result
// The caller awaits the result and stays on its own actor
nonisolated func processData(_ input: [Int]) async -> [Int] {
await Task.detached(priority: .userInitiated) {
input.map { heavyTransform($0) }
}.value
}
// Or, using a @concurrent async function (Swift 6.2+):
@concurrent
func processData(_ input: [Int]) async -> [Int] {
input.map { heavyTransform($0) }
}
Reference material
- See
references/swift-6-2-concurrency.mdfor Swift 6.2 changes, patterns, and examples. - See
references/approachable-concurrency.mdwhen the project is opted into approachable concurrency mode. - See
references/swiftui-concurrency-tour-wwdc.mdfor SwiftUI-specific concurrency guidance.
Frequently asked questions about Swift Concurrency Expert
Similar skills
Quality Playbook Generator
Run comprehensive quality audits on any codebase.
PR Draft Summary
Automate PR summary generation for openai-agents-python.
Final Release Review
Streamline your release candidate audits with ease.
Unit Test Vue Pinia
Efficiently write and review unit tests for Vue 3 applications.
Slang Shader Expert
Optimize and integrate Slang shaders with ease.
Telemetry Standards
Ensure consistent event tracking in Supabase Studio.
