[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M72YY2RWG6CDV1P9VRKZNM7Z":3,"skill-same:01M72YY2RWG6CDV1P9VRKZNM7Z":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M72YY2RWG6CDV1P9VRKZNM7Z","swift-concurrency-6-2",null,"Swift 6.2 Approachable Concurrency — single-threaded by default, @concurrent for explicit background offloading, isolated conformances for main actor types.","SriramGandhiS\u002FSkills","SriramGandhiS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F211849986?v=4","01M72WQCW12BYX71C6WN584TTA","Sriram S","01M72WQCWTJ2RD0ET1X31AF1RC",1,"MIT","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Feverything-claude-code\u002Fskills\u002Fswift-concurrency-6-2\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: swift-concurrency-6-2\ndescription: Swift 6.2 Approachable Concurrency — single-threaded by default, @concurrent for explicit background offloading, isolated conformances for main actor types.\n---\n\n# Swift 6.2 Approachable Concurrency\n\nPatterns for adopting Swift 6.2's concurrency model where code runs single-threaded by default and concurrency is introduced explicitly. Eliminates common data-race errors without sacrificing performance.\n\n## When to Activate\n\n- Migrating Swift 5.x or 6.0\u002F6.1 projects to Swift 6.2\n- Resolving data-race safety compiler errors\n- Designing MainActor-based app architecture\n- Offloading CPU-intensive work to background threads\n- Implementing protocol conformances on MainActor-isolated types\n- Enabling Approachable Concurrency build settings in Xcode 26\n\n## Core Problem: Implicit Background Offloading\n\nIn Swift 6.1 and earlier, async functions could be implicitly offloaded to background threads, causing data-race errors even in seemingly safe code:\n\n```swift\n\u002F\u002F Swift 6.1: ERROR\n@MainActor\nfinal class StickerModel {\n    let photoProcessor = PhotoProcessor()\n\n    func extractSticker(_ item: PhotosPickerItem) async throws -> Sticker? {\n        guard let data = try await item.loadTransferable(type: Data.self) else { return nil }\n\n        \u002F\u002F Error: Sending 'self.photoProcessor' risks causing data races\n        return await photoProcessor.extractSticker(data: data, with: item.itemIdentifier)\n    }\n}\n```\n\nSwift 6.2 fixes this: async functions stay on the calling actor by default.\n\n```swift\n\u002F\u002F Swift 6.2: OK — async stays on MainActor, no data race\n@MainActor\nfinal class StickerModel {\n    let photoProcessor = PhotoProcessor()\n\n    func extractSticker(_ item: PhotosPickerItem) async throws -> Sticker? {\n        guard let data = try await item.loadTransferable(type: Data.self) else { return nil }\n        return await photoProcessor.extractSticker(data: data, with: item.itemIdentifier)\n    }\n}\n```\n\n## Core Pattern — Isolated Conformances\n\nMainActor types can now conform to non-isolated protocols safely:\n\n```swift\nprotocol Exportable {\n    func export()\n}\n\n\u002F\u002F Swift 6.1: ERROR — crosses into main actor-isolated code\n\u002F\u002F Swift 6.2: OK with isolated conformance\nextension StickerModel: @MainActor Exportable {\n    func export() {\n        photoProcessor.exportAsPNG()\n    }\n}\n```\n\nThe compiler ensures the conformance is only used on the main actor:\n\n```swift\n\u002F\u002F OK — ImageExporter is also @MainActor\n@MainActor\nstruct ImageExporter {\n    var items: [any Exportable]\n\n    mutating func add(_ item: StickerModel) {\n        items.append(item)  \u002F\u002F Safe: same actor isolation\n    }\n}\n\n\u002F\u002F ERROR — nonisolated context can't use MainActor conformance\nnonisolated struct ImageExporter {\n    var items: [any Exportable]\n\n    mutating func add(_ item: StickerModel) {\n        items.append(item)  \u002F\u002F Error: Main actor-isolated conformance cannot be used here\n    }\n}\n```\n\n## Core Pattern — Global and Static Variables\n\nProtect global\u002Fstatic state with MainActor:\n\n```swift\n\u002F\u002F Swift 6.1: ERROR — non-Sendable type may have shared mutable state\nfinal class StickerLibrary {\n    static let shared: StickerLibrary = .init()  \u002F\u002F Error\n}\n\n\u002F\u002F Fix: Annotate with @MainActor\n@MainActor\nfinal class StickerLibrary {\n    static let shared: StickerLibrary = .init()  \u002F\u002F OK\n}\n```\n\n### MainActor Default Inference Mode\n\nSwift 6.2 introduces a mode where MainActor is inferred by default — no manual annotations needed:\n\n```swift\n\u002F\u002F With MainActor default inference enabled:\nfinal class StickerLibrary {\n    static let shared: StickerLibrary = .init()  \u002F\u002F Implicitly @MainActor\n}\n\nfinal class StickerModel {\n    let photoProcessor: PhotoProcessor\n    var selection: [PhotosPickerItem]  \u002F\u002F Implicitly @MainActor\n}\n\nextension StickerModel: Exportable {  \u002F\u002F Implicitly @MainActor conformance\n    func export() {\n        photoProcessor.exportAsPNG()\n    }\n}\n```\n\nThis mode is opt-in and recommended for apps, scripts, and other executable targets.\n\n## Core Pattern — @concurrent for Background Work\n\nWhen you need actual parallelism, explicitly offload with `@concurrent`:\n\n> **Important:** This example requires Approachable Concurrency build settings — SE-0466 (MainActor default isolation) and SE-0461 (NonisolatedNonsendingByDefault). With these enabled, `extractSticker` stays on the caller's actor, making mutable state access safe. **Without these settings, this code has a data race** — the compiler will flag it.\n\n```swift\nnonisolated final class PhotoProcessor {\n    private var cachedStickers: [String: Sticker] = [:]\n\n    func extractSticker(data: Data, with id: String) async -> Sticker {\n        if let sticker = cachedStickers[id] {\n            return sticker\n        }\n\n        let sticker = await Self.extractSubject(from: data)\n        cachedStickers[id] = sticker\n        return sticker\n    }\n\n    \u002F\u002F Offload expensive work to concurrent thread pool\n    @concurrent\n    static func extractSubject(from data: Data) async -> Sticker { \u002F* ... *\u002F }\n}\n\n\u002F\u002F Callers must await\nlet processor = PhotoProcessor()\nprocessedPhotos[item.id] = await processor.extractSticker(data: data, with: item.id)\n```\n\nTo use `@concurrent`:\n1. Mark the containing type as `nonisolated`\n2. Add `@concurrent` to the function\n3. Add `async` if not already asynchronous\n4. Add `await` at call sites\n\n## Key Design Decisions\n\n| Decision | Rationale |\n|----------|-----------|\n| Single-threaded by default | Most natural code is data-race free; concurrency is opt-in |\n| Async stays on calling actor | Eliminates implicit offloading that caused data-race errors |\n| Isolated conformances | MainActor types can conform to protocols without unsafe workarounds |\n| `@concurrent` explicit opt-in | Background execution is a deliberate performance choice, not accidental |\n| MainActor default inference | Reduces boilerplate `@MainActor` annotations for app targets |\n| Opt-in adoption | Non-breaking migration path — enable features incrementally |\n\n## Migration Steps\n\n1. **Enable in Xcode**: Swift Compiler > Concurrency section in Build Settings\n2. **Enable in SPM**: Use `SwiftSettings` API in package manifest\n3. **Use migration tooling**: Automatic code changes via swift.org\u002Fmigration\n4. **Start with MainActor defaults**: Enable inference mode for app targets\n5. **Add `@concurrent` where needed**: Profile first, then offload hot paths\n6. **Test thoroughly**: Data-race issues become compile-time errors\n\n## Best Practices\n\n- **Start on MainActor** — write single-threaded code first, optimize later\n- **Use `@concurrent` only for CPU-intensive work** — image processing, compression, complex computation\n- **Enable MainActor inference mode** for app targets that are mostly single-threaded\n- **Profile before offloading** — use Instruments to find actual bottlenecks\n- **Protect globals with MainActor** — global\u002Fstatic mutable state needs actor isolation\n- **Use isolated conformances** instead of `nonisolated` workarounds or `@Sendable` wrappers\n- **Migrate incrementally** — enable features one at a time in build settings\n\n## Anti-Patterns to Avoid\n\n- Applying `@concurrent` to every async function (most don't need background execution)\n- Using `nonisolated` to suppress compiler errors without understanding isolation\n- Keeping legacy `DispatchQueue` patterns when actors provide the same safety\n- Skipping `model.availability` checks in concurrency-related Foundation Models code\n- Fighting the compiler — if it reports a data race, the code has a real concurrency issue\n- Assuming all async code runs in the background (Swift 6.2 default: stays on calling actor)\n\n## When to Use\n\n- All new Swift 6.2+ projects (Approachable Concurrency is the recommended default)\n- Migrating existing apps from Swift 5.x or 6.0\u002F6.1 concurrency\n- Resolving data-race safety compiler errors during Xcode 26 adoption\n- Building MainActor-centric app architectures (most UI apps)\n- Performance optimization — offloading specific heavy computations to background\n","# Swift 6.2 Approachable Concurrency\n\nPatterns for adopting Swift 6.2's concurrency model where code runs single-threaded by default and concurrency is introduced explicitly. Eliminates common data-race errors without sacrificing performance.\n\n## When to Activate\n\n- Migrating Swift 5.x or 6.0\u002F6.1 projects to Swift 6.2\n- Resolving data-race safety compiler errors\n- Designing MainActor-based app architecture\n- Offloading CPU-intensive work to background threads\n- Implementing protocol conformances on MainActor-isolated types\n- Enabling Approachable Concurrency build settings in Xcode 26\n\n## Core Problem: Implicit Background Offloading\n\nIn Swift 6.1 and earlier, async functions could be implicitly offloaded to background threads, causing data-race errors even in seemingly safe code:\n\n```swift\n\u002F\u002F Swift 6.1: ERROR\n@MainActor\nfinal class StickerModel {\n    let photoProcessor = PhotoProcessor()\n\n    func extractSticker(_ item: PhotosPickerItem) async throws -> Sticker? {\n        guard let data = try await item.loadTransferable(type: Data.self) else { return nil }\n\n        \u002F\u002F Error: Sending 'self.photoProcessor' risks causing data races\n        return await photoProcessor.extractSticker(data: data, with: item.itemIdentifier)\n    }\n}\n```\n\nSwift 6.2 fixes this: async functions stay on the calling actor by default.\n\n```swift\n\u002F\u002F Swift 6.2: OK — async stays on MainActor, no data race\n@MainActor\nfinal class StickerModel {\n    let photoProcessor = PhotoProcessor()\n\n    func extractSticker(_ item: PhotosPickerItem) async throws -> Sticker? {\n        guard let data = try await item.loadTransferable(type: Data.self) else { return nil }\n        return await photoProcessor.extractSticker(data: data, with: item.itemIdentifier)\n    }\n}\n```\n\n## Core Pattern — Isolated Conformances\n\nMainActor types can now conform to non-isolated protocols safely:\n\n```swift\nprotocol Exportable {\n    func export()\n}\n\n\u002F\u002F Swift 6.1: ERROR — crosses into main actor-isolated code\n\u002F\u002F Swift 6.2: OK with isolated conformance\nextension StickerModel: @MainActor Exportable {\n    func export() {\n        photoProcessor.exportAsPNG()\n    }\n}\n```\n\nThe compiler ensures the conformance is only used on the main actor:\n\n```swift\n\u002F\u002F OK — ImageExporter is also @MainActor\n@MainActor\nstruct ImageExporter {\n    var items: [any Exportable]\n\n    mutating func add(_ item: StickerModel) {\n        items.append(item)  \u002F\u002F Safe: same actor isolation\n    }\n}\n\n\u002F\u002F ERROR — nonisolated context can't use MainActor conformance\nnonisolated struct ImageExporter {\n    var items: [any Exportable]\n\n    mutating func add(_ item: StickerModel) {\n        items.append(item)  \u002F\u002F Error: Main actor-isolated conformance cannot be used here\n    }\n}\n```\n\n## Core Pattern — Global and Static Variables\n\nProtect global\u002Fstatic state with MainActor:\n\n```swift\n\u002F\u002F Swift 6.1: ERROR — non-Sendable type may have shared mutable state\nfinal class StickerLibrary {\n    static let shared: StickerLibrary = .init()  \u002F\u002F Error\n}\n\n\u002F\u002F Fix: Annotate with @MainActor\n@MainActor\nfinal class StickerLibrary {\n    static let shared: StickerLibrary = .init()  \u002F\u002F OK\n}\n```\n\n### MainActor Default Inference Mode\n\nSwift 6.2 introduces a mode where MainActor is inferred by default — no manual annotations needed:\n\n```swift\n\u002F\u002F With MainActor default inference enabled:\nfinal class StickerLibrary {\n    static let shared: StickerLibrary = .init()  \u002F\u002F Implicitly @MainActor\n}\n\nfinal class StickerModel {\n    let photoProcessor: PhotoProcessor\n    var selection: [PhotosPickerItem]  \u002F\u002F Implicitly @MainActor\n}\n\nextension StickerModel: Exportable {  \u002F\u002F Implicitly @MainActor conformance\n    func export() {\n        photoProcessor.exportAsPNG()\n    }\n}\n```\n\nThis mode is opt-in and recommended for apps, scripts, and other executable targets.\n\n## Core Pattern — @concurrent for Background Work\n\nWhen you need actual parallelism, explicitly offload with `@concurrent`:\n\n> **Important:** This example requires Approachable Concurrency build settings — SE-0466 (MainActor default isolation) and SE-0461 (NonisolatedNonsendingByDefault). With these enabled, `extractSticker` stays on the caller's actor, making mutable state access safe. **Without these settings, this code has a data race** — the compiler will flag it.\n\n```swift\nnonisolated final class PhotoProcessor {\n    private var cachedStickers: [String: Sticker] = [:]\n\n    func extractSticker(data: Data, with id: String) async -> Sticker {\n        if let sticker = cachedStickers[id] {\n            return sticker\n        }\n\n        let sticker = await Self.extractSubject(from: data)\n        cachedStickers[id] = sticker\n        return sticker\n    }\n\n    \u002F\u002F Offload expensive work to concurrent thread pool\n    @concurrent\n    static func extractSubject(from data: Data) async -> Sticker { \u002F* ... *\u002F }\n}\n\n\u002F\u002F Callers must await\nlet processor = PhotoProcessor()\nprocessedPhotos[item.id] = await processor.extractSticker(data: data, with: item.id)\n```\n\nTo use `@concurrent`:\n1. Mark the containing type as `nonisolated`\n2. Add `@concurrent` to the function\n3. Add `async` if not already asynchronous\n4. Add `await` at call sites\n\n## Key Design Decisions\n\n| Decision | Rationale |\n|----------|-----------|\n| Single-threaded by default | Most natural code is data-race free; concurrency is opt-in |\n| Async stays on calling actor | Eliminates implicit offloading that caused data-race errors |\n| Isolated conformances | MainActor types can conform to protocols without unsafe workarounds |\n| `@concurrent` explicit opt-in | Background execution is a deliberate performance choice, not accidental |\n| MainActor default inference | Reduces boilerplate `@MainActor` annotations for app targets |\n| Opt-in adoption | Non-breaking migration path — enable features incrementally |\n\n## Migration Steps\n\n1. **Enable in Xcode**: Swift Compiler > Concurrency section in Build Settings\n2. **Enable in SPM**: Use `SwiftSettings` API in package manifest\n3. **Use migration tooling**: Automatic code changes via swift.org\u002Fmigration\n4. **Start with MainActor defaults**: Enable inference mode for app targets\n5. **Add `@concurrent` where needed**: Profile first, then offload hot paths\n6. **Test thoroughly**: Data-race issues become compile-time errors\n\n## Best Practices\n\n- **Start on MainActor** — write single-threaded code first, optimize later\n- **Use `@concurrent` only for CPU-intensive work** — image processing, compression, complex computation\n- **Enable MainActor inference mode** for app targets that are mostly single-threaded\n- **Profile before offloading** — use Instruments to find actual bottlenecks\n- **Protect globals with MainActor** — global\u002Fstatic mutable state needs actor isolation\n- **Use isolated conformances** instead of `nonisolated` workarounds or `@Sendable` wrappers\n- **Migrate incrementally** — enable features one at a time in build settings\n\n## Anti-Patterns to Avoid\n\n- Applying `@concurrent` to every async function (most don't need background execution)\n- Using `nonisolated` to suppress compiler errors without understanding isolation\n- Keeping legacy `DispatchQueue` patterns when actors provide the same safety\n- Skipping `model.availability` checks in concurrency-related Foundation Models code\n- Fighting the compiler — if it reports a data race, the code has a real concurrency issue\n- Assuming all async code runs in the background (Swift 6.2 default: stays on calling actor)\n\n## When to Use\n\n- All new Swift 6.2+ projects (Approachable Concurrency is the recommended default)\n- Migrating existing apps from Swift 5.x or 6.0\u002F6.1 concurrency\n- Resolving data-race safety compiler errors during Xcode 26 adoption\n- Building MainActor-centric app architectures (most UI apps)\n- Performance optimization — offloading specific heavy computations to background\n",{"name":5,"description":7},"master","d6ca01da0f24a3b0e26e4a8b7b66cbd25d429f5d","everything-claude-code\u002Fskills\u002Fswift-concurrency-6-2",0,"https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills","https:\u002F\u002Fgithub.com\u002FSriramGandhiS","https:\u002F\u002Fsriram.website\u002F","Curious guy who keeps tinkering until something works","2026-05-20 16:21:34",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add SriramGandhiS\u002FSkills --skill swift-concurrency-6-2",{"tool":39,"command":40},"bunx","bunx skills add SriramGandhiS\u002FSkills --skill swift-concurrency-6-2",{"tool":42,"command":43},"pnpm","pnpm dlx skills add SriramGandhiS\u002FSkills --skill swift-concurrency-6-2","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Feverything-claude-code\u002Fskills\u002Fswift-concurrency-6-2\u002FSKILL.md",true,[],[48,55,60,66,73,80],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M732609EPJWV13PVTX3GT4TM","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fwebgpu-threejs-tsl\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[],{"skillNo":56,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7325XM47AGWB6K6C4VXKE6B","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7325WP6DES69JKC840VMFEP","verification-loop","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7325TFQF1DZTQ6J3WGQQ1VR","tdd-workflow","Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Ftdd-workflow\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7325RGV9AY9PK92D2V8KKPW","strategic-compact","Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fstrategic-compact\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7325MZC28SE86E7NMCNEFS4","security-review","Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment\u002Fsensitive features. Provides comprehensive security checklist and patterns.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fsecurity-review\u002FSKILL.md",[],[]]