Use when encountering Swift 6 concurrency errors, Sendable conformance warnings, actor isolation issues, "global variable is not concurrency-safe" errors, or migrating codebases to Swift 6 language mode
Detects Swift 6 concurrency errors and migration issues, then fixes Sendable conformance, actor isolation, and thread-safety problems. Automatically resolves compiler errors like "global variable is not concurrency-safe" and "cannot pass argument of non-sendable type" by applying proper async/await patterns, actor wrapping, or @preconcurrency imports.
/plugin marketplace add ivan-magda/claude-code-marketplace/plugin install swift@claude-code-marketplaceThis skill is limited to using the following tools:
migration-guide.mdSwift 6 enforces data race safety at compile time. Migration involves making implicit isolation explicit and ensuring all shared state is thread-safe through Sendable conformance, actor isolation, or explicit synchronization.
Symptoms that trigger this skill:
global variable 'X' is not concurrency-safecannot pass argument of non-sendable typeactor-isolated property cannot be referenced from non-isolated contextreference to var 'X' is not concurrency-safetype 'X' does not conform to the 'Sendable' protocol-strict-concurrency=complete or Swift 6 modeWhen NOT to use:
| Problem | Solution |
|---|---|
| Mutable global var | Use let, isolate to @MainActor, or wrap in actor |
| Non-Sendable class | Add Sendable + @unchecked Sendable, or make an actor |
| Actor isolation error | Add await, use nonisolated, or annotate with @MainActor |
| Closure capturing non-Sendable | Use @Sendable closure, capture explicitly, or restructure |
| Legacy callback API | Wrap with withCheckedContinuation or withCheckedThrowingContinuation |
| Third-party non-Sendable types | Use @preconcurrency import as temporary workaround |
# Check Swift version
swift --version
# Build with complete concurrency checking (warnings)
swift build -Xswiftc -strict-concurrency=complete
# Build in Swift 6 mode (errors)
swift build -Xswiftc -swift-version -Xswiftc 6
Package.swift settings:
// Enable strict concurrency per target
.target(
name: "MyTarget",
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]
)
// Or enable Swift 6 mode
swiftLanguageVersions: [.v6]
-strict-concurrency=complete before Swift 6 mode| Mistake | Why It's Wrong | Better Approach |
|---|---|---|
Adding @unchecked Sendable everywhere | Hides real data races | Analyze actual thread safety first |
Using nonisolated(unsafe) without synchronization | Compiler trusts you but runtime doesn't | Only use with actual locks/queues protecting access |
Wrapping everything in Task { } | Creates unnecessary concurrency | Use await at natural boundaries |
| Making all classes actors | Actors have overhead and change semantics | Use actors for shared mutable state only |
Ignoring @preconcurrency warnings | Technical debt accumulates | Plan to address underlying issues |
The migration-guide.md file contains Apple's complete migration documentation (25 bundled files). Key sections:
| Topic | Search Pattern |
|---|---|
| Common errors | FILE: Guide.docc/CommonProblems.md |
| Data race safety | FILE: Guide.docc/DataRaceSafety.md |
| Incremental adoption | FILE: Guide.docc/IncrementalAdoption.md |
| Swift 6 mode | FILE: Guide.docc/Swift6Mode.md |
| Complete checking | FILE: Guide.docc/CompleteChecking.md |
| Sendable examples | FILE: Sources/Examples/ConformanceMismatches.swift |
| Global variable patterns | FILE: Sources/Examples/Globals.swift |
Use grep to find specific content: grep -n "pattern" migration-guide.md
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 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 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.