No slash command · from swift-foundation
Provides Swift language conventions for any Swift codebase: Swift 6 language mode, value types, optionals, error handling, protocols, generics, access control, strict concurrency, and API design guidelines.
Ships in swift-foundation. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Read it before writing a line — it decides what compiles:
// swift-tools-version: on the first line of Package.swift, and swiftLanguageModes: / per-target .swiftLanguageMode(.v5) settings. Tools version 6.0+ defaults to the Swift 6 language mode.SWIFT_VERSION in the target's build settings (project.pbxproj, .xcconfig, Tuist/XcodeGen manifests).SWIFT_STRICT_CONCURRENCY (minimal / targeted / complete) in Swift 5 mode; SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor and SWIFT_APPROACHABLE_CONCURRENCY = YES (Xcode 26+ app templates turn both on); .defaultIsolation(MainActor.self) in a SwiftPM 6.2+ target.Never change the language mode, strict-concurrency level or default isolation to make your code compile. Fix the code. Never use a feature newer than the toolchain the project pins (.swift-version, swift-tools-version, CI image).
struct for data, enum for closed sets of cases (with associated values), class only for identity, shared mutable state, or Objective-C / framework subclassing. final class unless designed for inheritance.let over var; mutate through methods on a struct (mutating) rather than exposing settable properties.enum instead of a cluster of optionals and booleans:enum LoadState<Value> {
case idle
case loading
case loaded(Value)
case failed(any Error)
}
switch over your own enums exhaustively — no default: that would silently swallow a new case. For framework enums marked non-frozen, use @unknown default:.Codable structs with CodingKeys (or a JSONDecoder.keyDecodingStrategy the project already uses) over hand-written dictionary parsing.!), try! or as! in production code. Allowed: IBOutlets in legacy UIKit, and a compile-time-known literal such as URL(string: "https://example.com")! — nothing derived from input.guard let x else { return / throw } for early exits; if let x for the happy branch; ?? for a real default, not to hide a bug.fatalError / precondition for conditions caused by input, network or disk — throw instead.throws for recoverable failures. Define domain errors as enum MyError: Error with associated values; conform to LocalizedError only where a message reaches the user.throws(ParseError)) only for small, closed, internal APIs where the caller must handle every case — public APIs and anything that calls into other throwing code stay untyped.Result is for storing or passing an outcome (callbacks, state), not for returning from async functions — use async throws.try? an operation whose failure matters; at least log it with context.protocol UserRepository { func user(id: User.ID) async throws -> User }) — the seam for tests and for swapping implementations.some Protocol for parameters and return types when one concrete type flows through; any Protocol only when you need heterogeneous storage. Write any explicitly — it is required in Swift 6 for existential use.async/await for every asynchronous API you write. No new completion-handler APIs; wrap legacy callbacks once with withCheckedThrowingContinuation and resume exactly once on every path.async let for a fixed number of parallel calls, withThrowingTaskGroup for a dynamic number. Unstructured Task { } only at a boundary (a UI event, a lifecycle hook) — and keep the handle if the work must be cancellable. Task.detached almost never.try Task.checkCancellation().@MainActor.actor. Remember actor reentrancy: re-check state after every await inside an actor method.Sendable — immutable structs/enums get it for free; classes need final + immutable stored properties, or must be an actor.nonisolated for pure functions on isolated types. With approachable concurrency, nonisolated async functions run on the caller's actor; mark a function @concurrent when it must run off the caller's actor (CPU-heavy work).@unchecked Sendable, nonisolated(unsafe) and @preconcurrency import are escape hatches for code you cannot change (old SDKs, C libraries). Each one needs a comment stating why it is safe. Never use them to silence a warning in code you own.DispatchQueue / DispatchSemaphore in new code unless you are bridging to an API that requires it. Never block a concurrency thread with a semaphore waiting on async work.self (callbacks, NotificationCenter observers, Combine sink) capture [weak self] and guard let self else { return }. unowned only when the lifetime relationship is guaranteed and documented.Task { } started from an object captures self strongly until it finishes; cancel long-running tasks in deinit or the view's .task lifecycle.weak var delegate: (any SomeDelegate)? with a class-constrained protocol (AnyObject).internal; private for helpers; public / package only for API another module consumes. open only when subclassing from outside is intended.extension Type: Protocol { } blocks.// MARK: - sections only where the file already uses them.remove(at: index), user(withID:), not removeElement(index:).UpperCamelCase; everything else lowerCamelCase; acronyms uniform case (userID, urlString, HTTPClient).isEmpty, hasChanges, canSubmit.sort() / sorted(), formUnion() / union().make. Protocols describing a capability end in -able / -ing; protocols describing what something is are nouns./// doc comments (summary line, - Parameter, - Returns, - Throws).Logger from os (Apple platforms) or swift-log (Logger(label:), servers / cross-platform) — whichever the project uses. No print in production paths.os.Logger, dynamic values are private by default in release logs — keep it that way; mark privacy: .public only for non-sensitive values.What SKILL.md sets; muted values are Claude Code's defaults
3 skills in this plugin
/swift-testingTesting Swift code: Swift Testing (@Suite, @Test, #expect, #require, parameterized arguments, traits, tags, confirmation for events), XCTest for existing suites (XCTAssert*, setUp/tearDown, expectations), async and actor-isolated tests, protocol-based test doubles, deterministic time and randomness, swift test / xcodebuild test, coverage. Stack-agnostic — referenced by swift-plugin and apple-plugin.
Use this skill to:
- Pick the framework the project already uses for the target you test.
- Write focused, deterministic tests for logic, async code and actors.
- Replace network, disk and clock dependencies with test doubles.
Do NOT use this skill for:
- SwiftUI previews, UI tests and snapshot tests — see apple-plugin:apple-testing.
- Server HTTP-level tests — the swift-plugin stack prompt covers Vapor / Hummingbird testing helpers.
/swift-toolingSwift project tooling: Package.swift manifests (tools version, platforms, products, targets, dependencies, resources, plugins), dependency constraints and the Package.resolved policy, swift build / test / run, xcodebuild for Xcode projects (schemes, destinations, test plans), Xcode project styles (buildable folders, Tuist, XcodeGen, legacy groups), formatters and linters (swift-format, SwiftFormat, SwiftLint), xcconfig files. Stack-agnostic — referenced by swift-plugin and apple-plugin.
Use this skill to:
- Add a dependency or a target the way the project already manages them.
- Make sure a new file is actually compiled.
- Run the project's own formatter, linter, build and tests the way CI does.
Do NOT use this skill for:
- Language idioms — see swift-foundation:swift-conventions.
- Testing patterns — see swift-foundation:swift-testing.
npx claudepluginhub aratkruglik/claude-sdlc --plugin swift-foundationOther plugins' skills for the same job