/nlsmdn:review-swift [--staged | --unpushed | --changed | --all | --multi]from nlsmdn
Swift-specific code review focused on JUDGMENT-level design a linter and the compiler can't decide — state modeling with enums and value types (make invalid states unrepresentable), optional and error modeling, concurrency isolation intent, ARC ownership, SwiftUI identity/lifetime/dependencies, and escape hatches (`!`, `as!`, `try!`, `@unchecked Sendable`) that compile but hide a modeling problem. Deliberately does NOT duplicate SwiftLint, swift-format, or Swift 6 strict-concurrency diagnostics. Auto-invoked by `code-review` on Swift projects. Triggers "review swift", "swift review", "swift concurrency review".
Ships in nlsmdn. 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.
Read when SKILL.md points to them.
Swift review that covers what the compiler and SwiftLint cannot decide for you — how state is modeled, whether optionals and errors carry the right information, whether isolation and ownership reflect real intent, and whether an escape hatch is papering over a design problem.
Run on .swift files. Complements review-cleancode (SOLID/DRY/smells) — don't repeat it.
Use only these finding priorities, in descending order:
Grade the demonstrated consequence, realistic reachability, and available recovery against project priorities. A category, missing convention, hypothetical future problem, or confidence that a claim is true does not set its priority. Do not assign automatic severity floors or ceilings. Keep unverified claims in validation gaps, outside the graded finding count; distinguish suggestions from defects. For plans, trace the consequence if implemented and state the assumptions.
Use the short labels Must Fix, Should Fix, and Nice to Have in summaries and ledgers.
Keep effort, verification status, user-facing change size, and tool/vendor diagnostic ratings
separate. When called by code-review, return its requested evidence and impact fields; the parent
owns scoring and final triage. Otherwise apply this rubric directly. Omit empty priority sections.
Three layers already cover the mechanical work. Your job is what's left.
1. The compiler. In Swift 6 language mode (or -strict-concurrency=complete), data-race safety is enforced: non-Sendable values crossing isolation boundaries, non-isolated global/static mutable state, actor state accessed from another domain, deinit isolation, @Sendable closure captures. Never report these as review findings when that mode is on.
2. SwiftLint — but check what's actually enabled. Many safety-relevant rules are opt-in, so in a default config they do not run. Verified against SwiftLint 0.55.1 (swiftlint rules):
| Rule | Opt-in? |
|---|---|
force_cast, force_try | on by default |
identifier_name, type_name, line_length, function_body_length, type_body_length, cyclomatic_complexity | on by default |
redundant_void_return, redundant_optional_initialization | on by default |
force_unwrapping, implicitly_unwrapped_optional | opt-in |
unowned_variable_capture, weak_delegate, strong_iboutlet | opt-in |
first_where, last_where, contains_over_filter_count, empty_count, toggle_bool | opt-in |
discouraged_optional_boolean, discouraged_optional_collection, redundant_type_annotation | opt-in |
unhandled_throwing_task | opt-in |
Recent SwiftLint versions add async_without_await, incompatible_concurrency_annotation, redundant_sendable, and rename some rules. Read the project's .swiftlint.yml rather than assuming — suppress a mechanical finding only if that project actually runs the rule. If it doesn't, fold it into the one-time recommendation below instead of reporting it per-occurrence.
SwiftLint has no SwiftUI property-wrapper or ownership rules, so all of §4 is yours.
3. Xcode runtime diagnostics catch some SwiftUI misuse at runtime (off-main-thread ObservedObject/StateObject mutation, cross-actor Binding access, StateObject accessed without being installed on a view). These are runtime issues, not review findings. Note they reportedly have no @Observable equivalent — so migrating to @Observable loses that safety net, which makes §4 review more important, not less.
The baseline read is a silencer, not a finding. Read the config so you don't report what a rule already covers. Recommending a lint or language-mode change is a project-level action — see §P — and belongs in an --all audit, not a diff review.
SwiftUI presentation, accessibility, adaptive layout, navigation, localization, and native
window/command interaction belong to review-swiftui. Keep state ownership, identity,
lifetime, dependencies, and rendering cost here; do not repeat the UI review.
Swift design decisions are made once; the ways they get violated recur with every change. So the default review looks only at what the diff introduces — a new struct whose fields are correlated, a new ! on external data, a new Task with no owner, a new @State holding a passed-in object. Whole-module properties (is SwiftLint configured, is the target on Swift 6 mode, is the public surface coherent) belong to §P, which runs at --all and nowhere else.
/review-swift # Review context-related code
/review-swift --staged # Review staged changes
/review-swift --unpushed # Review files changed across all unpushed commits
/review-swift --changed # Review unstaged changes
/review-swift --all # Full codebase audit (parallel agents)
/review-swift --multi # Also get external advisor opinions
| Flag | Scope | Method |
|---|---|---|
| (none) | Context-related code | Files from the current conversation context. If no context, ask the user to specify files or use --staged/--changed/--all. |
--staged | Staged changes | git diff --cached --name-only |
--unpushed | Files changed across unpushed commits | git diff --name-only $(git rev-list HEAD --not --remotes | tail -1)^..HEAD |
--changed | Unstaged changes | git diff --name-only |
--all | Full codebase + §P project-level checks | Glob *.swift, parallel agents |
--multi | Add external opinions | Combines with any scope above; invokes second-opinion --quick |
--unpushed derives its range from git rev-list HEAD --not --remotes (oldest unpushed commit's parent → HEAD). If nothing is unpushed, or there is no remote/upstream (or the range walks back to the root commit) so it can't be determined reliably, stop and ask the user to pick another scope.
Restrict the resolved file list to .swift before reviewing.
Determine scope (see table) and filter to Swift files only.
Read CLAUDE.md in the repo root for project conventions.
Establish the baseline — do this before reading any code. Since Swift 6.2 the same source text means different things depending on per-module settings, so isolation is unreviewable without them. Check:
Package.swift (swiftLanguageMode(.v6), .enableUpcomingFeature, .unsafeFlags) or Xcode's SWIFT_VERSION / SWIFT_STRICT_CONCURRENCY.-default-isolation MainActor / SwiftSetting.defaultIsolation(MainActor.self) (SE-0466). If on, unannotated code is @MainActor and your default reading inverts.NonisolatedNonsendingByDefault (SE-0461) — changes where nonisolated async functions run..swiftlint.yml — which rules actually run.Review each file against the categories below — against what the diff introduces. Add §P only at --all. Load the matching reference file when the code touches that area.
Parallelize if scope has >5 files: one sub-agent per category, merge and dedupe.
External opinions (if --multi): invoke second-opinion --quick with this prompt:
Read-only Swift review. Assume SwiftLint and the Swift compiler already handle mechanical rules — do NOT repeat lint-level or plain compiler-diagnostic findings. Focus on DESIGN judgment: are invalid states representable that should be modeled away with an enum + associated values? Are structs/classes chosen for the right semantics? Do optionals and error types carry the information callers need, or is failure flattened to nil? Does isolation reflect real ownership? Are there state assumptions across an `await` inside an actor? Do any `!`, `as!`, `try!`, `@unchecked Sendable`, or `nonisolated(unsafe)` hide a wrong upstream type or an unchecked invariant? 300 words or less.
Wait for all external results before proceeding.
Classify severity and report, grouped by severity.
The core value. The compiler checks that types are consistent; only a human checks that they're right.
struct LoadState { var isLoading: Bool; var value: T?; var error: Error? } permits loading-with-value-and-error. Recommend an enum with associated values (case idle, loading, loaded(T), failed(Error)) so illegal states won't compile. Swift's single highest-leverage modeling move.kind == .circle then radius is set" is enforced by convention, not by the type.class holding inert data with no identity or shared mutation should be a struct; a struct whose copies silently diverge where callers assume one shared instance is the reverse bug. Watch the leak: a struct holding a class has value semantics only at the top level.String/Int where an enum or wrapper type prevents mix-ups; -1/""/0 overloaded to mean "none"; interchangeable String IDs swappable at a call site. Recommend wrapper types only where mix-ups are a real risk — note the ergonomic cost.[Item]? where "possibly empty" suffices; Any/[String: Any] at an internal boundary. Liberal in inputs, strict in outputs.static var is global mutable state — prefer static let or a computed property.switch with default over an enum you own — enumerating cases forces every site to be reconsidered when a case is added.public/open surface that leaks internal types or was public by default rather than by decision; internal mutable state that should be private(set).sort()/sorted(), stripNewlines()/strippingNewlines(), union/formUnion); non-mutating methods read as noun phrases (x.distance(to: y)); factory methods begin with make; argument labels form a phrase at the call site. There is no "don't prefix with get" rule — it isn't in the guidelines; don't flag it.T? where the caller needs to know why it failed should throw or return Result.[Item]??, or [Item]? where empty already means empty.catch mapping every failure to one generic case, or an API throwing untyped Error where callers must string-match.throws remains the better default error-handling mechanism for most Swift code," and warns: "Resist the temptation to use typed throws because there is only a single kind of error that the implementation can throw." The three sanctioned cases are within-module/package implementation detail, generic code passing errors through, and constrained/embedded environments. Flag unjustified throws(SomeError) on an evolving API — it constrains future implementations.try? discarding a failure that mattered, empty catch {}. Distinguish "genuinely don't care" from "lost the diagnostic".assert + logging when recoverable; precondition/fatalError when not; fatalError specifically when the message is dynamic (precondition won't surface one in the crash log). assert compiles out in release, so an assert guarding an invariant that matters in production is a finding.CodingKeys silently dropping fields, try? erasing DecodingError, and whether init(from:) validates or merely parses. See references/memory-and-performance.md §4.Load references/concurrency.md when reviewing this area — it carries the version matrix, the official quotes, and the full pattern catalogue.
The essentials:
@MainActor application. Official guidance runs the other way: "It is completely normal for programs with a user interface to have a large set of MainActor-isolated state," and under-isolation is called the most common latent problem. The real defect is blocking the main actor with long synchronous work. nonisolated alone is not an unsafe keyword.await inside actor-isolated or @MainActor code — the highest-value blind spot, explicitly out of scope for the compiler. Check-then-act, read-modify-write, and set-a-flag-after-awaiting are the three shapes.@unchecked Sendable / nonisolated(unsafe) as silencers rather than as documented proof obligations over real synchronization. Prefer scoping the hatch to one property over disabling checking for the whole type.Task with no lifetime owner — nothing stores or cancels it. Cancellation is neither inherited nor automatic, and is cooperative (nothing happens unless something checks). Task { [weak self] in guard let self else { return } } is a no-op.@MainActor, some not), MainActor.run where await suffices, assumeIsolated in new 6.2+ code, DispatchSemaphore blocking on async work.Load references/swiftui.md for the full pairing table and identity rules. Apple's own lens is Identity · Lifetime · Dependencies.
@Observable: @State for the object the view creates, a plain property for one passed in, @Bindable for bindings, @Environment(T.self) from the environment. @State holding an @Observable class is the documented correct pattern — flag it only for a non-@Observable reference type, or for a passed-in object (which @State will silently pin to its first value).@State that then drifts.@ObservedObject on a view-created object (legacy stack); @ObservedObject/@StateObject wrapping an @Observable type (half-migrated).@State defaults or view init — @State does not memoize the way @StateObject did.AnyView destroying structural identity, id: \.self (a hash — mutating any field resets state), index/offset as identity, unstable .id().@State is destroyed on scroll (Apple: "don't depend on view state for data that needs to be kept alive after scrolling"); onAppear has no once-only guarantee.@Observable" on existing code — ObservableObject is legacy, not deprecated, and mixing is endorsed.Load references/memory-and-performance.md for the full treatment.
asyncAfter is fine strong — and marking it weak there is silently broken. Ask who retains whom, not "is there a [weak self]".self.handler = doThing) create cycles the compiler does not diagnose.weak is wrong for a helper the object created.weak is itself a defect — "actively harmful to use weak references in places where they aren't needed."unowned is contested and not faster — decide on lifetime semantics, never performance.Lint flags the presence of !, as!, try! (when enabled). What's left:
URL(string: endpoint)! because endpoint is a String that should have been a URL three layers up. The fix is upstream. Highest-value finding here.as! / as? standing in for a modeling gap — a downcast off Any or an untyped dictionary means the container type is wrong. Say what the right type is.try! at a trust boundary — decoding, network payloads, Bundle resources, UserDefaults. Distinguish from a genuinely-safe unwrap of a compile-time-known literal.fatalError/preconditionFailure on a reachable path — fine for programmer error, a production crash when the "impossible" case is external input.@retroactive conformances — two modules doing it conflict at runtime.State your reasoning. "Force-unwrap hides that configURL is modeled as String? when it's always a valid URL" is a finding; "there's a force-unwrap here" is not.
~Copyable, borrowing/consuming (Swift 5.9+) are genuinely niche — file handles, locks, once-only operations. One question at most: does this represent a resource that must not be duplicated? Treat unexplained borrowing/consuming on ordinary copyable code as noise; SE-0377 notes adding or removing them "does not have any source-breaking effects," so they're performance annotations, not contracts. No authoritative review guidance exists for macros — don't invent any.
--all onlyWhole-module properties. They change rarely, so raising them on a diff review buries the findings that matter. Never report these outside an --all audit.
.swiftlint.yml; the safety opt-ins missing (force_unwrapping, implicitly_unwrapped_optional, unowned_variable_capture); the target not on Swift 6 language mode or -strict-concurrency=complete. One recommendation covers the whole mechanical class better than eyeballing diffs ever will.Package.swift), sweep what is public versus what needs to be: public surface that leaks internal types, public where internal was the intent, mutable public var that should be private(set), and missing @frozen/@inlinable decisions on a library that has made an ABI commitment. Adding a case to a public enum a client switches over is a source break — worth one whole-module pass, not a per-diff nag.sort()/sorted(), union/formUnion), factory methods beginning with make, non-mutating methods reading as noun phrases. Flag only where it genuinely misleads — and remember there is no "don't prefix with get" rule.@retroactive conformances across the module — two modules conforming the same external type conflict at runtime, which only a whole-module view surfaces.sleep-based synchronization, real clock, network or home-directory access appear across the suite. Do not demand migration off XCTest; it is not deprecated and still has no equivalent for UI automation or performance testing.public surface and naming sweeps are module properties; this diff did not change them.Common reviewer instincts that are wrong or unsupported. See references/memory-and-performance.md §7 for sources.
final for speed — WMO already infers it. Legit reasons are enforcement and API semantics.ContiguousArray everywhere — identical efficiency for struct/enum elements.@inlinable for speed — it's an ABI commitment, and SwiftPM has conservative CMO by default.reserveCapacity — inside a loop it makes append O(n²).+= is quadratic" — folklore.@MainActor — see §3.get" — not an API Design Guidelines rule.-strict-memory-safety — officially "best left for projects with the strongest security requirements."## Swift Review: {scope}
### Baseline
{Language mode / default isolation / strict concurrency, and any assumption you had to make — these change how the code *reads*, so state them whenever they were ambiguous. **At `--all` only:** the §P results, including the toolchain recommendation. On a diff review, omit this block if the isolation picture was unambiguous.}
### Critical Issues (Must Fix)
- {file}:{line} — {category}: {description}
**Why it's not a lint or compiler finding:** {what judgment this needed}
**Impact:** {what breaks}
**Fix:** {model change / isolation change / real failure path — with code}
### Improvements (Should Fix)
- {file}:{line} — {category}: {description}
**Fix:** {solution}
### Suggestions (Nice to Have)
- {file}:{line} — {category}: {description} — {suggested change}
If --multi was used, append one subsection per advisor that responded (titled with the advisor's
name as reported by second-opinion), then a Cross-Model Agreement subsection.
Invalid state representable:
/review-swift --staged
Finds struct FeedState { var isLoading: Bool; var items: [Item]?; var error: Error? } — nothing prevents isLoading == true with both items and error set, and the view has three if branches guessing. Reports Should Fix when those contradictory branches create incorrect ordinary UI behavior; otherwise a useful modeling improvement is Nice to Have. Proposes an enum FeedState { case idle, loading, loaded([Item]), failed(Error) } rewrite. Not a lint finding: the struct is perfectly valid Swift.
Force-unwrap hiding a mistyped source:
/review-swift --changed
Finds URLRequest(url: URL(string: config.host + path)!) where config.host is a String decoded from a plist. Reports Should Fix if a malformed configured host causes a recoverable failure, or Must Fix only for a demonstrated core outage without reasonable recovery — decode host as a URL or validate once at config load, rather than guarding each call site. force_unwrapping is opt-in and may not even be running; even when it is, it only says "there's a !".
State assumption across a suspension:
/review-swift
Finds an actor cache whose value(for:) checks a dictionary, awaits a network fetch, then writes back. Concurrent callers each see an empty cache and issue duplicate requests. Reports Should Fix if this causes demonstrated substantial cost or wrong results; otherwise Nice to Have. Fix: store the in-flight Task so later callers await the same one. The compiler is silent; this is explicitly outside its scope.
Solution: Check whether the project actually runs that rule — many safety rules are opt-in and off by default. If it does, drop the finding. If it doesn't, fold it into the one-time baseline recommendation rather than reporting each occurrence.
Solution: Check Package.swift for swiftLanguageMode / defaultIsolation / .enableUpcomingFeature, and Xcode for SWIFT_VERSION, SWIFT_STRICT_CONCURRENCY, and the Approachable Concurrency / Default Actor Isolation settings. Mixed-mode workspaces are normal. If ambiguous, review as if strict checking is off and say so in the Baseline line.
Solution: Trace the value's origin. Compile-time literal or a value the same function just built → probably fine. Decoded, networked, user-supplied, or resource-loaded → recommend a real failure path.
Result).some-over-any, and noncopyable types all have costs — recommend them where they prevent real bugs.setUp-assigned IUO is defensible. A force-unwrap of a value produced by the system under test should be try #require(x) / try XCTUnwrap(x) — a crash loses the diagnostic and, under swift-testing's in-process parallelism, can take down concurrently running tests. Also flag sleep-based synchronization and real clock/network access in unit tests.What SKILL.md sets; muted values are Claude Code's defaults
highOther plugins' skills for the same job
65 skills in this plugin
/blind-spotsSurface consequential decisions a plan, design, or research brief left silently assumed, by interviewing the user in dependency order. Use when the user says "blind spots", "grill me", "stress-test this plan", "poke holes in this", "what am I missing", "interrogate this design", "what haven't I decided", or needs a loose idea or research brief clarified before work begins. Do NOT use for a clear factual lookup, to explain a previous reply in more detail (use `huh`), to generate ideas when it is unclear what to build (use `ideation`), or to review an already-written plan with agents (use `review-plan`)./brainstormWork out how to solve a problem the user can already name — interview them with `blind-spots` to understand it, generate structurally different approaches, validate each with an independent critic, then present the survivors with trade-offs and a recommendation. Use when the user says "brainstorm", "brainstorm approaches", "how should we solve/approach/tackle X", "what are our options", "compare approaches", "think this through with me", or wants solutions weighed before committing. Works on any topic, with codebase recon when a repo is involved; `--debate` adds external advisors for high-stakes calls. Do NOT use when stuck on what to build or what the problem is (use `ideation`), to probe an already-chosen plan (use `blind-spots`), or to pick a library or service (use `evaluate-tech`).npx claudepluginhub nielsmadan/skills --plugin nlsmdn