write-swift

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

Updated Aug 25, 2026
One-click install
npx skills add https://github.com/KlyrhonMiko/kly-skills --skill write-swift-klyrhonmiko
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: write-swift
Source: https://github.com/KlyrhonMiko/kly-skills/tree/main/data/skills/write-swift
Command: npx skills add https://github.com/KlyrhonMiko/kly-skills --skill write-swift-klyrhonmiko

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Swift's concurrency model, ownership rules, and language features changed significantly through Swift 6, and AI agents frequently produce outdated or data-race-prone code. This Skill provides current, opinionated guidance so generated Swift follows value-type modeling, Swift 6 data-race safety, and modern API design instead of legacy patterns. ## Core Features & Use Cases - Swift 6 Concurrency Guidance: Covers the Swift 6.2 approachable-concurrency model including @concurrent, main-actor-by-default, actors, task groups, Sendable checking, and structured concurrency. - Idiomatic Language Patterns: Explains value-type modeling, copy-on-write, noncopyable types, protocols and generics (some vs any), error handling, ARC lifetime rules, and performance optimization with InlineArray and Span. - Modern Tooling Coverage: Details Swift Testing, macros, Logger-based debugging, and API design principles current through Swift 6.4. - Use Case: When migrating a codebase to Swift 6 strict concurrency and hitting data-race errors, use this Skill to apply the ordered fix list: stop sharing state, use Sendable value types, isolate to an actor, then reach for Mutex only as a last resort. ## Quick Start Use the write-swift skill to review this Swift file for data-race safety and modernize its concurrency to the Swift 6.2 model.

Frequently Asked Questions about write-swift

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

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

Fix Swift 6 data-race errors by working down an ordered 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. Global and static variables are the most common source.

What changed in Swift 6.2 concurrency with async functions?▼

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 so callers decide where work runs.

When should I use some vs any in Swift protocols?▼

Write some P by default because it preserves type relationships and enables compiler specialization. Change to any P only when you need heterogeneous storage or optionality of the underlying type, accepting that associated-type relationships are erased and calls become opaque to the optimizer.

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

Use Swift Testing for new tests, since @Test, #expect, and parameterized arguments cover most needs with parallel execution by default. XCTest remains required only for UI automation with XCUIApplication, performance metrics with XCTMetric, and Objective-C exception handling.

When should Swift code use actors instead of classes?▼

Use an actor only when you need to move mutable state off the main actor after profiling shows excessive main-actor hops. Actors guarantee mutual exclusion but not transactions, so mutate state in synchronous methods and re-check assumptions after every await.