Use when writing async/await code, enabling strict concurrency, fixing Sendable errors, migrating from completion handlers, managing shared state with actors, or using Task/TaskGroup for concurrency.
Enables Swift 6.2+ async/await, actors, and strict concurrency. Triggers when migrating from completion handlers, fixing Sendable errors, managing shared state with actors, or using Task/TaskGroup for parallel operations.
/plugin marketplace add johnrogers/claude-swift-engineering/plugin install swift-engineering@claude-swift-engineeringThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/concurrency-essentials.mdreferences/macros.mdreferences/migration-patterns.mdreferences/modern-attributes.mdreferences/strict-concurrency.mdreferences/swift6-concurrency.mdreferences/task-cancellation.mdreferences/task-groups.mdSwift 6.2 introduces strict compile-time concurrency checking with async/await, actors, and Sendable constraints that prevent data races at compile time instead of runtime. This is the foundation of safe concurrent Swift.
Modern Swift replaces older concurrency patterns (completion handlers, DispatchQueue, locks) with compiler-enforced safety. The core principle: if it compiles with strict concurrency enabled, it cannot have data races.
| Need | Use | NOT |
|---|---|---|
| Async operation | async/await | Completion handlers |
| Main thread work | @MainActor | DispatchQueue.main |
| Shared mutable state | actor | Locks, serial queues |
| Parallel tasks | TaskGroup | DispatchGroup |
| Thread safety | Sendable | @unchecked everywhere |
When writing async Swift code:
async, call with await@MainActor to view models and UI-updating codeactor instead of locks for shared mutable stateTask.isCancelled or call Task.checkCancellation() in loopsLoad these based on what you need:
@unchecked Sendable as a quick fix — Using @unchecked Sendable to silence compiler errors means you've opted out of safety. If the error persists after @unchecked, your code has a potential data race. Fix the underlying issue instead.
Missing await at call sites — Forgetting await when calling async functions is a compiler error, but checking Task.isCancelled in a loop without calling Task.checkCancellation() silently ignores cancellation.
Capturing self in async blocks without weak — Holding a strong reference to self in a long-running async task prevents deinit. Always use [weak self] in closures or use .task which auto-manages the lifecycle.
Not checking task cancellation — Long-running operations should regularly check Task.isCancelled or call Task.checkCancellation(), otherwise cancellation signals are ignored.
Forgetting @MainActor on UI code and test suites — Main test struct and view models that update @Published properties need @MainActor. Forgetting it silently allows cross-thread mutations. Apply @MainActor to: view models, view structs, main test structs, and any type that touches UI.
Actor re-entrancy surprises — await inside an actor method can release the lock temporarily. Another task may modify actor state. Design actor methods assuming state can change between await points.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.