Command Palette

Search for a command to run...

Назад к скиллам
скилл № 60484

Swift

Writes, debugs, and optimizes Swift — concurrency, ARC leaks, optionals, generics, SwiftUI state, and packages. Use when writing or reviewing Swift code, when…

БесплатноБез исполняемых скриптов
clawicот clawic★ 23 звезды на GitHub

Установить Swift в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

User preferences and memory live in ~/Clawic/data/swift/ (see setup.md on first use, memory-template.md for the file format). If you have data at an old location (~/swift/ or ~/clawic/swift/), move it to ~/Clawic/data/swift/, and say in one line that you moved it and from where.

When To Use

  • Writing, reviewing, or refactoring Swift: models, protocols, generics, async code, SwiftUI views, packages
  • Diagnosing a crash from its message, or a hang with no message: nil unwrap, arithmetic overflow, unowned dangling, exclusivity violation, continuation never resumed
  • Fixing Swift 6 data-race errors, Sendable conformance failures, and actor-isolation diagnostics during a language-mode migration
  • Chasing memory: retain cycles, objects that never deinit, growth Instruments blames on nothing
  • Making builds and binaries faster: type-check blowups, generic bloat, ARC traffic, existential boxing
  • Shipping Swift off Apple platforms: Linux and server builds, static linking, Foundation gaps, C interop
  • Not for Xcode project settings, signing, or provisioning (→ xcode), and not for App Store review, app lifecycle, or platform frameworks (→ ios)

Quick Reference

Situation Play
Crash with a Swift message ("Unexpectedly found nil", "Index out of range") Decode it in Crash Messages below, then debugging.md for the chain
Crash with no message (EXC_BAD_ACCESS, bare SIGTRAP) Memory Graph, zombies, then sanitizers → debugging.md
Object never deallocates, deinit never runs Retain cycle: closure, delegate, timer, or observer → arc.md
"Sending value of non-Sendable type", "actor-isolated property" concurrency.md for the rule, swift6-migration.md for the order to fix them in
Async code hangs with no error and no CPU Continuation never resumed, or a blocked cooperative thread (rule 4) → concurrency.md
Upgrading a codebase to Swift 6 language mode Per-target ratchet, not a big bang → swift6-migration.md
Too many !, try!, or IUOs; nil handling is noisy optionals.md
Designing the failure channel: throws vs Result vs optional, typed throws, retry, cancellation errors.md
JSON decode throws, keys missing, dates rejected codable.md (fractional-second ISO 8601 is the usual one)
any vs some vs generic; a protocol default never gets called types.md
Unicode, string indices, substrings, regex, locale-sensitive compare strings.md
Array/Dictionary/Set behavior, ordering, or an O(n²) blowup collections.md
Arithmetic traps at runtime, a numeric conversion crashes, floats compare wrong, or money needs a type numerics.md
SwiftUI state resets, views redraw constantly, layout fights back swiftui.md
Tests flaky, async tests pass before the work finishes testing.md
Package won't resolve, resources missing, plugin blocked packages.md
Slow build, slow runtime, oversized binary performance.md
Objective-C, C, or C++ bridging; unsafe pointers; C callbacks interop.md
Builds on macOS, fails on Linux or in a container linux.md
Designing public API: naming, access control, availability, ABI api-design.md
Property wrappers, result builders, macros, key paths metaprogramming.md
Anything else Reduce to the smallest file that still reproduces, compile with -Onone, and read the FIRST compiler error — the rest is usually cascade noise

Core Rules

  1. ! is a deliberate crash, not a shortcut. Recoverable nil → guard let x else { return }. Nil that means the program is already broken → guard let x else { fatalError("config missing: \(key)") }; the crash log then names the invariant instead of "Unexpectedly found nil while unwrapping an Optional value", which names nothing. Only IBOutlets and two-phase init justify an implicitly unwrapped T!.
  2. weak when the target can die first; unowned only when lifetimes are provably nested. Test: can the referenced object deallocate while this reference exists? Yes → weak (becomes nil, no crash). Provably no, because it owns me → unowned (one less check, but a dangling read is an immediate crash rather than a nil). Escaping closures that touch self: [weak self] in guard let self else { return }. Non-escaping closures (map, forEach, withLock) never need a capture list — they cannot outlive the call.
  3. Reference type only for identity or lifecycle. Default struct. Reach for class/actor when the thing has identity (two copies with equal fields are still different things), needs deinit, or is genuinely shared and mutated in place. Copy cost is not the tiebreaker: standard-library collections are copy-on-write, so a copy is a retain until someone writes (→ types.md).
  4. Never block a thread in the cooperative pool. Swift concurrency runs one thread per active core, so on an 8-core machine 8 concurrent DispatchSemaphore.wait() calls inside async f
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • _meta.json
  • api-design.md
  • arc.md
  • codable.md
  • collections.md
  • concurrency.md
  • debugging.md
  • errors.md
  • interop.md
  • linux.md
  • memory-template.md
  • metaprogramming.md
  • numerics.md
  • optionals.md
  • packages.md
  • performance.md
  • setup.md
  • strings.md
  • swift6-migration.md
  • swiftui.md
  • testing.md
  • types.md

FAQ

Что делает скилл Swift?

Writes, debugs, and optimizes Swift — concurrency, ARC leaks, optionals, generics, SwiftUI state, and packages. Use when writing or reviewing Swift code, when a build won't type-check or the compiler "is unable to type-check this expression in reasonable time", when an app crashes on a force unwrap, an unowned reference, or EXC_BAD_ACCESS, when Swift 6 raises Sendable / actor-isolated / data-race errors, when a retain cycle keeps objects alive, when JSON fails to decode, when async code hangs or deadlocks, when SwiftUI state resets or views redraw too often, when XCTest or Swift Testing tests are flaky, when a Swift package won't resolve, or when bridging to Objective-C, C, or Linux. Not for Xcode signing and IDE settings, or App Store submission and iOS app lifecycle.

Как установить скилл Swift?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Swift запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Swift с