Apple & iOS
AuraScore 81/100

Swift Concurrency and Actor Isolation Migration Specification

Design a technical specification to migrate legacy Grand Central Dispatch codebases to modern Swift structured concurrency.

Use this template when refactoring legacy multi-threaded iOS modules into Swift async/await and Actor-isolated pipelines. It guarantees safety against data races while satisfying strict deployment targets.

Template

Role: Staff iOS Systems Architect specializing in Swift runtime internals and thread sanitization.

Context

  • Target Application: {{app_name}}
  • Refactored Module: {{target_module}}
  • Current Concurrency Pattern: {{concurrency_model_current}}
  • Critical Thread-Safety Hazards: {{thread_safety_risks}}
  • Minimum Target OS: {{minimum_ios_version}}
  • Performance and Latency Budgets: {{performance_targets}}

Task

Produce an exhaustive engineering technical specification for transitioning {{target_module}} in {{app_name}} from {{concurrency_model_current}} to Swift 6 structured concurrency and actors, resolving {{thread_safety_risks}} without exceeding {{performance_targets}}.

Method

  1. Map all mutable shared state across {{target_module}} and evaluate actor boundary isolation requirements.
  2. Identify callback-based APIs and define async/await signature replacements with appropriate task cancellation propagation.
  3. Design GlobalActor or dedicated actor boundaries to mitigate {{thread_safety_risks}} while avoiding MainActor contention.
  4. Define TaskGroup execution strategies for parallel asynchronous operations aligned with {{performance_targets}}.
  5. Audit bridging mechanisms between legacy completion handlers and async/await using CheckedContinuation safeguards.
  6. Formulate compiler flag strategies for Swift 6 complete concurrency checking compatibility on {{minimum_ios_version}}.
  7. Detail thread sanitization validation routines, XCTest asynchronous assertions, and performance profiling runs.

Constraints

  • MUST maintain strict backward deployment compatibility with {{minimum_ios_version}}.
  • MUST NOT leave unchecked continuations that risk thread starvation or memory leaks.
  • All async API contracts must implement explicit cooperative cancellation checks.
  • Specification must provide concrete Swift code signatures for critical domain models.

Output format

Provide the specification in four structured markdown sections:

  1. Architecture Overview (Actor isolation boundaries and state lifecycle diagram/table)
  2. Concurrency Interface Signatures (Typed Swift signatures and error-handling paradigms)
  3. Task Lifecycle and Cancellation Strategy (Propagation flow and continuation safety rules)
  4. Verification and Benchmark Plan (Instruments profiling steps and Thread Sanitizer test suite) Total document length must remain between 400 and 700 words.

Self-review

  • Verify all variables ({{app_name}}, {{target_module}}, {{concurrency_model_current}}, {{thread_safety_risks}}, {{minimum_ios_version}}, {{performance_targets}}) are addressed.
  • Confirm no usage of deprecated DispatchGroup or lock primitives in proposed Swift signatures.
  • Ensure exact compliance with the four specified section headers.
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 engineering12/12 · Strong

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.

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