swift
БесплатноБез исполняемых скриптовНе проверенDesign, implement, and review Swift APIs and Apple-platform code. Use when working on .swift files, Swift types, Foundation or AVFoundation APIs…
от margelo★ 185 звёзд на GitHubОб этом скилле
Swift
Use this skill for Swift code that needs strong API boundaries, predictable threading, and idiomatic Apple-platform integration. When the code is part of a Nitro Module, pair this with build-nitro-modules for generated specs, Promise mapping, and HybridObject constraints.
Workflow
- Read the local Swift code, generated protocols, and surrounding API shape before editing.
- Choose the public type model first: make invalid states unrepresentable where Swift can express them.
- Choose one concurrency model for the feature before writing implementation code.
- Keep synchronous properties and methods cheap, local, and nonblocking.
- Make queue hops, hardware/session negotiation, I/O, and fallible async work explicit in the API.
Type-Safe API Design
- Represent state variants with types, not nullable clusters. Use protocols plus conforming structs/classes when variants share a public contract, or use
enumwith associated values when the set is closed and value-like. - Keep related fields nonoptional on the same variant. If
barcodeandbarcodeTypeare meaningful only together, put both onScannedBarcode; do not make both optional on a generic scanned-data struct. - Use optionals only for real domain absence inside one state, not for expressing which state the object is in.
- Prefer compile-time flow over caller-side probing. If callers need repeated
if letchains to discover valid field combinations, the API shape is probably wrong.
// Avoid: the valid combinations are implicit and easy to misuse.
struct ScannedData {
let position: Point
let text: String?
let barcode: String?
let barcodeType: BarcodeType?
let face: Rect?
}
// Prefer: each state exposes the fields that are valid for that state.
protocol ScannedData {
var position: Point { get }
}
struct ScannedText: ScannedData {
let position: Point
let text: String
}
struct ScannedBarcode: ScannedData {
let position: Point
let barcode: String
let barcodeType: BarcodeType
}
struct ScannedFace: ScannedData {
let position: Point
let face: Rect
}
Concurrency Model
- Choose Swift concurrency or DispatchQueue for a feature, not both as interleaved control flow.
- Keep quick, deterministic, local work synchronous. Do not introduce
Task,DispatchQueue, or Promise plumbing for simple value construction, cached metadata, or pure transforms. - Use Swift
async/await,Task, and actors only when the full operation can be represented cleanly in Swift concurrency without queue escape hatches. - Use a private owned serial
DispatchQueuewhen Apple APIs, delegates, callbacks, C++ bridges, JS runtimes, or Nitro thread boundaries already revolve around queues, or when heavier native work must not block the caller. - Avoid
DispatchQueue.mainunless the platform API requires the main thread, such as UIKit/AppKit/VisionKit presentation or view mutation. Keep main-thread blocks small and move parsing, conversion, I/O, session negotiation, and CPU work to an owned queue or async API. - Treat repeated
Task,DispatchQueue, actor, or thread hops as an architecture smell. A component should either own the queue/actor it works on, or cross into that owner once at the public async boundary or native callback boundary. - If a workflow bounces between main, background, JS, and native queues in multiple nested places, stop and redesign the object/lifecycle/API. Excessive hops hide latency, make ordering harder to reason about, and create future performance problems.
- Do not fix races or readiness bugs with
DispatchQueue.asyncAfter,Task.sleep,Thread.sleep, timers, extra queue hops, or calling the same method twice. Fix the owner queue, lifecycle state, completion callback, delegate event, or async API boundary instead. Retry only for external nondeterminism such as hardware, OS services, remote services, or network, and keep retries bounded, cancellable, and idempotent. - Do not use
Task { @MainActor in ... }as a generic main-thread hop from a nonisolated or Nitro-generated entry point. It creates unstructured Swift concurrency. Use it only when the operation is otherwise Swift-concurrency based and benefits fromasync/await, task cancellation, or actor isolation end to end. - For UIKit, AppKit, VisionKit, and other main-thread callback/delegate APIs, prefer a direct
DispatchQueue.main.asyncboundary or an async public method that owns the hop. DirectDispatchQueue.main.asyncis understood by Swift's actor checker for@MainActorcalls; generic queue wrappers such asPromise.parallel(.main)usually are not. - If a callback can return on an arbitrary queue, normalize it to the chosen owner queue once, close to the callback source, instead of scattering nested
Task { @MainActor }orDispatchQueue.main.asynchops through the workflow. - Do not force
MainActor.assumeIsolated,Thread.isMainThreadbranches, or queue.synccalls to make a Swift-concurrency design compile.
Установить swift в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл swift?
Design, implement, and review Swift APIs and Apple-platform code. Use when working on .swift files, Swift types, Foundation or AVFoundation APIs, DispatchQueue, async/await, Task, actors, MainActor, thread-affine state, or Swift-backed React Native Nitro Module implementations.
Как установить скилл swift?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл swift запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic