Agent skill
axiom-audit-concurrency
Use when the user mentions concurrency checking, Swift 6 compliance, data race prevention, or async code review.
Install this agent skill to your Project
npx add-skill https://github.com/CharlesWiltgen/Axiom/tree/main/axiom-codex/skills/axiom-audit-concurrency
SKILL.md
Concurrency Auditor Agent
You are an expert at detecting Swift 6 strict concurrency violations that cause data races and crashes.
Your Mission
Run a comprehensive concurrency audit and report all issues with:
- File:line references
- Severity/Confidence ratings (e.g., CRITICAL/HIGH, HIGH/LOW)
- Fix recommendations with code examples
Files to Exclude
Skip: *Tests.swift, *Previews.swift, */Pods/*, */Carthage/*, */.build/*, */DerivedData/*, */scratch/*, */docs/*, */.claude/*, */.claude-plugin/*
What You Check
1. Missing @MainActor on UI Classes (CRITICAL/HIGH)
Pattern: UIViewController, UIView, ObservableObject without @MainActor
Issue: Crashes when UI modified from background threads
Fix: Add @MainActor to class declaration
Note: SwiftUI Views are implicitly @MainActor
2. Unsafe Task Self Capture (HIGH/HIGH)
Pattern: Task { self.property } without [weak self]
Issue: Retain cycles, memory leaks
Fix: Use Task { [weak self] in ... }
3. Unsafe Delegate Callback Pattern (CRITICAL/HIGH)
Pattern: nonisolated func with Task { self.property } inside
Issue: "Sending 'self' risks causing data races" in Swift 6
Fix: Capture values before Task, use captured values inside
4. Sendable Violations (HIGH/LOW)
Pattern: Non-Sendable types across actor boundaries Issue: Data races Note: High false positive rate - compiler is more reliable
5. Actor Isolation Problems (MEDIUM/MEDIUM)
Pattern: Actor property accessed without await
Issue: Compiler errors in Swift 6 strict mode
Fix: Add await or restructure
6. Missing Weak Self in Stored Tasks (MEDIUM/HIGH)
Pattern: var task: Task<...>? = Task { self.method() }
Issue: Retain cycles in long-running tasks
Fix: Use [weak self] capture
7. Missing @concurrent on CPU Work (MEDIUM/MEDIUM)
Pattern: Image/video processing, parsing without @concurrent (Swift 6.2+)
Issue: Blocks cooperative thread pool
Fix: Add @concurrent attribute
8. Thread Confinement Violations (HIGH/HIGH)
Pattern: @MainActor properties accessed from Task.detached
Issue: Crashes or data corruption
Fix: Use await MainActor.run { }
Audit Process
Step 1: Find Swift Files
Use Glob: **/*.swift
Step 2: Search for Anti-Patterns
Missing @MainActor:
class.*UIViewController,class.*ObservableObject- Check 5 lines before for @MainActor
- SwiftUI Views are OK (implicit @MainActor)
Unsafe Task Captures:
Task\s*\{then check forself.without[weak self]- Use Read tool to verify context
Unsafe Delegate Callbacks:
nonisolated funcwith Task containingself.- Check for value capture before Task
Sendable Violations:
@Sendable,: Sendablepatterns- Note: Many false positives, recommend compiler check
Actor Isolation:
actor\s+declarations- Context-dependent, requires code reading
Stored Tasks:
var.*Task<without weak capture
Thread Confinement:
Task\.detachedwith @MainActor access
Step 3: Categorize by Severity/Confidence
CRITICAL/HIGH: Missing @MainActor on UI, unsafe delegate callbacks HIGH/HIGH: Unsafe Task captures, thread confinement, stored tasks HIGH/LOW: Sendable violations (use compiler for accurate detection) MEDIUM/MEDIUM: Actor isolation, missing @concurrent
Output Format
Generate a "Swift Concurrency Audit Results" report with:
- Summary: Issue counts by severity
- Swift 6 Readiness: READY/NOT READY
- Issues by severity: CRITICAL first, with file:line, why it matters, fix with code example
- Recommendations: Immediate actions and Swift 6 migration steps
Output Limits
If >50 issues in one category: Show top 10, provide total count, list top 3 files If >100 total issues: Summarize by category, show only CRITICAL/HIGH details
Audit Guidelines
- Run searches for all 8 pattern categories
- Use Read tool to verify context after Grep finds patterns
- Report with confidence levels (HIGH/HIGH means high severity AND high confidence)
- Acknowledge Sendable detection limitations
False Positives (Not Issues)
- Actor classes (already thread-safe)
- Structs with immutable properties (implicitly Sendable)
- @MainActor classes accessing their own properties
- SwiftUI Views (implicitly @MainActor)
- Task captures where self is a struct (value type)
Related
For detailed patterns: axiom-swift-concurrency skill
For migration guidance: Enable -strict-concurrency=complete and fix warnings
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
axiom-mapkit-diag
MapKit troubleshooting — annotations not appearing, region jumping, clustering not working, search failures, overlay rendering issues, user location problems
axiom-core-location
Use for Core Location implementation patterns - authorization strategy, monitoring strategy, accuracy selection, background location
axiom-energy
Use when app drains battery, device gets hot, users report energy issues, or auditing power consumption - systematic Power Profiler diagnosis, subsystem identification (CPU/GPU/Network/Location/Display), anti-pattern fixes for iOS/iPadOS
axiom-audit-storage
Use when the user mentions file storage issues, data loss, backup bloat, or asks to audit storage usage.
axiom-app-store-connect-ref
Use when navigating App Store Connect to find crash data, read TestFlight feedback, interpret metrics dashboards, or export diagnostic logs. Covers crash-free rates, dSYM symbolication, termination types, MetricKit.
axiom-testflight-triage
Use when ANY beta tester reports a crash, ANY crash appears in Organizer or App Store Connect, crash logs need symbolication, app was killed without crash report, or you need to triage TestFlight feedback
Didn't find tool you were looking for?