Review memory and retain cycles
review_swift_memoryDetect retain cycles and lifetime defects in Swift code, including strong self captures in timers, observers, Combine sinks, and escaping closures. Use when memory grows or deinit never fires.
Instructions
Check a Swift project for retain cycles and lifetime defects: repeating Timers and block-based NotificationCenter observers capturing self strongly, Combine sinks stored in a cancellables set owned by the same object, non-weak delegate properties, stored closure properties capturing self, unowned self in escaping closures, and long-running unstructured Tasks that keep an object alive after its screen is gone. Use when memory grows over time, when deinit is never called, or before shipping a screen with timers or subscriptions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the Swift project root (the folder containing Package.swift or the .xcodeproj). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| score | Yes | 0-100 defect density. 100 = no findings. penalty = 10*blockers + 3*serious + 1*minor; capacity = files*10. Comparable across runs on ONE project, not between projects. | |
| counts | Yes | ||
| issues | Yes | Every finding, most severe first. | |
| summary | Yes | One-line plain-language result. | |
| suggestions | Yes | Prioritized next actions, deduplicated by rule — not a restatement of every issue's fix. | |
| files_checked | Yes | Swift files actually scanned. |