About ios-chaos-monkey
ios-chaos-monkey is a crash-hunting guidance skill for iOS and Swift developers. Its prioritized rules cover concurrency, memory, persistence, and other runtime risks, using a test-first process that proves a crash before applying a fix.
Key features
- 01Prioritized crash-risk rules
- 02Concurrency and data-race checks
- 03Memory and deadlock guidance
- 04Async task and cancellation checks
- 05Persistence and file I/O risks
- 06Test-first proof-of-crash workflow
Use cases
- 01Auditing Swift concurrency for data races
- 02Checking async code for cancellation and continuation leaks
- 03Testing persistence and file I/O failure risks
- 04Writing failing crash tests before fixes
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ pproenca/ dot-skills --skill ios-chaos-monkeyAfter installing, type/ios-chaos-monkeyin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
metadata.jsonassets/templates/_template.mdreferences/_sections.mdasync-actor-hop-starvation.mdasync-continuation-leak.mdasync-detached-task-leak.mdasync-missing-cancellation.mdasync-task-group-error.mdasync-unsafe-sendable.mddead-actor-reentrancy.mddead-mainactor-blocking.mddead-queue-hierarchy.mddead-recursive-lock.mddead-semaphore-in-async.mddead-sync-on-main.mdexhaust-file-descriptor-leak.mdexhaust-memory-warning-ignored.mdexhaust-thread-explosion.mdexhaust-unbounded-task-spawn.mdexhaust-urlsession-leak.mdio-concurrent-file-write.mdio-coredata-cross-thread.mdio-filemanager-race.mdio-keychain-thread-safety.mdio-plist-concurrent-mutation.mdio-swiftdata-background.mdmem-async-task-self-capture.mdmem-closure-retain-cycle.mdmem-combine-sink-retain.mdmem-delegate-strong-reference.mdDetails
From the project READMEiOS 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.
Clinic Architecture Contract (iOS 26 / Swift 6.2)
All guidance in this skill assumes the clinic modular MVVM-C architecture:
- Feature modules import
Domain+DesignSystemonly (neverData, never sibling features) - App target is the convergence point and owns
DependencyContainer, concrete coordinators, and Route Shell wiring Domainstays pure Swift and defines models plus repository,*Coordinating,ErrorRouting, andAppErrorcontractsDataowns SwiftData/network/sync/retry/background I/O and implements Domain protocols- Read/write flow defaults to stale-while-revalidate reads and optimistic queued writes
- ViewModels call repository protocols directly (no default use-case/interactor layer)
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 | race- |
| 2 | Memory Corruption & Leaks | CRITICAL | mem- |
| 3 | Deadlocks & Thread Starvation | HIGH | dead- |
| 4 | Async/Await & Structured Concurrency | HIGH | async- |
| 5 | File I/O & Persistence Corruption | MEDIUM-HIGH | io- |
| 6 | Collection & State Mutation | MEDIUM | mut- |
| 7 | Resource Exhaustion | MEDIUM | exhaust- |
| 8 | Objective-C Interop Traps | LOW-MEDIUM | objc- |
Quick Reference
1. Data Races & Thread Safety (CRITICAL)
race-dictionary-concurrent-write- Concurrent Dictionary mutation crashes with EXC_BAD_ACCESSrace-array-concurrent-append- Concurrent Array append corrupts internal bufferrace-property-access- Unsynchronized property read-write across threadsrace-lazy-initialization- Lazy property double-initialization under concurrencyrace-singleton-initialization- Non-atomic singleton exposes partially constructed staterace-bool-flag- Non-atomic Bool flag creates check-then-act racerace-closure-capture-mutation- Closure captures mutable reference across threadsrace-delegate-nilification- Delegate set to nil during active callback
2. Memory Corruption & Leaks (CRITICAL)
mem-closure-retain-cycle- Strong self capture in escaping closures creates retain cyclemem-timer-retain-cycle- Timer retains target creating undiscoverable retain cyclemem-delegate-strong-reference- Strong delegate reference prevents deallocationmem-unowned-crash- Unowned reference crashes after owner deallocationmem-notification-observer-leak- NotificationCenter observer retains closure after removal neededmem-combine-sink-retain- Combine sink retains self without cancellable storagemem-async-task-self-capture- Task captures self extending lifetime beyond expected scope
3. Deadlocks & Thread Starvation (HIGH)
dead-sync-on-main- DispatchQueue.main.sync from main thread deadlocks instantlydead-recursive-lock- Recursive lock acquisition on same serial queuedead-actor-reentrancy- Actor reentrancy produces unexpected interleavingdead-semaphore-in-async- Semaphore.wait() inside async context deadlocks thread pooldead-queue-hierarchy- Dispatch queue target hierarchy inversion deadlocksdead-mainactor-blocking- Blocking MainActor with synchronous heavy work
4. Async/Await & Structured Concurrency (HIGH)
async-missing-cancellation- Missing Task.isCancelled check wastes resources after navigationasync-detached-task-leak- Detached task without cancellation handle leaks workasync-task-group-error- TaskGroup silently drops child task errorsasync-continuation-leak- CheckedContinuation never resumed leaks awaiting taskasync-actor-hop-starvation- Excessive MainActor hops in hot loop starve UI updatesasync-unsafe-sendable- @unchecked Sendable hides data race from compiler
5. File I/O & Persistence Corruption (MEDIUM-HIGH)
io-concurrent-file-write- Concurrent file writes corrupt data without coordinationio-coredata-cross-thread- CoreData NSManagedObject accessed from wrong threadio-swiftdata-background- SwiftData model accessed from wrong ModelContextio-plist-concurrent-mutation- UserDefaults concurrent read-write produces stale valuesio-filemanager-race- FileManager existence check then use is a TOCTOU raceio-keychain-thread-safety- Keychain access from multiple threads returns unexpected errors
6. Collection & State Mutation (MEDIUM)
mut-enumerate-and-mutate- Collection mutation during enumeration crashes at runtimemut-kvo-dealloc-crash- KVO observer not removed before deallocation crashesmut-index-out-of-bounds- Array index access without bounds check crashesmut-force-unwrap- Force unwrapping optional in production crashes on nilmut-enum-future-cases- Non-exhaustive switch crashes on unknown enum case
7. Resource Exhaustion (MEDIUM)
exhaust-unbounded-task-spawn- Unbounded task spawning in loop exhausts memoryexhaust-thread-explosion- GCD creates unbounded threads under concurrent loadexhaust-urlsession-leak- URLSession not invalidated leaks delegate and connectionsexhaust-file-descriptor-leak- File handle not closed leaks file descriptorsexhaust-memory-warning-ignored- Low memory warning ignored triggers Jetsam kill
8. Objective-C Interop Traps (LOW-MEDIUM)
objc-unrecognized-selector- Missing @objc annotation crashes with unrecognized selectorobjc-nsnull-in-json- NSNull in decoded JSON collection crashes on accessobjc-bridge-type-mismatch- Swift/ObjC bridge type mismatch crashes at runtimeobjc-dynamic-dispatch- Missing dynamic keyword breaks method swizzling
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 |