Skill Wiki v0.1.0
rule @ios-swift/rule-weak-self-in-escaping-closures

Weak Self In Escaping Closures

Strong captures inside an `@escaping` closure that the receiver itself stores — completion blocks, Combine subscribers, NotificationCenter observers, async tasks held on a controller, timer handlers — create a retain cyc…

Skill
@ios-swift
Domain
ios-swift
Version
0.1.0
Quality
4.0
Edges
3 out · 2 in
Tokens
128/357/384
$ prime install @ios-swift/rule-weak-self-in-escaping-closures

Projection

Always in _index.xml · the agent never has to ask for this.

WeakSelfInEscapingClosures [rule] v0.1.0

Strong captures inside an @escaping closure that the receiver itself stores — completion blocks, Combine subscribers, NotificationCenter observers, async tasks held on a controller, timer handlers — create a retain cycle. The receiver retains the closure, the closure retains the receiver, neither deinits. The fix is [weak self] in the capture list, paired with a guard let self else { return } (or optional-chained self?.) inside the body.

Source

prime-system/examples/ios-swift/primes/compiled/@ios-swift/rule-weak-self-in-escaping-closures/atom.yaml

Compiled at 2026-05-10