audit-swiftui-concurrency-safety

Audits macOS SwiftUI code for Swift concurrency isolation defects and data races.

2|1|Updated Jun 7, 2026
One-click install
npx skills add https://github.com/yigitkonur/plugin-swiftui --skill audit-swiftui-concurrency-safety-yigitkonur
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: audit-swiftui-concurrency-safety
Source: https://github.com/yigitkonur/plugin-swiftui/tree/main/plugins/swiftui/skills/audit-swiftui-concurrency-safety
Command: npx skills add https://github.com/yigitkonur/plugin-swiftui --skill audit-swiftui-concurrency-safety-yigitkonur

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ast-grep, and includes scripts (resource) and references (resource) components.

What problem does it solve? Swift concurrency rules changed twice in twelve months (Swift 6 strict checking, Swift 6.2 opt-in isolation modes), so AI-generated and legacy SwiftUI code often contains non-Sendable actor crossings, @Sendable closures touching main-actor state, DispatchQueue.main.async cargo-cults, and lifecycle-leaking Tasks that compile into latent data races. ## Core Features & Use Cases - Eleven-rule defect index (conc-01 to conc-11): Detects non-Sendable boundary crossings, @Sendable closure violations, GCD main-queue hops, bare Tasks in .onAppear, @MainActor spam, Swift 6.2 opt-in misreads, non-Sendable Transferable payloads, and off-context SwiftData mutations. - Hybrid lint engine: Runs tier-1 ripgrep tells plus tier-2 ast-grep structural rules (Task-in-onAppear containment, modelContext mutation inside Task.detached) emitting unified JSON and SARIF. - Era-aware verdicts: Reads the target's Swift language mode and default-isolation build setting before judging, and verifies uncertain facts against swift.org, Swift Evolution proposals, and a corpus of 1,857 shipping macOS apps. - Use Case: Point it at an in-progress macOS SwiftUI project to receive per-file findings with severity, isolation_kind, swift_era tags, consensus-shape fixes backed by real GitHub permalinks, and one auto-fix for DispatchQueue.main.async. ## Quick Start Audit the SwiftUI sources in this macOS project for Swift concurrency safety issues and write findings under swiftui-audits/concurrency-safety.

Frequently Asked Questions about audit-swiftui-concurrency-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit SwiftUI code for Swift concurrency data races?

Run the audit against your SwiftUI sources; it locates candidates with ripgrep tells and ast-grep structural rules, then reads each file in full to confirm isolation hazards. Confirmed findings are written per-file with severity, swift_era, and isolation_kind tags.

What concurrency defects does this SwiftUI audit detect?

It covers eleven defects: non-Sendable types crossing actors, @Sendable closures touching main-actor state, DispatchQueue.main.async cargo-cults, bare Tasks in .onAppear, @MainActor spam, Swift 6.2 opt-in misreads, non-Sendable Transferable payloads, and off-context SwiftData @Model mutations.

Does the audit handle Swift 6.2 default MainActor isolation?

Yes. It reads the target's build settings in the ORIENT step to determine whether the Swift 6 language mode or the opt-in -default-isolation MainActor mode is active, and gates Swift 6.2-only spellings like @concurrent and nonisolated(nonsending) as advisory until the toolchain is confirmed.

Can the audit automatically fix concurrency issues it finds?

Only one defect is auto-fixed: DispatchQueue.main.async in async code is rewritten to await MainActor.run or an @MainActor annotation under a fix-safety protocol. All other findings are flag-only, reported with a corpus-verified correct shape and a permalinked real-world example.

Why does a bare Task in .onAppear cause problems in SwiftUI?

A bare Task in .onAppear is not bound to the view's lifetime, so it is never cancelled on disappear and can leak or race a re-appearing view. The lifecycle-correct shape is .task or .task(id:), which auto-cancels and re-keys on input changes.