write-swift

Guides writing, reviewing, and migrating modern Swift code with Swift 6 concurrency and value-type modeling.

Updated Sep 7, 2026
One-click install
npx skills add https://github.com/raphaelmans/spectralpointengineering --skill write-swift-raphaelmans
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-swift
Source: https://github.com/raphaelmans/spectralpointengineering/tree/main/.skillshare/skills/write-swift
Command: npx skills add https://github.com/raphaelmans/spectralpointengineering --skill write-swift-raphaelmans

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Swift's concurrency model changed significantly in Swift 6.2, and most codebases and AI agents still apply outdated patterns, leading to data races, hangs, retain cycles, and performance regressions. This Skill provides current, opinionated guidance for writing idiomatic Swift through Swift 6.3/6.4. ## Core Features & Use Cases - Swift 6 Concurrency Guidance: Covers the main-actor-by-default model, @concurrent, actors, Sendable checking, structured concurrency, and a step-by-step fix list for data-race errors. - Idiomatic Language Patterns: Value-type modeling, copy-on-write, some vs any generics, error handling, ARC and object lifetime, API design, and performance measurement with Instruments. - Modern Tooling Coverage: Swift Testing (replacing XCTest), macros, property wrappers, and new Swift 6.2-6.4 features like InlineArray, Span, and noncopyable types. - Use Case: When migrating a Swift 5 codebase to Swift 6 strict concurrency and hitting hundreds of sendability errors, use this Skill to apply the ordered fix strategy: don't share, make it a Sendable value type, isolate to an actor, then reach for Mutex only as a last resort. ## Quick Start Review this Swift file and fix any data-race or concurrency issues using Swift 6 best practices.

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 strict concurrency?

Work down an ordered list: first don't share 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 as a last resort use Mutex or @unchecked Sendable. Most real errors are fixed by the first step.

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 default for library APIs so callers decide where work runs.

When should I use some vs any in Swift generics?

Write some P by default since it preserves type relationships and enables compiler specialization. Switch to any P only when you need heterogeneous storage, optionality of the underlying type, or full type erasure, accepting the runtime cost of dynamic dispatch.

Should I use Swift Testing or XCTest for new tests?

Use Swift Testing for new tests; XCTest remains required only for UI automation with XCUIApplication, performance metrics with XCTMetric, and Objective-C tests. Both frameworks coexist in one target, so you can migrate incrementally.

Why does my Swift actor code still have race conditions?

Actors guarantee mutual exclusion, not transactions, and await is a suspension point where other work runs. Mutate actor state in synchronous methods, keep async methods thin, and re-check assumptions after every await to avoid check-then-act bugs.

When should I not add concurrency to Swift code?

Stay single-threaded on the main actor until profiling with Instruments shows a hang. Don't spawn tasks for trivial work, don't make functions async that have nothing to await, and always try algorithmic optimizations before adding concurrency.