/mobile-plugin:swift-concurrencyfrom mobile-plugin
Swift Concurrency支援。async/await、Actor、Sendable、データ競合防止。使用タイミング: (1) 並行処理コードの実装時、(2) Swift 6 Strict Concurrency対応時、(3) データ競合の診断・修正時、(4) MainActorとバックグラウンド処理の設計時
Ships in mobile-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Swift Concurrencyの正しい使用法とデータ競合防止をガイドする。
// ✅ 値型は自動的にSendable
struct UserData: Sendable {
let id: UUID
let name: String
}
// ✅ Actorは暗黙的にSendable
actor DataManager {
private var cache: [String: Data] = [:]
func getData(for key: String) -> Data? {
cache[key]
}
}
// ⚠️ クラスは明示的な対応が必要
// 方法1: @unchecked Sendable(内部で同期を保証している場合のみ使用)
final class ThreadSafeCache: @unchecked Sendable {
private let lock = NSLock()
private var storage: [String: Any] = [:]
func get(_ key: String) -> Any? {
lock.withLock { storage[key] }
}
}
// 方法2: 不変クラス
final class ImmutableConfig: Sendable {
let apiURL: URL
let timeout: TimeInterval
init(apiURL: URL, timeout: TimeInterval) {
self.apiURL = apiURL
self.timeout = timeout
}
}
// グローバルActor定義
@globalActor
actor DatabaseActor {
static let shared = DatabaseActor()
}
// Actor隔離されたクラス
@DatabaseActor
class DatabaseService {
private var connection: DatabaseConnection?
func query(_ sql: String) async throws -> [Row] {
// DatabaseActor上で実行される
guard let conn = connection else {
throw DatabaseError.notConnected
}
return try await conn.execute(sql)
}
}
// MainActorへの切り替え
@DatabaseActor
class ViewModel {
private var data: [Item] = []
func loadData() async {
let items = try? await fetchItems()
// UI更新はMainActorで
await MainActor.run {
self.updateUI(with: items ?? [])
}
}
@MainActor
private func updateUI(with items: [Item]) {
// UI更新処理
}
}
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")
// または
.swiftLanguageMode(.v6)
]
SWIFT_STRICT_CONCURRENCY = complete(コンパイラフラグとしては -strict-concurrency=complete).enableUpcomingFeature("StrictConcurrency") で警告のみ有効化swiftLanguageMode: .v6 でアプリ全体をSwift 6モードへclass SearchViewModel: ObservableObject {
@Published var results: [SearchResult] = []
@Published var isSearching = false
private var searchTask: Task<Void, Never>?
func search(query: String) {
// 前の検索をキャンセル
searchTask?.cancel()
searchTask = Task {
await MainActor.run {
isSearching = true
}
// デバウンス
try? await Task.sleep(for: .milliseconds(300))
// キャンセルチェック
guard !Task.isCancelled else { return }
do {
let results = try await performSearch(query)
guard !Task.isCancelled else { return }
await MainActor.run {
self.results = results
self.isSearching = false
}
} catch {
guard !Task.isCancelled else { return }
await MainActor.run {
self.isSearching = false
}
}
}
}
deinit {
searchTask?.cancel()
}
}
actor BankAccount {
var balance: Int = 0
// ⚠️ awaitの前後でbalanceが変わる可能性
func transferTo(_ other: BankAccount, amount: Int) async {
guard balance >= amount else { return }
balance -= amount // ここで中断
await other.deposit(amount) // 他のタスクがbalanceを変更可能
// 戻ってきた時、想定外の状態かも
}
// ✅ トランザクション的に処理
func withdraw(_ amount: Int) -> Bool {
guard balance >= amount else { return false }
balance -= amount
return true
}
func deposit(_ amount: Int) {
balance += amount
}
}
// 呼び出し側で制御
func transfer(from: BankAccount, to: BankAccount, amount: Int) async {
let withdrawn = await from.withdraw(amount)
if withdrawn {
await to.deposit(amount)
}
}
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub caphtech/claude-marketplace --plugin mobile-plugin10 skills in this plugin
/flutter-widget-splittingFlutter Widgetの肥大化を、責務分離・共通化・Riverpod境界の整理でリファクタリングする。build()が長い、Widgetを分割したい、Riverpodのwatch/read/listen/select境界を見直したい、共通化したい、Flutter UIを整理したい時に使用。/ios-archiveアーカイブ・配布支援。App Store Connect、TestFlight、Ad Hoc/Enterprise配布。使用タイミング: (1) App Storeへの提出準備時、(2) TestFlight配布時、(3) Ad Hoc/Enterprise配布時、(4) CI/CDでの自動配布設定時/ios-ia-navigationiOSアプリの情報設計(IA)と画面遷移(ナビゲーション)を設計するスキル。Apple HIGとWWDCセッションに基づき、タブ/階層push/モーダルを情報階層とタスク構造から逆算して選定し、根拠と未確定事項を可視化しながら設計を完遂する。使用タイミング: (1) 新規アプリの情報設計時、(2) 画面遷移設計時、(3) 「IAを設計したい」「ナビゲーション構造を決めたい」、(4) iPad/iPhone両対応の構造設計時、(5) ディープリンク対応設計時、(6) 既存アプリのリファクタリング時Other plugins' skills for the same job