swift-concurrency
Swift concurrency: async/await, Actor, Task, Sendable patterns.
适合你,如果正在用 Swift 开发并发应用
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
~/.claude/skills/(项目级 .claude/skills/)~/.codex/skills/npx oh-my-skill add notque/vexjoy-agent/swift-concurrencycurl -fsSL https://oh-my-skill.com/install.sh | bash -s -- notque/vexjoy-agent/swift-concurrencynpx oh-my-skill verify notque/vexjoy-agent/swift-concurrency怎么用
技能原文 SKILL.md
Swift Structured Concurrency
Pattern catalog for Swift's structured concurrency model: async/await, Actors, TaskGroups, AsyncSequence, Sendable, and cancellation. Load the reference file matching the developer's question.
Reference Loading Table
| Signal | Reference File | Content | |--------|---------------|---------| | async/await, Task, Sendable | references/fundamentals.md | async/await patterns, Task/Task.detached, Sendable/@Sendable | | Actor, @MainActor, nonisolated | references/actor-isolation.md | Actor isolation, MainActor UI confinement, nonisolated opt-out | | TaskGroup, AsyncSequence, AsyncStream, cancellation | references/task-patterns.md | Structured concurrency, rate-limited groups, streams, cancellation | | Failure modes, common mistakes | references/preferred-patterns.md | Blocking MainActor, task leaking, actor reentrancy hazard |
Key Conventions
- Prefer structured concurrency -- use
TaskGroupover looseTask { }whenever possible; structured tasks propagate cancellation and errors automatically. - Mark types Sendable -- enable strict concurrency checking (
-strict-concurrency=complete) and resolve all warnings before they become errors in Swift 6. - Use actors for shared mutable state -- avoid manual locks; actors provide compiler-verified safety.
- Cancel what you create -- every
Taskstored in a property should have a corresponding cancellation path. - Minimize @MainActor surface -- isolate only the UI layer; keep business logic and networking off the main actor.
References
references/fundamentals.md-- async/await, Task, Sendable basicsreferences/actor-isolation.md-- Actor, @MainActor, nonisolatedreferences/task-patterns.md-- TaskGroup, AsyncSequence, AsyncStream, cancellationreferences/preferred-patterns.md-- blocking, leaking, reentrancy mistakes