Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

swift-concurrency

БесплатноБез исполняемых скриптовНе проверен

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

AvdLeeот AvdLee★ 1 740 звёзд на GitHub

Об этом скилле

Swift Concurrency

Fast Path

Before proposing a fix:

  1. Analyze Package.swift or .pbxproj to determine Swift language mode, strict concurrency level, default isolation, and upcoming features. Do this always, not only for migration work.
  2. Capture the exact diagnostic and offending symbol.
  3. Determine the isolation boundary: @MainActor, custom actor, actor instance isolation, or nonisolated.
  4. Confirm whether the code is UI-bound or intended to run off the main actor. When spawning unstructured tasks, inspect the synchronous prefix (everything before the first await): start on @MainActor only when that prefix truly needs main-actor access; otherwise use Task { @concurrent in ... } and hop back with MainActor.run only after the suspension. A trivial non-main line (for example, print) followed by main-actor work in the same prefix is not a reason to use @concurrent. For delayed retries, timers, and backoff tasks, separate the waiting from the UI mutation. The sleep often belongs off the main actor even when the final state update belongs on it.

Project settings that change concurrency behavior:

Setting SwiftPM (Package.swift) Xcode (.pbxproj)
Language mode swiftLanguageVersions or -swift-version (// swift-tools-version: is not a reliable proxy) Swift Language Version
Strict concurrency .enableExperimentalFeature("StrictConcurrency=targeted") SWIFT_STRICT_CONCURRENCY
Default isolation .defaultIsolation(MainActor.self) SWIFT_DEFAULT_ACTOR_ISOLATION
Upcoming features .enableUpcomingFeature("NonisolatedNonsendingByDefault") SWIFT_UPCOMING_FEATURE_*
Approachable Concurrency N/A (use individual upcoming features) SWIFT_APPROACHABLE_CONCURRENCY

Xcode 26 note: New projects created in Xcode 26 will often start with SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor and SWIFT_APPROACHABLE_CONCURRENCY = YES enabled by default. Treat these as likely defaults for newly created projects, not as confirmed settings.

If any of these are unknown, ask the developer to confirm them before giving migration-sensitive guidance. Do not guess, even for new Xcode 26 projects.

Guardrails:

  • Do not recommend @MainActor as a blanket fix. Justify why the code is truly UI-bound.
  • Prefer structured concurrency over unstructured tasks. Use Task.detached only with a clear reason.
  • If recommending @preconcurrency, @unchecked Sendable, or nonisolated(unsafe), require a documented safety invariant and a follow-up removal plan.
  • Optimize for the smallest safe change. Do not refactor unrelated architecture during migration.
  • Course references are for deeper learning only. Use them sparingly and only when they clearly help answer the developer's question.

Quick Fix Mode

Use Quick Fix Mode when all of these are true:

  • The issue is localized to one file or one type.
  • The isolation boundary is clear.
  • The fix can be explained in 1-2 behavior-preserving steps.

Skip Quick Fix Mode when any of these are true:

  • Build settings or default isolation are unknown.
  • The issue crosses module boundaries or changes public API behavior.
  • The likely fix depends on unsafe escape hatches.

Common Diagnostics

Diagnostic First check Smallest safe fix Escalate to
Main actor-isolated ... cannot be used from a nonisolated context Is this truly UI-bound? Isolate the caller to @MainActor or use await MainActor.run { ... } only when main-actor ownership is correct. references/actors.md, references/threading.md
Actor-isolated type does not conform to protocol Must the requirement run on the actor? Prefer isolated conformance (e.g., extension Foo: @MainActor SomeProtocol); use nonisolated only for truly nonisolated requirements. references/actors.md
Sending value of non-Sendable type ... risks causing data races What isolation boundary is being crossed? Keep access inside one actor, or convert the transferred value to an immutable/value type. references/sendable.md, references/threading.md
SwiftLint async_without_await Is async actually required by protocol, override, or @concurrent? Remove async, or use a narrow suppression with rationale. Never add fake awaits. references/linting.md
wait(...) is unavailable from asynchronous contexts Is this legacy XCTest async waiting? Replace with await fulfillment(of:) or Swift Testing equivalents. references/testing.md
Core Data concurrency warnings Are NSManagedObject instances crossing contexts or actors? Pass NSManagedObjectID or map to a Sendable value type. references/core-data.md
@Observable isolation or Sendable errors Is the @Observable class annotated with the correct actor? Add @MainActor for UI state; pass Sendable snapshots across boundaries. references/observation.md
Thread.current unavailable from asynchronous contexts
Полный SKILL.md на GitHub

Установить swift-concurrency в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

agents/openai.yamlassets/logo-small.pngassets/logo.pngreferences/_index.mdreferences/actors.mdreferences/async-algorithms.mdreferences/async-await-basics.mdreferences/async-sequences.mdreferences/core-data.mdreferences/glossary.mdreferences/linting.mdreferences/memory-management.mdreferences/migration.mdreferences/observation.mdreferences/performance.mdreferences/sendable.mdreferences/tasks.mdreferences/testing.mdreferences/threading.md

FAQ

Что делает скилл swift-concurrency?

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 concurrency-related compiler and linter warnings.

Как установить скилл swift-concurrency?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл swift-concurrency запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить swift-concurrency с