Community程式設計與開發github.com

steipete/swift-concurrency-expert

Swift 並發審查/修正:編譯器錯誤、Sendable、隔離、修復方案。

swift-concurrency-expert 是什麼?

這個技能專為 Swift 6.2+ 專案設計,旨在自動化審查與修復 Swift 並發問題。它能自動捕捉編譯器診斷訊息,識別並發符號,並套用最小的安全修復方案,例如添加 @MainActor 註解、讓協定遵循隔離、或將全域狀態移入 actor。此技能支援所有 Swift 6.2 以上的程式碼庫,無論是 UIKit/SwiftUI 的 UI 繫結程式碼,還是非同步後台任務。其運作原理是先對問題進行分類(分級),然後選擇最不影響現有行為的修復方式,避免使用 @unchecked Sendable,除非確定執行緒安全。它非常適合團隊在啟用嚴格並發檢查時,減少手動審查時間並避免常見的資料競爭錯誤。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/steipete/agent-scripts/tree/main/skills/swift-concurrency-expert

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Swift 並發專家

歸屬:改編自 @Dimillian 的 Dimillian/Skills(2025-12-31)。

概述

審查並修正 Swift 6.2+ 程式碼庫中的 Swift 並發問題,透過套用 actor 隔離、Sendable 安全性及現代並發模式,同時將行為變更降至最低。

工作流程

1. 問題分類

  • 擷取確切的編譯器診斷訊息與有問題的符號。
  • 識別當前的 actor 上下文(@MainActor、actor、nonisolated),並確認是否啟用了預設 actor 隔離模式。
  • 確認程式碼是 UI 繫結還是預設在主 actor 之外執行。

2. 套用最小的安全修復

偏好能保留現有行為同時滿足資料競爭安全性的編輯。

常見修復方式:

  • UI 繫結型別:為型別或相關成員加上 @MainActor 註解。
  • 主 actor 型別上的協定遵循:讓遵循行為隔離(例如 extension Foo: @MainActor SomeProtocol)。
  • 全域/靜態狀態:以 @MainActor 保護或移入 actor。
  • 後台工作:將耗時工作移至 nonisolated 型別上的 @concurrent 非同步函式,或使用 actor 保護可變狀態。
  • Sendable 錯誤:偏好不可變/值型別;只有在正確時才添加 Sendable 遵循;除非能證明執行緒安全,否則避免使用 @unchecked Sendable。

參考資料

  • 參閱 references/swift-6-2-concurrency.md 了解 Swift 6.2 的變更、模式與範例。
  • 參閱 references/swiftui-concurrency-tour-wwdc.md 了解 SwiftUI 特定的並發指引。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

steipete/agent-transcript

GitHub PR/issue agent transcripts: redact, preview, and insert safely.

steipete/beeper

Beeper cache: contact hints, room lookup, WhatsApp/iMessage traces, FTS.

steipete/browser-use

Existing Chrome automation: Chrome plugin first, mcporter fallback.

steipete/clawsweeper-status

ClawSweeper status: URLs, workflow health, active workers, ops snapshot.

steipete/clickclack

ClickClack ops: chat app, Hetzner deploy, DNS/docs/app, Docker rollout.

steipete/cloudflare-registrar

Cloudflare Registrar: domain availability, prices, registration via mcporter.

steipete/codex-debugging

Codex debugging: codex-rs core/tui/exec/cli/app-server/config.

steipete/create-cli

CLI UX/spec: args, flags, help, output, errors, config, dry-run.

steipete/discord-clawd

Discord-backed OpenClaw agent/session relay; not archive search.

steipete/domain-dns-ops

DNS/domain ops: registrars, zones, redirects, DNS/HTTP verify, manager truth.

steipete/frontend-design

Frontend UI: pages, apps, components, polished non-generic design.

steipete/github-author-context

GitHub contributor context: identity, activity, trust, company/team signal.

steipete/github-cache-hygiene

GitHub quota/cache hygiene: gh, ghx, xcache, gitcrawl, mirrors, limits.

steipete/github-deep-review

GitHub deep review: bugs, PRs, best fix, stale-or-real, read code first.

steipete/github-project-triage

GitHub issue/PR triage: queues, CI, blockers, risk, proof, next actions.

steipete/hopper-debugger

Hopper debugging: macOS/iOS binaries, ObjC/Swift symbols, dyld, LLDB.

steipete/instruments-profiling

Instruments/xctrace profiling: macOS/iOS traces, binaries, args, exports.

steipete/mac-maintenance

Mac upkeep: brew update/upgrade, pull clean repos, empty Trash.

steipete/maintainer-orchestrator

Open-source maintainer orchestration: Codex app workers, work recovery, dependencies, vision, releases.

steipete/markdown-converter

Markdown conversion: PDF, Office, HTML, data, OCR, audio, ZIP, YouTube.

相關技能