Back to Mobile Development

swift-concurrency-expert

SwiftConcurrencyActorsSendableAsync AwaitCode ReviewiOS DevelopmentRefactoring
⭐ 3.7kπŸ“„ MITπŸ•’ 2026-03-29Source β†—

Install this skill

npx skills add dimillian/skills

Works 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

  1. Scan project logs for Swift compiler diagnostic errors
  2. Determine the project's concurrency strictness level settings
  3. Identify types requiring Sendable conformance or actor protection
  4. Apply minimal code edits to annotate types or isolate functions
  5. 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

Should I use @unchecked Sendable to silence warnings?
Only use @unchecked Sendable if you can manually guarantee thread safety, as it tells the compiler to skip its safety checks.
How does this differ from just adding async to my functions?
Adding async without addressing data isolation and Sendable requirements will likely cause new compiler errors related to actor boundaries.
Can this skill handle SwiftUI specific issues?
Yes, it applies specific patterns for SwiftUI view updates and state management, ensuring lifecycle methods respect main actor isolation.

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.

Source & trust

⭐ 3.7k starsπŸ“„ MITπŸ•’ Updated 2026-03-29
πŸ“„ Full skill instructions β€” original source: dimillian/skills
# Swift 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.

## 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)

  1. Click "Download" above
  2. In your project, create the directory: .agent/skills/swift-concurrency-expert/
  3. Save the file as SKILL.md
  4. 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

Read the Master Guide: Mastering Agent Skills β†’

Recommended Rules

View more rules β†’

Recommended Workflows

View more workflows β†’

Recommended MCP Servers

View more MCP servers β†’

Take It Further

Maximize your productivity with these powerful resources

πŸ“‹

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
πŸ“–

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide

How to use this Skill in Claude Code & Cursor

For Claude Code (CLI)

To use this skill in Claude Code, copy the rule content into your project's custom instructions or follow our Add-Skill CLI guide. This ensures Claude follows your standards during every code generation.

For Cursor & Windsurf

For Cursor or Windsurf, individual skills are best used in the "Rules for AI" section. This specific unit helps the agent avoid mobile development issues, leading to cleaner, more efficient code.

Why the skill format matters: the standardized Agent Skills format lets your AI agent load detailed instructions only when they are relevant, keeping your prompt clean while improving results.

Source & attribution

This skill is categorized under Mobile Development and is published by Thomas Ricouard, maintained in dimillian/skills.

← Browse All Agent Skills
Sponsored AI assistant. Recommendations may be paid.