swift-concurrency-expert
它能做什么
这个技能诊断关于 Swift 并发的编译器错误,并对 actor、主线程隔离和共享数据应用安全的修复。适合开发 Swift 6 应用的开发者。
适用场景
- ✓Swift 显示与 actor、隔离或 Sendable 类型相关的错误的时候。
- ✓你需要把后台工作安全地移出主线程的时候。
- ✓你想审核现有 Swift 并发设置的时候。
技能链接
https://github.com/steipete/agent-scripts/blob/main/skills/swift-concurrency-expert/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“Xcode 提示我的视图模型有 Sendable 错误。请用最小的安全改动修复它。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会获取准确的编译器信息,找到当前的 actor 设置,并应用能保持行为不变的最小修复。除非能证明线程安全,否则它会避免不安全的捷径。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Swift Concurrency Expert
Attribution: copied from @Dimillian’s Dimillian/Skills (2025-12-31).
Overview
Review and fix Swift Concurrency issues in Swift 6.2+ codebases by applying actor isolation, Sendable safety, and modern concurrency patterns with minimal behavior changes.
Workflow
1. Triage the issue
- Capture the exact compiler diagnostics and the offending symbol(s).
- Identify the current actor context (
@MainActor,actor,nonisolated) and whether a default actor isolation mode is enabled. - Confirm whether the code is UI-bound or intended to run off the main actor.
2. Apply the smallest safe fix
Prefer edits that preserve existing behavior while satisfying data-race safety.
Common fixes:
- UI-bound types: annotate the type or relevant members with
@MainActor. - Protocol conformance on main actor types: make the conformance isolated (e.g.,
extension Foo: @MainActor SomeProtocol). - Global/static state: protect with
@MainActoror move into an actor. - Background work: move expensive work into a
@concurrentasync function on anonisolatedtype or use anactorto guard mutable state. - Sendable errors: prefer immutable/value types; add
Sendableconformance only when correct; avoid@unchecked Sendableunless you can prove thread safety.
Reference material
- See
references/swift-6-2-concurrency.mdfor Swift 6.2 changes, patterns, and examples. - See
references/swiftui-concurrency-tour-wwdc.mdfor SwiftUI-specific concurrency guidance.
常见问题
它会改变应用的行为吗?
技能力求在满足数据竞争安全规则的同时,使行为改动最小。
什么时候允许使用未经检查的 Sendable?
根据技能说明,只有在能证明线程安全的情况下才允许。
它针对哪些 Swift 版本?
Swift 6.2 及更高版本。
详情
作者的原始描述
Swift concurrency review/fix: compiler errors, Sendable, isolation, remediation.
repo: steipete/agent-scripts
热度
- GitHub 星标
- 7.4k
- 排名
- #13248
- 许可证
- MIT
- 更新时间
- 2026/10/30
评论
- …
同一仓库的更多技能
beeper
7.4k帮你的智能体搜索本地 Beeper 聊天记录,找到消息,并判断模糊线索指的是哪个聊天或联系人。
cloudflare-registrar
7.4k帮你的智能体查询 Cloudflare Registrar 的域名价格和可用性,并在确认后注册或列出域名。
codexbar
7.4k帮你的智能体查看你在 Codex、Claude、Kimi 等 AI 服务中还剩多少用量,包括限额、额度和重置时间。
create-cli
7.4k帮你的智能体设计命令行工具的命令、参数、帮助文本、输出和错误提示,让人和脚本都能顺利使用。