Apple & iOS
AuraScore 81/100

Swift Concurrency Migration and Data Race Analysis

Evaluate legacy threading code to identify data races, isolation breaks, and optimal Swift async/await actor architectures.

Deploy this analysis when modernizing legacy Grand Central Dispatch codebases to strict Swift 6 concurrency. It pinpoints concurrency warnings, non-Sendable leaks, and actor isolation boundaries.

Template

Role: Lead iOS Systems Architect specializing in Swift Concurrency, Sendable safety, and GCD-to-Async migration.

Context

  • Target subsystem name: {{subsystem_name}}
  • Existing threading logic: {{legacy_dispatch_logic}}
  • Project Swift language mode: {{swift_language_mode}}
  • Shared state properties: {{shared_mutable_state}}
  • Throughput and latency expectations: {{performance_criticality}}
  • External concurrency dependencies: {{third_party_dependencies}}

Task

Generate a rigorous concurrency analysis and actor-based migration architecture for {{subsystem_name}} that eliminates data races in {{shared_mutable_state}} while satisfying {{swift_language_mode}} strict checking requirements.

Method

  1. Audit {{legacy_dispatch_logic}} to pinpoint thread hops, locks, and manual queue synchronizations.
  2. Evaluate all types participating in {{shared_mutable_state}} for Sendable conformance and value-type safety.
  3. Analyze potential actor isolation crossings and non-isolated boundary leaks considering {{third_party_dependencies}}.
  4. Determine whether an Actor, GlobalActor (such as MainActor), or TaskGroup is required for {{subsystem_name}}.
  5. Model deadlocks, reentrancy vulnerabilities, and executor contention risks under {{performance_criticality}} constraints.
  6. Architect the modern Swift async/await replacement pattern to deprecate callback-based dispatch queues.
  7. Formulate a stepwise migration plan that preserves binary compatibility during rollout.

Constraints

  • MUST address Swift 6 strict concurrency checks explicitly for {{swift_language_mode}}.
  • MUST identify and solve actor reentrancy risks in asynchronous critical paths.
  • MUST NOT introduce arbitrary Task sleeps or unchecked Sendable workarounds.
  • Keep architectural changes scoped directly to the boundaries of {{subsystem_name}}.

Output format

  • Concurrency Risk Assessment (ranked list of current race conditions)
  • Actor Isolation Architecture Plan (actor definitions and boundary model)
  • Refactored Swift Concurrency Code (complete replacement implementation)
  • Actor Reentrancy & Deadlock Defense (technical risk mitigation review)
  • Migration & Testing Strategy (phased rollout with unit test examples)

Self-review

  • Are all shared mutable properties in {{shared_mutable_state}} protected by actors or Sendable guarantees?
  • Does the migration handle {{third_party_dependencies}} integration boundaries safely?
  • Did I verify actor reentrancy scenarios across suspension points?
AuraScore breakdown
81/100Provisional
Instruction clarity15/15 · Strong

Explicit role, a named task, and discrete steps the model can follow.

Context architecture12/12 · Strong

Background, inputs and variables the model needs before it starts.

Constraint engineering10/12 · Adequate

Hard boundaries — what the model must and must not do.

Output specification6/14 · Thin

A named, field-level shape for the response.

Reasoning structure10/10 · Strong

Ordered work items that force analysis before an answer.

Model compatibility10/10 · Strong

Length and structure that travel across frontier models.

Token efficiency7/10 · Adequate

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness3/5 · Adequate

Quality bar, assumptions and behaviour when inputs are thin.

Observed performance1/5 · Thin

How much real usage the template has behind it.

developers
developers-apple
software-engineering-debugging
swift
concurrency
actors