- Home
- Skills
- Rshankras
- Claude Code Apple Skills
- Concurrency
concurrency_skill
- Swift
56
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill rshankras/claude-code-apple-skills --skill concurrency- SKILL.md19.9 KB
Overview
This skill explains Swift 6.2 concurrency updates focused on approachable concurrency: default MainActor inference, @concurrent for explicit background execution, isolated conformances, and migration tips. It helps developers adopt Swift 6.2 safely and resolve common data-race or conformance errors when moving from Swift 6.0/6.1. Use it as a practical guide to enable the new defaults and pick the right isolation and scheduling primitives.
How this skill works
The skill inspects your concurrency intent and explains how Swift 6.2 changes execution and isolation rules: async functions now stay on the caller's actor, the build setting can make declarations implicitly @MainActor, @concurrent marks functions to run on the background pool, and protocol conformances can be isolated to an actor. It highlights when to add nonisolated, when to mark methods @concurrent, and when isolated conformances are required.
When to use it
- Adopting Swift 6.2 or migrating from Swift 6.0/6.1
- Resolving data-race compiler errors caused by implicit executor hops
- Enabling default MainActor inference for app or executable targets
- Offloading CPU-heavy or blocking work safely using @concurrent
- Fixing protocol conformance errors with actor-isolated types
Best practices
- Enable default MainActor inference for app or script targets, but avoid it for libraries or plugins
- Use nonisolated for types/functions that must run off MainActor and audit those explicitly
- Reserve @concurrent for measured, CPU-bound or blocking operations only
- Prefer @concurrent over Task.detached for structured background work when a single function needs parallelism
- Use isolated conformances (e.g., extension Type: @MainActor Protocol) to fix cross-isolation protocol errors safely
Example use cases
- Remove noisy @MainActor annotations across a UI-driven app by enabling default MainActor inference
- Keep an async helper on the caller actor to avoid data races without code changes
- Mark a heavy image-processing function @concurrent to run on the background thread pool
- Make a UI model conform to a protocol using an isolated conformance to avoid compiler errors
- Audit and mark network parsers or file I/O utilities nonisolated and @concurrent when appropriate
FAQ
Enable it for app or executable targets where most code belongs on the main thread; avoid enabling it for libraries or plugins that must remain isolation-agnostic.
How is @concurrent different from Task.detached?
@concurrent declares a single async function to run on the background thread pool while remaining structured and inheriting task context; Task.detached creates an unstructured, fully detached task without parent context.