write-swift

Guides writing, reviewing, and migrating modern Swift code through Swift 6.4.

Updated Jul 14, 2026
One-click install
npx skills add https://github.com/quanthubbr/tron-claude-config --skill write-swift-quanthubbr
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: write-swift
Source: https://github.com/quanthubbr/tron-claude-config/tree/main/managed/skills/emilkowalski/write-swift
Command: npx skills add https://github.com/quanthubbr/tron-claude-config --skill write-swift-quanthubbr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Swift's concurrency model changed significantly in Swift 6.2, and most AI agents and developers still write outdated patterns that cause data races, hangs, retain cycles, and performance regressions. This Skill provides current, opinionated guidance for writing Swift the way the language intends, from value-type modeling to structured concurrency. ## Core Features & Use Cases - Modern Concurrency Guidance: Covers the Swift 6.2+ model including @concurrent, main-actor-by-default, actors, task groups, Sendable checking, and a step-by-step fix list for data-race errors. - Idiomatic Language Patterns: Explains value types vs classes, copy-on-write, some vs any, typed throws, noncopyable types, macros, and API design principles grounded in clarity at the point of use. - Performance and Testing: Details ARC lifetime rules, Instruments-driven profiling, InlineArray and Span, and Swift Testing with @Test, #expect, parameterized tests, and traits. - Use Case: When migrating a codebase to Swift 6 strict concurrency and hitting sendability errors, use this Skill to work down the resolution list: stop sharing the object, make it a Sendable value type, isolate it to an actor, then reach for Mutex only as a last resort. ## Quick Start Ask the AI to review your Swift file for Swift 6 concurrency issues and suggest fixes following modern language idioms.

Frequently Asked Questions about write-swift

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix data-race errors in Swift 6?▼

Fix Swift 6 data-race errors by working down a priority list: first stop sharing the object by giving each concurrent job its own instance, then make it a Sendable value type, then isolate it to an actor, and only finally use Mutex or @unchecked Sendable as a last resort.

What changed about async functions in Swift 6.2?▼

In Swift 6.2, marking a function async no longer moves it off the current actor; it runs where it was called from. Use @concurrent to guarantee background execution for CPU-heavy work and nonisolated as the right default for library APIs.

Should I use Swift Testing or XCTest for new tests?▼

Use Swift Testing for new tests by default. XCTest remains required only for UI automation with XCUIApplication, performance metrics with XCTMetric, and tests written in Objective-C or catching Objective-C exceptions.

When should I use some versus any in Swift?▼

Write some P by default since it preserves type relationships and enables compiler specialization. Change to any P only when you need heterogeneous storage, optionality of the underlying type, or to fully hide the abstraction behind a type-erased box.

Why does my Swift actor code still have race conditions?▼

Actors guarantee mutual exclusion, not transactions, so state can change between awaits due to reentrancy. Mutate actor state in synchronous methods, keep async methods thin, and re-check assumptions after every await, such as re-validating a cache after a download.

When should I avoid adding concurrency to Swift code?▼

Avoid concurrency until profiling with Instruments shows an actual hang, since task allocation and scheduling carry real costs. Start single-threaded on the main actor, add async only to hide latency, and never spawn tasks for trivial work like reading a UserDefaults value.