Agent skill

Swift Concurrency

by jamesrochabrun in jamesrochabrun/skills

Guide for building, auditing, and refactoring Swift code using modern concurrency patterns (Swift 6+).

MITAuto-check passedDevelopment

Install Swift Concurrency

skills CLI
$ npx skills add jamesrochabrun/skills --skill swift-concurrency -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jamesrochabrun/skills swift-concurrency --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jamesrochabrun/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/swift-concurrency .claude/skills/swift-concurrency && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
swift-concurrency
GitHub stars
216
Token cost
~1.9k tokens
SKILL.md length
429 words
Files
6 (incl. references)
Skills in repo
23
Repo updated
First seen
Licence
MIT

At a glance

Guide for building, auditing, and refactoring Swift code using modern concurrency patterns (Swift 6+).

  • Works in 4 steps: Determine Isolation Needs → Design Async Functions → Handle Parallel Work → …
  • Tasks that involve Async programming
  • SKILL.md covers Overview, Workflow Decision Tree, Building Workflow and Auditing Checklist, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Swift Concurrency is an agent skill from jamesrochabrun/skills. Guide for building, auditing, and refactoring Swift code using modern concurrency patterns (Swift 6+). This skill should be used when working with async/await, Tasks, actors, MainActor, Sendable types, isolation domains, or when migrating legacy callback/Combine code to structured concurrency. Covers Approachable Concurrency settings, isolated parameters, and common pitfalls.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including reference files (for example `references/common-mistakes.md`, `references/fundamentals.md` and `references/glossary.md`).

It sits in Development, covering Async programming, iOS development and Refactoring. It works with Swift and SwiftUI. The licence is MIT.

When your agent uses it

  • Tasks that involve Async programming
  • Tasks that involve iOS development
  • Tasks that involve Refactoring

Example prompts

  • “/swift-concurrency”

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Determine Isolation Needs
  2. Design Async Functions
  3. Handle Parallel Work
  4. SwiftUI Integration

What it can do on your machine

Read from SKILL.md and the folder at commit 2482c17. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are swift).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Swift Concurrency loads about 1.9k tokens when it runs, and up to ~9.9k if it reads all its reference files. Until then it costs about 99 tokens; SKILL.md has 429 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~99
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~9.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jamesrochabrun/skills at commit 2482c17, republished under its MIT licence (© jamesrochabrun). 429 words, ~1,934 tokens.

Download SKILL.mdSave it as .claude/skills/swift-concurrency/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
swift-concurrency
description
Guide for building, auditing, and refactoring Swift code using modern concurrency patterns (Swift 6+). This skill should be used when working with async/await, Tasks, actors, MainActor, Sendable types, isolation domains, or when migrating legacy callback/Combine code to structured concurrency. Covers Approachable Concurrency settings, isolated parameters, and common pitfalls.

Swift Concurrency

Overview

This skill provides guidance for writing thread-safe Swift code using modern concurrency patterns. It covers three main workflows: building new async code, auditing existing code for issues, and refactoring legacy patterns to Swift 6+.

Core principle: Isolation is inherited by default. With Approachable Concurrency, code starts on MainActor and propagates through the program automatically. Opt out explicitly when needed.

Workflow Decision Tree

What are you doing?
│
├─► BUILDING new async code
│   └─► See "Building Workflow" below
│
├─► AUDITING existing code
│   └─► See "Auditing Checklist" below
│
└─► REFACTORING legacy code
    └─► See "Refactoring Workflow" below

Building Workflow

When writing new async code, follow this decision process:

Step 1: Determine Isolation Needs
Does this type manage UI state or interact with UI?
│
├─► YES → Mark with @MainActor
│
└─► NO → Does it have mutable state shared across contexts?
         │
         ├─► YES → Consider: Can it live on MainActor anyway?
         │         │
         │         ├─► YES → Use @MainActor (simpler)
         │         │
         │         └─► NO → Use a custom actor (requires justification)
         │
         └─► NO → Leave non-isolated (default with Approachable Concurrency)
Step 2: Design Async Functions
swift
// PREFER: Inherit caller's isolation (works everywhere)
func fetchData(isolation: isolated (any Actor)? = #isolation) async throws -> Data {
  // Runs on whatever actor the caller is on
}

// USE WHEN: CPU-intensive work that must run in background
@concurrent
func processLargeFile() async -> Result { }

// AVOID: Non-isolated async without explicit choice
func ambiguousAsync() async { } // Where does this run?
Step 3: Handle Parallel Work
swift
// For known number of independent operations
async let avatar = fetchImage("avatar.jpg")
async let banner = fetchImage("banner.jpg")
let (a, b) = await (avatar, banner)

// For dynamic number of operations
try await withThrowingTaskGroup(of: Void.self) { group in
  for id in userIDs {
    group.addTask { try await fetchUser(id) }
  }
  try await group.waitForAll()
}
Step 4: SwiftUI Integration
swift
struct ProfileView: View {
  @State private var avatar: Image?

  var body: some View {
    avatar
      .task { avatar = await downloadAvatar() }  // Auto-cancels on disappear
      .task(id: userID) { /* Reloads when userID changes */ }
  }
}

// For user actions
Button("Save") {
  Task { await saveProfile() }  // Inherits MainActor isolation
}

Auditing Checklist

When reviewing Swift concurrency code, check for these issues:

Critical Issues (Must Fix)
  • Blocking the cooperative pool: Look for DispatchSemaphore.wait(), DispatchGroup.wait(), or similar blocking calls inside async contexts
  • Data races: Non-Sendable types crossing isolation boundaries without proper handling
  • Non-isolated async in non-Sendable types: These only work from non-isolated contexts
Common Issues (Should Fix)
  • Actor overuse: Custom actors without justification (see "Actor Justification Test" in references)
  • Unnecessary MainActor.run: Should usually be @MainActor on the function instead
  • Thinking async = background: Synchronous CPU work inside async functions still blocks
  • Unstructured Tasks where structured works: Task { } instead of async let or TaskGroup
  • Missing cancellation handling: Long operations should check Task.isCancelled
SwiftUI-Specific
  • Views not MainActor-isolated: SwiftUI views should be @MainActor (or use @Observable)
  • Accessing @State from detached tasks: Must hop back to MainActor
Sendable Compliance
  • @unchecked Sendable overuse: Should be rare and justified
  • Making everything Sendable: Not all types need to cross boundaries
  • Non-Sendable closures escaping: Check closure captures

Refactoring Workflow

From Callbacks to async/await
swift
// BEFORE: Callback-based
func fetchUser(id: Int, completion: @escaping (Result<User, Error>) -> Void) {
  URLSession.shared.dataTask(with: url) { data, _, error in
    if let error { completion(.failure(error)); return }
    // ...
  }.resume()
}

// AFTER: async/await with continuation
func fetchUser(id: Int) async throws -> User {
  try await withCheckedThrowingContinuation { continuation in
    fetchUser(id: id) { result in
      continuation.resume(with: result)
    }
  }
}
Show full SKILL.md (172 more words)Show less
From DispatchQueue to Actors
swift
// BEFORE: Queue-based protection
class BankAccount {
  private let queue = DispatchQueue(label: "account")
  private var _balance: Double = 0

  var balance: Double {
    queue.sync { _balance }
  }

  func deposit(_ amount: Double) {
    queue.async { self._balance += amount }
  }
}

// AFTER: Actor (if truly needs own isolation)
actor BankAccount {
  var balance: Double = 0

  func deposit(_ amount: Double) {
    balance += amount
  }
}

// BETTER: MainActor class (if doesn't need concurrent access)
@MainActor
class BankAccount {
  var balance: Double = 0

  func deposit(_ amount: Double) {
    balance += amount
  }
}
From Combine to AsyncSequence
swift
// BEFORE: Combine publisher
cancellable = NotificationCenter.default
  .publisher(for: .userDidLogin)
  .sink { notification in /* ... */ }

// AFTER: AsyncSequence
for await _ in NotificationCenter.default.notifications(named: .userDidLogin) {
  // Handle notification
}

Quick Reference

KeywordPurpose
asyncFunction can suspend
awaitSuspension point
Task { }Start async work, inherits isolation
Task.detached { }Start async work, no inheritance
@MainActorRuns on main thread
actorType with isolated mutable state
nonisolatedOpts out of actor isolation
nonisolated(nonsending)Inherits caller's isolation
@concurrentAlways run on background (Swift 6.2+)
SendableSafe to cross isolation boundaries
sendingOne-way transfer of non-Sendable
async letStart parallel work
TaskGroupDynamic parallel work

Approachable Concurrency Settings (Swift 6.2+)

For new Xcode 26+ projects, these are enabled by default:

SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor
SWIFT_APPROACHABLE_CONCURRENCY = YES

Effects:

  • Everything runs on MainActor unless explicitly marked otherwise
  • nonisolated async functions stay on caller's actor instead of hopping to background
  • Sendable errors become much rarer

Resources

For detailed technical reference, consult:

  • references/fundamentals.md - async/await, Tasks, structured concurrency
  • references/isolation.md - Actors, MainActor, isolation domains, inheritance
  • references/sendable.md - Sendable protocol, non-Sendable patterns, isolated parameters
  • references/common-mistakes.md - Detailed examples of what to avoid
  • references/glossary.md - Complete terminology reference

Search patterns for references:

  • Isolation: grep -i "isolation\|actor\|mainactor\|nonisolated"
  • Sendable: grep -i "sendable\|sending\|boundary"
  • Tasks: grep -i "task\|taskgroup\|async let\|structured"

© jamesrochabrun, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (references) in skills/swift-concurrency of jamesrochabrun/skills.

  • SKILL.md
  • references/common-mistakes.md
  • references/fundamentals.md
  • references/glossary.md
  • references/isolation.md
  • references/sendable.md

Open the folder on GitHubat commit 2482c17

Compare with similar skills

Swift Concurrency next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Swift Concurrency compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Swift Concurrency this skilljamesrochabrun/skills216—~1.9kAutomated safety check: PassMIT
Swift Refactorpproenca/dot-skills215—~3kAutomated safety check: PassMIT
Swift Datapproenca/dot-skills215—~3.4kAutomated safety check: PassMIT
Swift Concurrencyhenrypldev/react-native-nitro-mlx1003 repos~3.1kAutomated safety check: PassMIT
Swift Concurrencynimblehq/ios-templates110—~1.7kAutomated safety check: PassMIT
cmux Swift Package Architecturemanaflow-ai/cmux28k1 repos~4.2kAutomated safety check: PassCustom licence

Similar skills

  • Swift Refactor

    pproenca/dot-skills

    Swift and SwiftUI refactoring patterns aligned with the iOS 26 / Swift 6.2 clinic modular MVVM-C architecture (Airbnb + OLX SPM layout).

    215 GitHub stars~3k tokensUpdated 1 mo ago
    MobileAuto-check passed
  • Swift Data

    pproenca/dot-skills

    SwiftData persistence and data-layer architecture for iOS 26 / Swift 6.2 clinic modular MVVM-C apps.

    215 GitHub stars~3.4k tokensUpdated 1 mo ago
    MobileAuto-check passed
  • Swift Concurrency

    henrypldev/react-native-nitro-mlx

    Diagnose Swift Concurrency issues, refactor callback-based code to async/await, and guide Swift 6 migration when working with tasks, actors, @MainActor, Sendable, data races, thread safety, or…

    100 GitHub starsUsed in 3 repos~3.1k tokens
    DevelopmentAuto-check passed
  • Swift Concurrency

    nimblehq/ios-templates

    Write, review, or fix Swift 6 concurrency code using actors, Sendable, structured concurrency, and the strict data-race-safety model.

    110 GitHub stars~1.7k tokensUpdated 2 mo ago
    DevelopmentAuto-check passed
  • Architecture rules for cmux's move to Swift Packages: acyclic whole-domain packages, minimal public API, group folders, Xcode project wiring and Swift 6 concurrency.

    28k GitHub starsUsed in 1 repo~4.2k tokens
    DevelopmentAuto-check passed
  • Concurrency Patterns

    gustavscirulis/snapgrid

    Swift concurrency patterns including Swift 6.2 approachable concurrency, structured concurrency, actors, continuations, and migration.

    117 GitHub starsUsed in 1 repo~1.2k tokens
    DevelopmentAuto-check passed

More from jamesrochabrun/skills

All 23 skills in this repo
  • Prd Generator

    jamesrochabrun/skills

    Generate comprehensive Product Requirements Documents (PRDs) for product managers.

    216 GitHub starsUsed in 2 repos~3.8k tokens
    Auto-check passed
  • Technical Launch Planner

    jamesrochabrun/skills

    Plan and execute technical product launches for developer tools, APIs, and technical products.

    216 GitHub starsUsed in 1 repo~3.8k tokens
    Auto-check passed
  • Design Brief Generator

    jamesrochabrun/skills

    Generate comprehensive design briefs for design projects. An agent skill from jamesrochabrun/skills.

    216 GitHub stars~3.3k tokensUpdated 8 mo ago
    Auto-check passed
  • Git Worktrees

    jamesrochabrun/skills

    Manage Git worktrees for parallel Claude Code development. An agent skill from jamesrochabrun/skills.

    216 GitHub stars~4.2k tokensUpdated 8 mo ago
    Auto-check passed
  • Content Brief Generator

    jamesrochabrun/skills

    Generate comprehensive content briefs for writers, ensuring clarity, alignment, and strategic content creation across all formats.

    216 GitHub starsUsed in 1 repo~2.9k tokens
    Auto-check passed
  • LLM Router

    jamesrochabrun/skills

    This skill should be used when users want to route LLM requests to different AI providers (OpenAI, Grok/xAI, Groq, DeepSeek, OpenRouter) using SwiftOpenAI-CLI.

    216 GitHub stars~3.3k tokensUpdated 8 mo ago
    Auto-check passed

Works with

Questions about Swift Concurrency

What does Swift Concurrency do?

Guide for building, auditing, and refactoring Swift code using modern concurrency patterns (Swift 6+). Swift Concurrency is an agent skill from jamesrochabrun/skills. Guide for building, auditing, and refactoring Swift code using modern concurrency patterns (Swift 6+).

When should I use Swift Concurrency?

Swift Concurrency fits situations like: tasks that involve Async programming; tasks that involve iOS development; tasks that involve Refactoring.

How do I install Swift Concurrency in Claude Code?

Run `npx skills add jamesrochabrun/skills --skill swift-concurrency -a claude-code`. Or copy the skill folder (skills/swift-concurrency in jamesrochabrun/skills) into .claude/skills/swift-concurrency in your project. Claude Code loads it when a task matches its description.

How do I install Swift Concurrency in Codex?

Run `npx skills add jamesrochabrun/skills --skill swift-concurrency -a codex`. Or copy the skill folder (skills/swift-concurrency in jamesrochabrun/skills) into .agents/skills/swift-concurrency in your project. Codex loads it when a task matches its description.

Can I use Swift Concurrency in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jamesrochabrun/skills --skill swift-concurrency -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/swift-concurrency, .gemini/skills/swift-concurrency, .github/skills/swift-concurrency and .opencode/skills/swift-concurrency in your project.

What does Swift Concurrency need to run?

SKILL.md names no scripts, command-line tools or credentials: Swift Concurrency is instructions for the agent only.

Does Swift Concurrency access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Swift Concurrency safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Swift Concurrency use?

Swift Concurrency is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Swift Concurrency use?

About 1.9k tokens (SKILL.md is roughly 7.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 8k tokens, read only when the agent opens those files.

What are the alternatives to Swift Concurrency?

Skills that share tags, products or a category with Swift Concurrency: Swift Refactor (pproenca/dot-skills, 215 stars), Swift Data (pproenca/dot-skills, 215 stars), Swift Concurrency (henrypldev/react-native-nitro-mlx, 100 stars) and Swift Concurrency (nimblehq/ios-templates, 110 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Swift Concurrency?

jamesrochabrun (a GitHub user) maintains it in jamesrochabrun/skills, which has 216 GitHub stars. The repository holds 23 skills in this directory. The repository was last updated on January 14, 2026.

Source: jamesrochabrun/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.