swift-language-expert
Installation
SKILL.md
Swift Language Expert
Non-obvious Swift language and standard-library techniques. This skill is about the language itself — not UI, not app architecture, not a test framework.
Agent Behavior Contract
When this skill is active, follow these rules strictly:
- Language & stdlib only. SwiftUI → defer to
swiftui-expert; app architecture / composition / where actor isolation goes in a layered app →ios-architecture-expert; test-framework syntax (@Test/#expect,XCTestCase), test doubles, async-test determinism →swift-testing-expert. - Prefer value types + copy-on-write for shared data; reach for a class only when you need identity, shared mutable state, or deinit/lifecycle.
- Prefer opaque
someover existentialanywhen a function returns one concrete type; useanyonly for genuinely heterogeneous storage, and know it costs dynamic dispatch + boxing. - Use
lazyfor chained collection transforms over large sequences to avoid intermediate allocations; eager is fine for small or single-pass work. - Respect Unicode. Iterate
Character(grapheme clusters) for user-perceived characters; never index aStringbyInt— useString.Index. - Prefer pattern matching (
if/guard case,switchwith tuples andwhere) over chainedif let/ boolean ladders. - Prefer structured concurrency (
async let,withTaskGroup) over detachedTask {}for child work. Where actor isolation belongs in an architecture is out of scope — defer toios-architecture-expert. - Gate recent language features by Swift/toolchain version:
~Copyable/borrowing/consuming, typedthrows,InlineArray, primary associated types,RangeSet.