write-swift

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

Updated Aug 29, 2026
One-click install
npx skills add https://github.com/Seyamalam/pstu_final --skill write-swift-seyamalam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-swift
Source: https://github.com/Seyamalam/pstu_final/tree/main/.agents/skills/write-swift
Command: npx skills add https://github.com/Seyamalam/pstu_final --skill write-swift-seyamalam

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Swift's concurrency model changed significantly in Swift 6.2, and most guidance and training data still reflects outdated patterns, leading to data races, hangs, retain cycles, and misused actors. This Skill provides current, opinionated rules for writing idiomatic Swift through Swift 6.3/6.4. ## Core Features & Use Cases - Modern Concurrency Guidance: Covers the Swift 6.2 model where async no longer switches actors, plus @concurrent, nonisolated, actors, task groups, and Sendable diagnostics. - Value-Type Modeling & API Design: Rules for structs vs classes, copy-on-write, noncopyable types, some vs any, protocols, and generics. - Performance, ARC, and Testing: Concrete levers like InlineArray, Span, and final, plus Swift Testing patterns with @Test, #expect, and parameterized tests. - Use Case: When a data-race error appears after migrating to Swift 6, use this Skill to work down the fix hierarchy: stop sharing, make it a Sendable value type, isolate to an actor, then reach for Mutex. ## Quick Start Ask the assistant to review your Swift file for Swift 6 concurrency correctness and idiomatic value-type design.

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?

Work down a hierarchy: 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 then use Mutex or @unchecked Sendable. Most real errors are fixed at step one.

Does marking a function async move it off the main actor in Swift 6.2?

No. In Swift 6.2 an async function runs on the caller's actor by default. Use @concurrent to guarantee execution on the background thread pool, or nonisolated to let the caller decide, which is the right default for library APIs.

When should I use some versus any in Swift?

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

Should I use Swift Testing or XCTest for new tests?

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

Why does my 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.