Claude-superpowers swift-6-migration
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
git clone https://github.com/ivan-magda/claude-superpowers
T=$(mktemp -d) && git clone --depth=1 https://github.com/ivan-magda/claude-superpowers "$T" && mkdir -p ~/.claude/skills && cp -r "$T/plugins/swift/skills/swift-6-migration" ~/.claude/skills/ivan-magda-claude-superpowers-swift-6-migration && rm -rf "$T"
plugins/swift/skills/swift-6-migration/SKILL.mdSwift 6 Migration
Overview
Swift 6 enforces data race safety at compile time. Migration involves making implicit isolation explicit and ensuring all shared state is thread-safe.
This skill bundles Apple's complete migration guide. You MUST search it for EVERY error before implementing a fix.
Mandatory Workflow
digraph migration_workflow { rankdir=TB; node [shape=box]; "Compiler error/warning" [shape=ellipse]; "Search migration-guide.md" [label="REQUIRED: Search migration-guide.md\nfor error pattern"]; "Read matched section" [label="Read the matched FILE: section"]; "Apply documented fix" [label="Apply Apple's documented fix"]; "Verify fix" [label="Build and verify"]; "Compiler error/warning" -> "Search migration-guide.md"; "Search migration-guide.md" -> "Read matched section"; "Read matched section" -> "Apply documented fix"; "Apply documented fix" -> "Verify fix"; "Verify fix" -> "Compiler error/warning" [label="More errors"]; }
For EACH compiler error/warning:
- FIRST search migration-guide.md for the error pattern
- THEN read the matched FILE: section
- THEN apply the documented fix
- FINALLY verify the fix
Checklist
Use TodoWrite to track each item:
- Enable
warnings before Swift 6 mode-strict-concurrency=complete - For EACH error: grep migration-guide.md BEFORE implementing fix
- Read the relevant FILE: section from search results
- Verify fix matches Apple's documented approach
- Test runtime behavior after fixes (execution order may change)
Required Searches by Error Type
You MUST run these searches. Do not skip to Quick Reference.
| Error Pattern | Required Search Command |
|---|---|
| |
| |
| |
| |
needed | |
or async/await migration | |
| GCD/DispatchQueue migration | |
Quick Reference (Starting Points Only)
These are shortcuts for orientation. You MUST verify against migration-guide.md before applying.
| Problem | Likely Direction | Verify With |
|---|---|---|
| Mutable global var | , , or actor | |
| Non-Sendable class | , , or actor | |
| Actor isolation error | , , or | |
| Closure capturing | closure or restructure | |
| Legacy callback API | | |
Commands
# 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]
Common Mistakes
| Mistake | Why It's Wrong | Better Approach |
|---|---|---|
Adding everywhere | Hides real data races | Search guide first: |
Using | Compiler trusts you but runtime doesn't | Search: |
| Skipping the migration guide | Miss Apple's recommended patterns | ALWAYS search before fixing |
Red Flags - STOP and Search First
These thoughts mean you're about to skip required verification:
- "I know how to fix this"
- "The Quick Reference has the answer"
- "This is a common pattern"
- "I'll check the guide if this doesn't work"
- "My knowledge is sufficient"
All of these mean: Search migration-guide.md FIRST.
Reference Documentation
The migration-guide.md file contains Apple's complete migration documentation (25 bundled files, 3700+ lines):
| Topic | Search Pattern |
|---|---|
| Common errors | |
| Data race safety | |
| Incremental adoption | |
| Swift 6 mode | |
| Complete checking | |
| Sendable examples | |
| Global variable patterns | |
To find specific content:
grep -n "pattern" migration-guide.md