Skip to content
Skills Library
Programming · Building & coding

swift-6-migration

/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

Licence
MIT
Last repository change
21.06.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 21.06.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

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

Triggers from the description

global variable is not concurrency-safe
Original author description

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

How it works

  1. Overview
  2. Mandatory Workflow
  3. Checklist
  4. Required Searches by Error Type
  5. Quick Reference (Starting Points Only)
  6. Commands
  7. Common Mistakes
  8. Red Flags - STOP and Search First
  9. Reference Documentation
Original SKILL.md headings · 132 lines, 705 words
SKILL.md preview
---
name: swift-6-migration
description: 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
allowed-tools: Read, Grep, Glob
---

# Swift 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

```dot
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:**

1. **FIRST** search migration-guide.md for the error pattern
2. **THEN** read the matched FILE: section
3. **THEN** apply the documented fix
4. **FINALLY** verify the fix

## Checklist

Use TodoWrite to track each item:

- [ ] Enable `-strict-concurrency=complete` warnings before Swift 6 mode
- [ ] 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                                    |
| ------------------------------------------- | ---------------------------------------------------------- |
| `global variable is not concurrency-safe`   | `grep -n -A 30 "Unsafe Global" migration-guide.md`         |
| `does not conform to.*Sendable`             | `grep -n -A 30 "Sendable Types" migration-guide.md`        |
| `cannot pass argument of non-sendable type` | `grep -n -A 30 "ConformanceMismatches" migration-guide.md` |
| `actor-isolated.*cannot be referenced`      | `grep -n -A 30 "actor-isolated" migration-guide.md`        |
| `@preconcurrency` needed                    | `grep -n -A 30 "PreconcurrencyImport" migration-guide.md`  |
| `Task` or async/await migration             | `grep -n -A 30 "Boundaries.swift" migration-guide.md`      |
| GCD/DispatchQueue migration                 | `grep -n -A 30 "DispatchQueue" migration-guide.md`         |

## 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    | `let`, `@MainActor`, or actor               | `grep -n "Globals.swift" migration-guide.md`  |
| Non-Sendable class    | `Sendable`, `@unchecked Sendable`, or actor | `grep -n "Sendable" migration-guide.md`       |
| Actor isolation error | `await`, `nonisolated`, or `@MainActor`     | `grep -n "actor-isolated" migration-guide.md` |
| Closure capturing     | `@Sendable` closure or restructure          | `grep -n "closure" migration-guide.md`        |
| Legacy callback API   | `withCheckedContinuation`                   | `grep -n "continuation" migration-guide.md`   |

## Commands

```bash
# 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:**

```swift
// 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 `@unchecked Sendable` everywhere | Hides real data races                   | Search guide first: `grep -n "unchecked" migration-guide.md` |
| Using `nonisolated(unsafe)`             | Compiler trusts you but runtime doesn't | Search: `grep -n "nonisolated" migration-guide.md`           |
| 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            | `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`               |

To find specific content: `grep -n "pattern" migration-guide.md`
Files in this package (2)
  • SKILL.md 6 KB
  • migration-guide.md 120 KB

Versions

The database has no other skills named swift-6-migration.

Database snapshot: 13.11.2026 · package version 5f187c794942 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95swift-concurrency
    Resolve Swift concurrency compiler errors, adopt approachable concurrency (SE-0466), and write data-race-safe async code. Use when fixing Sendable conformance errors, actor isolation warnings, or strict concurrency diagnostics; when adopting default MainActor isolation,…
  • 95swift-concurrency-expert
    Swift Concurrency review and remediation for Swift 6.2+. Use when asked to review Swift Concurrency usage, improve concurrency compliance, or fix Swift concurrency compiler errors in a feature or file. Concrete actions include adding Sendable conformance, applying @MainActor…
  • 100swift-concurrency-expert
    Diagnoses and fixes Swift concurrency problems: data-race-safety errors in the Swift 6 language mode, actor isolation, Sendable, moving work off the main actor, and wrapping callback APIs in async functions. Reads the target's build settings first, because default isolation and…
  • 95swift-concurrency
    Expert guidance on Swift Concurrency concepts. Use when working with async/await, Tasks, actors, MainActor, Sendable, isolation domains, or debugging concurrency compiler errors. Helps write safe concurrent Swift code.
  • 100swift-concurrency
    Use when diagnosing Swift Concurrency issues, refactoring callback-based code to async/await, or migrating to Swift 6 - tasks, actors, @MainActor, Sendable, data races and isolation errors.
  • 100swift-code-review
    Reviews Swift code for concurrency safety, error handling, memory management, and common mistakes. Use when reviewing .swift files for async/await patterns, actor isolation, Sendable conformance, or general Swift best practices.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.