Skip to content
Back to skills

Swift Code Review

ASecurity

Reviews Swift code for concurrency safety, error handling, memory management, and common mistakes. Use when reviewing .swift files for async/await patterns, actor isolation, Sendable conformance, or general Swift best practices.

  • 92 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added February 8, 2026
developmentswiftcode-reviewapi

Works with

  • api

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned November 26, 2026

npx -y skills add existential-birds/beagle --skill swift-code-review --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Swift Code Review?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Swift Code Review
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/existential-birds-swift-code-review/badge)](https://www.skillsdirectory.com/skills/existential-birds-swift-code-review)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: swift-code-review
description: "Reviews Swift code for concurrency safety, error handling, memory management, and common mistakes. Use when reviewing .swift files for async/await patterns, actor isolation, Sendable conformance, or general Swift best practices."
---

# Swift Code Review

## Review Workflow

Follow this sequence **in order**. Do not emit findings until every **Pass** below is satisfied.

1. **Swift / toolchain baseline** — Establish language and tooling context: `Package.swift` `// swift-tools-version` and per-target `swiftSettings` (including `NonisolatedNonsendingByDefault`, `InferIsolatedConformances`, or `MainActor` default isolation); for Xcode, `SWIFT_VERSION` and Swift 6.2 `SWIFT_DEFAULT_ACTOR_ISOLATION` / approachable concurrency build settings; note if review is single-file only.  
   **Pass:** You state a concrete Swift language version or mode (e.g. Swift 6.2 with `MainActor` default isolation, Swift 6 language mode, tools 5.10) *before* advice that depends on strict concurrency, approachable concurrency, migration-only syntax, or SDK availability.

2. **Read surrounding code** — For each changed `.swift` file, read the full enclosing type, function, method, or property that contains the edits, not only the diff hunk.  
   **Pass:** At least one full enclosing symbol (type or member) containing the change was read per changed file.

3. **Scope the checklist** — Using [Quick Reference](#quick-reference), decide which [Review Checklist](#review-checklist) rows and [references](#when-to-load-references) apply; open those reference files; skip rows clearly unrelated to the diff.  
   **Pass:** The review (or working notes) lists which checklist areas you applied, or marks areas N/A with a one-line reason tied to the diff (e.g. “no SwiftUI / @Observable in change”).

4. **Pre-report verification** — Load and follow `review-verification-protocol` at [review-verification-protocol](../review-verification-protocol/SKILL.md).  
   **Pass:** That skill’s **Hard gates (sequenced)** are satisfied for each finding you will report (full symbol read, usage search before “unused”, caller checked before “missing handling”, severity calibrated, `[FILE:LINE]` proof).

## Hard gates (same sequence, shorter)

| Step | Objective pass condition |
| --- | --- |
| 1 | Swift version/mode and default actor isolation settings (or explicit single-file limitation) recorded before version- or SDK-gated advice. |
| 2 | Full enclosing symbol read per changed file, not diff-only. |
| 3 | Checklist areas + references listed or N/A with diff-tied reason. |
| 4 | `review-verification-protocol` completed for every reported issue. |

## Output format

Report findings as:

```text
[FILE:LINE] ISSUE_TITLE
Severity: Critical | Major | Minor | Informational
Description of the issue and why it matters.
```

## Quick Reference

| Issue Type | Reference |
|------------|-----------|
| async/await, actors, Sendable, Task, Swift 6.2 isolation | [references/concurrency.md](references/concurrency.md) |
| @Observable, @ObservationIgnored, observation tracking | [references/observable.md](references/observable.md) |
| throws, typed throws, CancellationError, Result | [references/error-handling.md](references/error-handling.md) |
| Force unwraps, IUOs, retain cycles, unowned traps | [references/common-mistakes.md](references/common-mistakes.md) |

## Review Checklist

- [ ] No force unwraps (`!`) or `try!` on runtime data (network, user input, files)
- [ ] Escaping closures stored as properties (and long-lived `Task` loops) use `[weak self]`; `unowned` only when lifetime is strictly guaranteed
- [ ] Delegate properties are `weak`
- [ ] Independent async operations use `async let` or `TaskGroup`
- [ ] Long-running `Task` loops check cancellation (`try Task.checkCancellation()` or `Task.isCancelled`) and don't swallow `CancellationError`
- [ ] Swift 6.2 isolation settings respected (`@concurrent` for CPU-bound offloads under `NonisolatedNonsendingByDefault`; don't flag missing `@MainActor` if target uses `SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor`)
- [ ] Actors have mutable state to protect (no stateless actors) and guard invariants across `await` suspension points
- [ ] `Sendable` / `@unchecked Sendable` types are genuinely thread-safe (backed by real synchronization)
- [ ] Errors handled explicitly (no silent `Task` failures or broad `catch` swallowing `CancellationError`)
- [ ] Non-tracked/injected/Combine properties in `@Observable` classes use `@ObservationIgnored`
- [ ] Nested observed reference types inside `@Observable` models are also `@Observable`

## When to Load References

- Reviewing async/await, actors, `Sendable`, or Swift 6.2 concurrency → [references/concurrency.md](references/concurrency.md)
- Reviewing `@Observable` macro design or `withObservationTracking` → [references/observable.md](references/observable.md)
- Reviewing typed throws, `CancellationError`, or error propagation → [references/error-handling.md](references/error-handling.md)
- Reviewing force unwraps, retain cycles, `unowned`, or IUOs → [references/common-mistakes.md](references/common-mistakes.md)

## Review Questions

1. Are independent async operations running concurrently with `async let` or `TaskGroup`?
2. Could actor state change across suspension points (reentrancy bug)?
3. Under Swift 6.2 Approachable Concurrency, are heavy CPU tasks explicitly marked `@concurrent` instead of blocking the caller's actor?
4. Is `@unchecked Sendable` backed by actual synchronization?
5. Could any broad `catch` block accidentally swallow `CancellationError` or `Task` failure?
6. Could any stored closure, delegate, or long-lived `AsyncSequence` `Task` create a retain cycle?

Files in this skill

  • SKILL.md2 KB
  • references/common-mistakes.md3.7 KB
  • references/concurrency.md3.7 KB
  • references/error-handling.md3.6 KB
  • references/observable.md3.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.