Skills

Write Swift

How to write modern Swift well, modeling with value types, Swift 6 data-race safety...

Install

npx skills add emilkowalski/skills --skill write-swift -g -a claude-code -y
Repository
emilkowalski/skills52.7k
Category
Design
Updated
7d ago
License
MIT
Context cost
Mediumabout 3,000 tokens
Runs scripts
No, instructions only

What it does

How to write modern Swift well, modeling with value types, Swift 6 data-race safety and approachable concurrency (@concurrent, main-actor-by-default, actors, task groups), protocols and generics (some vs any), API design, performance and ARC, Swift Testing, macros, and the modern language features agents don't know about yet. Use when writing, reviewing, or migrating Swift, or when a concurrency error, a hang, a data race, a retain cycle, or a performance problem needs fixing.

Write Swift

Initial Response

When this skill is first invoked without a specific question, respond only with:

I'm ready to help you write modern Swift, the way the language wants to be written.

Do not provide any other information until the user asks a question.

How to write Swift the way the language wants to be written, current through Swift 6.4.

Toolchain baseline: Swift 6.3 (current release as of August 2026). Everything here compiles on 6.3 unless marked ⚠, which flags unreleased Swift 6.4 features. Concurrency guidance assumes the Swift 6.2 model, if the project is on 6.1 or earlier, §3's rules about async and @concurrent do not apply.

The through-line: Swift is a progressive-disclosure language. Start with the simplest, most static, most single-threaded thing that works, and buy dynamism, concurrency, reference semantics, existentials, unsafe pointers, only where you can point at the reason. Every rule below is an application of that.

Model this hierarchy of defaults. Move down a level only with a reason you can state:

NeedReach forMove down only when
Datastruct / enumyou need identity, sharing, or inheritance
Abstractionconcrete typeyou have repeated code across types
Polymorphismsome P (generic)you need heterogeneous storage → any P
Executionmain actor, synchronousprofiling shows a hang → async → @concurrent → actor
MemoryArray, Stringprofiling shows the cost → InlineArray, Span
Safetysafe APIC interop or a measured hot path → Unsafe*

1. Model data with value types

Read the whole SKILL.md on GitHub

More in Design