本文へ移動
cccskills
無料GitHub で公開日本語紹介

swift-concurrency-pro

Swiftの非同期・並行処理をレビューし、共有データの扱い、タスクの構成、キャンセルなどを点検。問題箇所と修正前後のコード、対応の優先順位を示します。

原文原文の説明を見る

Reviews Swift code for concurrency correctness, modern API usage, and common async/await pitfalls. Use when reading, writing, or reviewing Swift concurrency code.

インストール方法を見る

こんなときに便利

  • actorと共有データの扱いを確認
  • タスク構成とキャンセル処理の点検
  • 厳格な並行処理チェックのエラー調査
  • 従来の非同期APIからの移行レビュー

日本語での紹介

できること

Swiftの非同期・並行処理を読み、複数の処理が進む際のデータの扱いや、async/awaitの使い方を点検します。共有データへのアクセスを管理するactor、タスクの構成、キャンセルの伝播、非同期ストリーム、従来のAPIとの接続が対象です。実際の問題をファイルと行番号ごとに示し、修正前後の短いコードと対応の優先順位をまとめます。

こんなときに便利

非同期処理を新しく書くときや、既存コードの不具合を調べるときに向いています。厳格な並行処理チェックで出たコンパイラーエラーの修正、GCDや完了ハンドラーを使うコードの移行、非同期テストのレビューにも使えます。複数のターゲットやパッケージがある場合は、並行処理に関するビルド設定の違いも確認します。

使い方の例

  • 「このactorで、awaitの前後に状態が変わる問題がないか確認して」
  • 「タスクの構成とキャンセル処理をレビューして」
  • 「厳格な並行処理チェックのエラーに修正案を出して」

注意点

Swift 6.2以降と厳格な並行処理チェックを前提とします。サードパーティー製の並行処理フレームワークを追加する前には確認を求めます。ライセンスはMITです。

この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。

含まれるファイル(16)

  • SKILL.md5.4 KB
  • agents/openai.yaml380 B
  • assets/swift-concurrency-pro-icon.png2.7 KB
  • assets/swift-concurrency-pro-icon.svg1.5 KB
  • references/actors.md5.4 KB
  • references/async-streams.md2.1 KB
  • references/bridging.md2.9 KB
  • references/bug-patterns.md4.1 KB
  • references/cancellation.md3.6 KB
  • references/diagnostics.md4.4 KB
  • references/hotspots.md2.3 KB
  • references/interop.md3.6 KB
  • references/new-features.md7.7 KB
  • references/structured.md3.0 KB
  • references/testing.md8.1 KB
  • references/unstructured.md2.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Review Swift concurrency code for correctness, modern API usage, and adherence to project conventions. Report only genuine problems - do not nitpick or invent issues.

Review process:

  1. Scan for known-dangerous patterns using references/hotspots.md to prioritize what to inspect.
  2. Check for recent Swift 6.2 concurrency behavior using references/new-features.md.
  3. Validate actor usage for reentrancy and isolation correctness using references/actors.md.
  4. Ensure structured concurrency is preferred over unstructured where appropriate using references/structured.md.
  5. Check unstructured task usage for correctness using references/unstructured.md.
  6. Verify cancellation is handled correctly using references/cancellation.md.
  7. Validate async stream and continuation usage using references/async-streams.md.
  8. Check bridging code between sync and async worlds using references/bridging.md.
  9. Review any legacy concurrency migrations using references/interop.md.
  10. Cross-check against common failure modes using references/bug-patterns.md.
  11. If the project has strict-concurrency errors, map diagnostics to fixes using references/diagnostics.md.
  12. If reviewing tests, check async test patterns using references/testing.md.

If doing a partial review, load only the relevant reference files.

Core Instructions

  • Target Swift 6.2 or later with strict concurrency checking.
  • If code spans multiple targets or packages, compare their concurrency build settings before assuming behavior should match.
  • Prefer structured concurrency (task groups) over unstructured (Task {}).
  • Prefer Swift concurrency over Grand Central Dispatch for new code. GCD is still acceptable in low-level code, framework interop, or performance-critical synchronous work where queues and locks are the right tool – don't flag these as errors.
  • If an API offers both async/await and closure-based variants, always prefer async/await.
  • Do not introduce third-party concurrency frameworks without asking first.
  • Do not suggest @unchecked Sendable to fix compiler errors. It silences the diagnostic without fixing the underlying race. Prefer actors, value types, or sending parameters instead. The only legitimate use is for types with internal locking that are provably thread-safe.

Output Format

Organize findings by file. For each issue:

  1. State the file and relevant line(s).
  2. Name the rule being violated.
  3. Show a brief before/after code fix.

Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.

Example output:

DataLoader.swift

Line 18: Actor reentrancy – state may have changed across the await.

// Before
actor Cache {
    var items: [String: Data] = [:]

    func fetch(_ key: String) async throws -> Data {
        if items[key] == nil {
            items[key] = try await download(key)
        }
        return items[key]!
    }
}

// After
actor Cache {
    var items: [String: Data] = [:]

    func fetch(_ key: String) async throws -> Data {
        if let existing = items[key] { return existing }
        let data = try await download(key)
        items[key] = data
        return data
    }
}

Line 34: Use withTaskGroup instead of creating tasks in a loop.

// Before
for url in urls {
    Task { try await fetch(url) }
}

// After
try await withThrowingTaskGroup(of: Data.self) { group in
    for url in urls {
        group.addTask { try await fetch(url) }
    }

    for try await result in group {
        process(result)
    }
}

Summary

  1. Correctness (high): Actor reentrancy bug on line 18 may cause duplicate downloads and a force-unwrap crash.
  2. Structure (medium): Unstructured tasks in loop on line 34 lose cancellation propagation.

End of example.

References

  • references/hotspots.md - Grep targets for code review: known-dangerous patterns and what to check for each.
  • references/new-features.md - Swift 6.2 changes that alter review advice: default actor isolation, isolated conformances, caller-actor async behavior, @concurrent, Task.immediate, task naming, and priority escalation.
  • references/actors.md - Actor reentrancy, shared-state annotations, global actor inference, and isolation patterns.
  • references/structured.md - Task groups over loops, discarding task groups, concurrency limits.
  • references/unstructured.md - Task vs Task.detached, when Task {} is a code smell.
  • references/cancellation.md - Cancellation propagation, cooperative checking, broken cancellation patterns.
  • references/async-streams.md - AsyncStream factory, continuation lifecycle, back-pressure.
  • references/bridging.md - Checked continuations, wrapping legacy APIs, @unchecked Sendable.
  • references/interop.md - Migrating from GCD, Mutex/locks, completion handlers, delegates, and Combine.
  • references/bug-patterns.md - Common concurrency failure modes and their fixes.
  • references/diagnostics.md - Strict-concurrency compiler errors, protocol conformance fixes, and likely remedies.
  • references/testing.md - Async test strategy with Swift Testing, race detection, avoiding timing-based tests.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

app-store-review

無料概要あり

AppleのApp Store審査ガイドラインに沿ってアプリのコードを点検します。課金や個人情報、ログインなどを確認し、申請前に却下につながり得る問題を洗い出します。

  • App Store申請前の点検
  • 課金やサブスクリプションの確認
  • 個人情報とアカウント削除の確認
jacklandrin/OnlySwitch6,0042026年10月21日 更新

onlyswitch-deeplink

無料概要あり

自然な言葉で頼んだ操作をOnlySwitchの内蔵機能に対応付けて実行します。macOSでスリープ防止やダークモードの切り替え、ごみ箱の消去などを呼び出せます。

  • スリープ防止を切り替えたいとき
  • ダークモードを切り替えたいとき
  • ごみ箱を空にしたいとき
jacklandrin/OnlySwitch6,0042026年10月21日 更新

swift-testing-pro

無料概要あり

Swift Testingを使う単体・結合テストの作成とレビューを支援します。非同期処理や検証方法を点検し、XCTestからの移行にも対応します。

  • 単体・結合テストを作成したいとき
  • 非同期処理のテストを点検したいとき
  • XCTestから移行したいとき
jacklandrin/OnlySwitch6,0042026年10月21日 更新

swiftui-pro

無料概要あり

SwiftUIのコードを読み、古いAPIやデータの受け渡し、画面構成、操作のしやすさ、性能を点検。問題のある箇所と修正前後のコードをファイル別に示します。

  • 既存のSwiftUIコードをレビュー
  • 非推奨APIを更新したいとき
  • 読み上げや文字サイズへの対応確認
jacklandrin/OnlySwitch6,0042026年10月21日 更新

writing-plans

無料概要あり

仕様や要件を、変更ファイル・実装コード・テスト手順まで含む実装計画にまとめます。作業を小さく分け、コードを書き始める前の準備や引き継ぎに使えます。

  • 実装前に開発計画を立てたいとき
  • 開発作業の引き継ぎ
  • 要件を検証可能なタスクに分けたいとき
jacklandrin/OnlySwitch6,0042026年10月21日 更新

jacklandrin のスキルをすべて見る

このスキルの問題を報告する