Apple & iOS
AuraScore 81/100

Swift Structured Concurrency Migration Framework

Assess legacy GCD patterns and construct a safe migration framework for Swift 6 structured concurrency.

Use this template when refactoring legacy multithreaded iOS codebases into Swift async/await, actors, and Sendable models. It helps engineering leads eliminate data races while preserving throughput.

Template

Role: Principal iOS Systems Engineer with expertise in Swift 6 concurrency, runtime memory safety, and thread sanitization.

Context

  • Target Application: {{app_name}}
  • Minimum Supported iOS Version: {{target_ios_version}}
  • Legacy Dispatch Strategy: {{legacy_concurrency_pattern}}
  • Critical Core Subsystem: {{critical_subsystem}}
  • Diagnostics and Tooling: {{thread_safety_tooling}}
  • Latency and Throughput Budget: {{performance_budget_ms}}

Task

Produce an actionable, phased migration framework that transitions {{critical_subsystem}} from {{legacy_concurrency_pattern}} to modern Swift structured concurrency without introducing deadlocks, thread explosion, or breaking changes in {{app_name}}.

Method

  1. Analyze the existing {{legacy_concurrency_pattern}} in {{critical_subsystem}} to identify state mutations across thread boundaries.
  2. Classify mutable state boundaries into @MainActor, custom Global Actors, or isolated Actor domains targeting {{target_ios_version}}.
  3. Identify non-isolated class boundaries requiring conversion to value types or explicit Sendable conformance.
  4. Design continuation bridges (withCheckedThrowingContinuation) for legacy completion handlers that cannot be rewritten immediately.
  5. Map out structured task trees (TaskGroup vs unstructured Task) to maintain deterministic cancellation semantics.
  6. Evaluate actor reentrancy risks across suspension points to prevent intermediate invalid state reads.
  7. Formulate a verification protocol using {{thread_safety_tooling}} to validate race condition elimination under {{performance_budget_ms}}.

Constraints

  • MUST maintain strict compiler complete concurrency checking without disabling runtime safety flags.
  • MUST NOT introduce unbounded Task creation inside tight loops that risk thread pool exhaustion.
  • MUST isolate all UI-bound event handlers and UI binding pipelines to @MainActor.
  • Provide concrete Swift code signatures for critical architectural boundaries rather than abstract placeholders.

Output format

  • Section 1: Architecture State Boundary Map (table format comparing Legacy Pattern to Swift 6 Target)
  • Section 2: Actor Isolation & Sendability Contract (structural Swift pseudo-code or interface blueprints)
  • Section 3: Phased Rollout Plan (3 execution phases with clear entry and exit criteria)
  • Section 4: Diagnostics & Regression Protocol (bulleted list of validation commands and {{thread_safety_tooling}} steps)
  • Total length: 450-800 words.

Self-review

  • Confirm all 6 context variables are actively integrated in the reasoning steps.
  • Verify that actor reentrancy edge cases are explicitly addressed in the isolation contract.
  • Ensure strict adherence to the named sections and word limits.
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 efficiency5/10 · Thin

Signal density — instruction weight without padding.

Reusability7/7 · Strong

Documented variables so the scaffold adapts to new inputs.

Robustness5/5 · Strong

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
ios
swift
concurrency