Co-Pilot / 辅助式
更新于 a month ago
swift-concurrency-expert
DDimillian
1.5k
Dimillian/Skills/swift-concurrency-expert
💡 摘要
Swift Concurrency Expert 帮助审查和修复 Swift 6.2+ 代码库中的并发问题。
🎯 适合人群
从事并发工作的 Swift 开发者维护遗留 Swift 代码的软件工程师监督 Swift 项目的技术负责人教授 Swift 并发的教育工作者专注于并发合规性的代码审查员
🤖 AI 吐槽: “看起来很能打,但别让配置把人劝退。”
安全分析低风险
风险:Low。建议检查:权限范围、数据流向与依赖风险。以最小权限运行,并在生产环境启用前审计代码与依赖。
name: swift-concurrency-expert description: 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.
Swift Concurrency Expert
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).
- Check project concurrency settings: Swift language version (6.2+), strict concurrency level, and whether approachable concurrency (default actor isolation / main-actor-by-default) is enabled.
- 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/approachable-concurrency.mdwhen the project is opted into approachable concurrency mode. - See
references/swiftui-concurrency-tour-wwdc.mdfor SwiftUI-specific concurrency guidance.
五维分析
清晰度8/10
创新性7/10
实用性9/10
完整性7/10
可维护性8/10
优缺点分析
优点
- 彻底的问题识别过程
- 关注最小行为变化
- 现代并发模式的指导
- 处理 UI 绑定和后台工作
缺点
- 需要理解 Swift 并发概念
- 仅限于 Swift 6.2+
- 可能无法覆盖所有边缘情况
- 依赖于外部参考材料
相关技能
免责声明:本内容来源于 GitHub 开源项目,仅供展示和评分分析使用。
版权归原作者所有 Dimillian.
