ios-chaos-monkey
Original:🇺🇸 English
Translated
iOS crash-hunter skill that finds and fixes gnarly concurrency, memory, and I/O bugs using TDD. Every rule shows dangerous code, a failing test that proves the crash, and the fix that makes it pass. Complements ios-testing, swift-optimise, and other ios-*/swift-* skills. Triggers on tasks involving data races, retain cycles, deadlocks, async/await pitfalls, file corruption, thread safety, or crash debugging in Swift/iOS apps.
9installs
Sourcepproenca/dot-skills
Added on
NPX Install
npx skill4agent add pproenca/dot-skills ios-chaos-monkeyTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →iOS Chaos Monkey — Crash-Hunter Best Practices
Adversarial crash-hunting guide for iOS and Swift applications. Contains 47 rules across 8 categories, prioritized by crash severity. Every rule follows TDD: dangerous code first, a failing test that proves the bug, then the fix that makes the test pass.
When to Apply
Reference these guidelines when:
- Hunting data races, deadlocks, and concurrency crashes in Swift
- Auditing memory management for retain cycles and use-after-free
- Reviewing async/await code for cancellation and continuation leaks
- Stress-testing file I/O and CoreData/SwiftData persistence layers
- Writing proof-of-crash tests before implementing fixes
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Data Races & Thread Safety | CRITICAL | |
| 2 | Memory Corruption & Leaks | CRITICAL | |
| 3 | Deadlocks & Thread Starvation | HIGH | |
| 4 | Async/Await & Structured Concurrency | HIGH | |
| 5 | File I/O & Persistence Corruption | MEDIUM-HIGH | |
| 6 | Collection & State Mutation | MEDIUM | |
| 7 | Resource Exhaustion | MEDIUM | |
| 8 | Objective-C Interop Traps | LOW-MEDIUM | |
Quick Reference
1. Data Races & Thread Safety (CRITICAL)
- - Concurrent Dictionary mutation crashes with EXC_BAD_ACCESS
race-dictionary-concurrent-write - - Concurrent Array append corrupts internal buffer
race-array-concurrent-append - - Unsynchronized property read-write across threads
race-property-access - - Lazy property double-initialization under concurrency
race-lazy-initialization - - Non-atomic singleton exposes partially constructed state
race-singleton-initialization - - Non-atomic Bool flag creates check-then-act race
race-bool-flag - - Closure captures mutable reference across threads
race-closure-capture-mutation - - Delegate set to nil during active callback
race-delegate-nilification
2. Memory Corruption & Leaks (CRITICAL)
- - Strong self capture in escaping closures creates retain cycle
mem-closure-retain-cycle - - Timer retains target creating undiscoverable retain cycle
mem-timer-retain-cycle - - Strong delegate reference prevents deallocation
mem-delegate-strong-reference - - Unowned reference crashes after owner deallocation
mem-unowned-crash - - NotificationCenter observer retains closure after removal needed
mem-notification-observer-leak - - Combine sink retains self without cancellable storage
mem-combine-sink-retain - - Task captures self extending lifetime beyond expected scope
mem-async-task-self-capture
3. Deadlocks & Thread Starvation (HIGH)
- - DispatchQueue.main.sync from main thread deadlocks instantly
dead-sync-on-main - - Recursive lock acquisition on same serial queue
dead-recursive-lock - - Actor reentrancy produces unexpected interleaving
dead-actor-reentrancy - - Semaphore.wait() inside async context deadlocks thread pool
dead-semaphore-in-async - - Dispatch queue target hierarchy inversion deadlocks
dead-queue-hierarchy - - Blocking MainActor with synchronous heavy work
dead-mainactor-blocking
4. Async/Await & Structured Concurrency (HIGH)
- - Missing Task.isCancelled check wastes resources after navigation
async-missing-cancellation - - Detached task without cancellation handle leaks work
async-detached-task-leak - - TaskGroup silently drops child task errors
async-task-group-error - - CheckedContinuation never resumed leaks awaiting task
async-continuation-leak - - Excessive MainActor hops in hot loop starve UI updates
async-actor-hop-starvation - - @unchecked Sendable hides data race from compiler
async-unsafe-sendable
5. File I/O & Persistence Corruption (MEDIUM-HIGH)
- - Concurrent file writes corrupt data without coordination
io-concurrent-file-write - - CoreData NSManagedObject accessed from wrong thread
io-coredata-cross-thread - - SwiftData model accessed from wrong ModelContext
io-swiftdata-background - - UserDefaults concurrent read-write produces stale values
io-plist-concurrent-mutation - - FileManager existence check then use is a TOCTOU race
io-filemanager-race - - Keychain access from multiple threads returns unexpected errors
io-keychain-thread-safety
6. Collection & State Mutation (MEDIUM)
- - Collection mutation during enumeration crashes at runtime
mut-enumerate-and-mutate - - KVO observer not removed before deallocation crashes
mut-kvo-dealloc-crash - - Array index access without bounds check crashes
mut-index-out-of-bounds - - Force unwrapping optional in production crashes on nil
mut-force-unwrap - - Non-exhaustive switch crashes on unknown enum case
mut-enum-future-cases
7. Resource Exhaustion (MEDIUM)
- - Unbounded task spawning in loop exhausts memory
exhaust-unbounded-task-spawn - - GCD creates unbounded threads under concurrent load
exhaust-thread-explosion - - URLSession not invalidated leaks delegate and connections
exhaust-urlsession-leak - - File handle not closed leaks file descriptors
exhaust-file-descriptor-leak - - Low memory warning ignored triggers Jetsam kill
exhaust-memory-warning-ignored
8. Objective-C Interop Traps (LOW-MEDIUM)
- - Missing @objc annotation crashes with unrecognized selector
objc-unrecognized-selector - - NSNull in decoded JSON collection crashes on access
objc-nsnull-in-json - - Swift/ObjC bridge type mismatch crashes at runtime
objc-bridge-type-mismatch - - Missing dynamic keyword breaks method swizzling
objc-dynamic-dispatch
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |