Token导航 LogoToken导航

Agent Skill · 研究检索

swift-concurrency(Swift 并发)

swift-concurrency 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

swift-concurrency 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,674 个 Skill 里排第 55,255。

总安装 489周安装 21GitHub Stars 56下载 171核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:swift-concurrency(Swift 并发)
来源仓库:https://github.com/joannis/claude-skills
仓库路径:skills/swift-concurrency
安装命令:
npx skills add https://github.com/joannis/claude-skills --skill swift-concurrency
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/joannis/claude-skills --skill swift-concurrency

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

swift-concurrency 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。适用于需要根据关键词或任务场景进行信息检索与筛选的场景。通过 npx skills add 命令从 GitHub 仓库安装并使用该技能。

安装前建议确认权限范围、维护状态及是否触发联网或文件操作。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/swift-concurrency

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/joannis/claude-skills --skill swift-concurrenc…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

swift-concurrency 怎么安装?

在终端执行 npx skills add https://github.com/joannis/claude-skills --skill swift-concurrency。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

swift-concurrency 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

swift-concurrency 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

swift-concurrency 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

swift-concurrency 用的人多吗?

公开数据是累计安装 489 次,近一周安装 21 次,下载 171 次,GitHub 56 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

swift-concurrency 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
swift-concurrency

Swift 并发 · 本页

48956需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Swift Concurrency

Overview

This skill provides expert guidance on Swift Concurrency, covering modern async/await patterns, actors, tasks, Sendable conformance, and migration to Swift 6. Use this skill to help developers write safe, performant concurrent code and navigate the complexities of Swift's structured concurrency model.

Agent Behavior Contract (Follow These Rules)

  1. Analyze the project/package file to find out which Swift language mode (Swift 5.x vs Swift 6) and which Xcode/Swift toolchain is used when advice depends on it.
  2. Before proposing fixes, identify the isolation boundary: @MainActor, custom actor, actor instance isolation, or nonisolated.
  3. Do not recommend @MainActor as a blanket fix. Justify why main-actor isolation is correct for the code.
  4. Prefer structured concurrency (child tasks, task groups) over unstructured tasks. Use Task.detached only with a clear reason.
  5. If recommending @preconcurrency, @unchecked Sendable, or nonisolated(unsafe), require:

- a documented safety invariant - a follow-up ticket to remove or migrate it

  1. For migration work, optimize for minimal blast radius (small, reviewable changes) and add verification steps.

Project Settings Intake (Evaluate Before Advising)

Concurrency behavior depends on build settings. Always try to determine:

  • Default actor isolation (is the module default @MainActor or nonisolated?)
  • Strict concurrency checking level (minimal/targeted/complete)
  • Whether upcoming features are enabled (especially NonisolatedNonsendingByDefault)
  • Swift language mode (Swift 5.x vs Swift 6) and diSwiftPM tools version

Manual checks (no scripts)

  • SwiftPM:

- Check Package.swift for .defaultIsolation(MainActor.self). - Check Package.swift for .enableUpcomingFeature("NonisolatedNonsendingByDefault"). - Check for strict concurrency flags: .enableExperimentalFeature("StrictConcurrency=targeted") (or similar). - Check tools version at the top: // swift-tools-version:...

  • Xcode projects:

- Search project.pbxproj for: - SWIFT_DEFAULT_ACTOR_ISOLATION - SWIFT_STRICT_CONCURRENCY - SWIFT_UPCOMING_FEATURE_ (and/or SWIFT_ENABLE_EXPERIMENTAL_FEATURES)

If any of these are unknown, ask the developer to confirm them before giving migration-sensitive guidance.

Quick Decision Tree

When a developer needs concurrency guidance, follow this decision tree:

  1. Starting fresh with async code?

- Read references/async-await-basics.md for foundational patterns - For parallel operations → references/tasks.md (async let, task groups)

  1. Protecting shared mutable state?

- Need to protect class-based state → references/actors.md (actors, @MainActor) - Need thread-safe value passing → references/sendable.md (Sendable conformance)

  1. Managing async operations?

- Structured async work → references/tasks.md (Task, child tasks, cancellation) - Streaming data → references/async-sequences.md (AsyncSequence, AsyncStream)

  1. Performance or debugging issues?

- Slow async code → references/performance.md (profiling, suspension points) - Testing concerns → references/testing.md (XCTest, Swift Testing)

Triage-First Playbook (Common Errors -> Next Best Move)

  • SwiftLint concurrency-related warnings

- Use references/linting.md for rule intent and preferred fixes; avoid dummy awaits as “fixes”.

  • SwiftLint async_without_await warning

- Remove async if not required; if required by protocol/override/@concurrent, prefer narrow suppression over adding fake awaits. See references/linting.md.

  • "Sending value of non-Sendable type... risks causing data races"

- First: identify where the value crosses an isolation boundary - Then: use references/sendable.md and references/threading.md (especially Swift 6.2 behavior changes)

  • "Main actor-isolated... cannot be used from a nonisolated context"

- First: decide if it truly belongs on @MainActor - Then: use references/actors.md (global actors, nonisolated, isolated parameters) and references/threading.md (default isolation)

  • "Class property 'current' is unavailable from asynchronous contexts" (Thread APIs)

- Use references/threading.md to avoid thread-centric debugging and rely on isolation + Instruments

  • XCTest async errors like "wait(...) is unavailable from asynchronous contexts"

- Use references/testing.md (await fulfillment(of:) and Swift Testing patterns)

  • Core Data concurrency warnings/errors

- Use references/core-data.md (DAO/NSManagedObjectID, default isolation conflicts)

Core Patterns Reference

When to Use Each Concurrency Tool

async/await - Making existing synchronous code asynchronous

// Use for: Single asynchronous operations
func fetchUser() async throws -> User {
    try await networkClient.get("/user")
}

async let - Running multiple independent async operations in parallel

// Use for: Fixed number of parallel operations known at compile time
async let user = fetchUser()
async let posts = fetchPosts()
let profile = try await (user, posts)

Task Group - Dynamic parallel operations with structured concurrency

// Use for: Unknown number of parallel operations at compile time
await withTaskGroup(of: Result.self) { group in
    for item in items {
        group.addTask { await process(item) }
    }
}

Actor - Protecting mutable state from data races

// Use for: Shared mutable state accessed from multiple contexts
actor DataCache {
    private var cache: [String: Data] = [:]
    func get(_ key: String) -> Data? { cache[key] }
}

@MainActor - Ensuring UI updates on main thread

// Use for: View models, UI-related classes
@MainActor
class ViewModel: ObservableObject {
    @Published var data: String = ""
}

Common Scenarios

Scenario: Multiple parallel network requests

async let users = fetchUsers()
async let posts = fetchPosts()
async let comments = fetchComments()
let (u, p, c) = try await (users, posts, comments)

Scenario: Processing array items in parallel

await withTaskGroup(of: ProcessedItem.self) { group in
    for item in items {
        group.addTask { await process(item) }
    }
    for await result in group {
        results.append(result)
    }
}

Swift 6 Migration Quick Guide

Key changes in Swift 6:

  • Strict concurrency checking enabled by default
  • Complete data-race safety at compile time
  • Sendable requirements enforced on boundaries
  • Isolation checking for all async boundaries

For detailed migration steps, see references/migration.md.

Reference Files

Load these files as needed for specific topics:

  • async-await-basics.md - async/await syntax, execution order, async let, URLSession patterns
  • tasks.md - Task lifecycle, cancellation, priorities, task groups, structured vs unstructured
  • threading.md - Thread/task relationship, suspension points, isolation domains, nonisolated
  • actors.md - Actor isolation, @MainActor, global actors, reentrancy, custom executors, Mutex
  • sendable.md - Sendable conformance, value/reference types, @unchecked, region isolation
  • async-sequences.md - AsyncSequence, AsyncStream, when to use vs regular async methods
  • performance.md - Profiling with Instruments, reducing suspension points, execution strategies
  • testing.md - XCTest async patterns, Swift Testing, concurrency testing utilities
  • production-patterns.md - Advanced patterns: actor state machines, ~Copyable state, structured concurrency, lock-free atomics, service lifecycle

Best Practices Summary

  1. Prefer structured concurrency - Use task groups over unstructured tasks when possible
  2. Minimize suspension points - Keep actor-isolated sections small to reduce context switches
  3. Use @MainActor judiciously - Only for truly UI-related code
  4. Make types Sendable - Enable safe concurrent access by conforming to Sendable
  5. Handle cancellation - Check Task.isCancelled in long-running operations
  6. Avoid blocking - Never use semaphores or locks in async contexts
  7. Test concurrent code - Use proper async test methods and consider timing issues

Use Structured Concurrency for Resource Management

When managing resources that need cleanup (connections, file handles, etc.), use the withX pattern to ensure proper cleanup through structured concurrency.

Bad - Unstructured cleanup:

func withConnection<R>(
    _ body: (Connection) async throws -> R
) async throws -> R {
    let connection = Connection()
    try await connection.connect()
    defer {
        Task {
            await connection.disconnect()  // Unstructured! May not complete
        }
    }
    return try await body(connection)
}

Better - Explicit cleanup in all paths:

func withConnection<R>(
    _ body: (Connection) async throws -> R
) async throws -> R {
    let connection = Connection()
    try await connection.connect()
    do {
        let result = try await body(connection)
        await connection.disconnect()
        return result
    } catch {
        await connection.disconnect()
        throw error
    }
}

Best - Make the pattern impossible to misuse:

actor Client {
    private let connection: Connection  // Non-optional, always valid

    private init(connection: Connection) {
        self.connection = connection
    }

    static func withConnection<R>(
        _ body: (Client) async throws -> R
    ) async throws -> R {
        let connection = try await Connection.establish()
        let client = Client(connection: connection)
        do {
            let result = try await body(client)
            await connection.close()
            return result
        } catch {
            await connection.close()
            throw error
        }
    }

    // No public connect()/disconnect() methods - can't forget cleanup
}

This pattern:

  • Makes the initializer private so users must go through withConnection
  • Stores resources as non-optional properties (no guard-let needed)
  • Guarantees cleanup happens before the function returns
  • Eliminates notConnected error cases entirely

Swift 6 Strict Concurrency with Global Mutable State

When accessing C globals like stdout in Swift 6 strict concurrency mode, use a local nonisolated(unsafe) variable:

@inline(__always)
private func flushStdout() {
    nonisolated(unsafe) let out = stdout
    fflush(out)
}

The nonisolated(unsafe) annotation tells the compiler to skip concurrency checking for this specific access to the C global.

ThrowingDiscardingTaskGroup for Fire-and-Forget Tasks

Use withThrowingDiscardingTaskGroup when you need to spawn multiple tasks but don't need to collect their individual results:

try await withThrowingDiscardingTaskGroup { taskGroup in
    taskGroup.addTask {
        try await handleClient(client1)
    }
    taskGroup.addTask {
        try await handleClient(client2)
    }
}

Graceful Shutdown Patterns

Check for both cancellation and graceful shutdown in long-running loops:

while !Task.isShuttingDownGracefully && !Task.isCancelled {
    try await handle(value)
}

// Use gracefulShutdown() for clean termination
try await gracefulShutdown()

AsyncStream: Avoid When Possible

AsyncStream has no backpressure. If the producer yields faster than the consumer processes, values accumulate in an unbounded buffer, leading to memory growth.

Prefer mapping NIOAsyncSequence or other backpressured sequences instead:

// Bad - no backpressure, unbounded buffer
let stream = AsyncStream<Message> { continuation in
    Task {
        for await rawMessage in nioChannel.inbound {
            continuation.yield(Message(rawMessage))
        }
        continuation.finish()
    }
}

// Good - preserves backpressure from NIO
let messages = nioChannel.inbound.map { Message($0) }
for try await message in messages {
    process(message)
}

If you must use AsyncStream, use structured concurrency with makeStream():

func run() async {
    let (stream, continuation) = AsyncStream<Value>.makeStream()

    async let producer: Void = runProducer(continuation: continuation)

    for await value in stream {
        process(value)
    }

    await producer
}

private func runProducer(
    continuation: sending AsyncStream<Value>.Continuation
) async {
    let cont = consume continuation  // Transfer ownership

    try? await withThrowingDiscardingTaskGroup { group in
        group.addTask {
            while !Task.isCancelled {
                cont.yield(produceValue())
                try await Task.sleep(for: .seconds(1))
            }
        }
    }

    cont.finish()
}

Key points:

  • sending parameter transfers ownership into the function
  • consume continuation allows safe sharing across task group children
  • AsyncStream.Continuation is Sendable - no need for nonisolated(unsafe)
  • Avoid Task {} inside AsyncStream.init - it's unstructured concurrency

Verification Checklist (When You Change Concurrency Code)

  • Confirm build settings (default isolation, strict concurrency, upcoming features) before interpreting diagnostics.
  • After refactors:

- Run tests, especially concurrency-sensitive ones (see references/testing.md). - If performance-related, verify with Instruments (see references/performance.md). - If lifetime-related, verify that the code is structured correctly, using with-style APIs.

Glossary

See references/glossary.md for quick definitions of core concurrency terms used across this skill.

平台分布

Codex

33.94%
按下载量换算58

Claude

32.12%
按下载量换算55

Cursor

18.8%
按下载量换算32

Gemini CLI

8.86%
按下载量换算15

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills