File contents 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.
Clinic Architecture Contract (iOS 26 / Swift 6.2)
All guidance in this skill assumes the clinic modular MVVM-C architecture:
Feature modules import Domain + DesignSystem only (never Data, never sibling features)
App target is the convergence point and owns DependencyContainer, concrete coordinators, and Route Shell wiring
Domain stays pure Swift and defines models plus repository, *Coordinating, ErrorRouting, and AppError contracts
Data owns 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_ACCESS
race-array-concurrent-append - Concurrent Array append corrupts internal buffer
race-property-access - Unsynchronized property read-write across threads
race-lazy-initialization - Lazy property double-initialization under concurrency
race-singleton-initialization - Non-atomic singleton exposes partially constructed state
race-bool-flag - Non-atomic Bool flag creates check-then-act race
race-closure-capture-mutation - Closure captures mutable reference across threads
race-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 cycle
mem-timer-retain-cycle - Timer retains target creating undiscoverable retain cycle
mem-delegate-strong-reference - Strong delegate reference prevents deallocation
mem-unowned-crash - Unowned reference crashes after owner deallocation
mem-notification-observer-leak - NotificationCenter observer retains closure after removal needed
mem-combine-sink-retain - Combine sink retains self without cancellable storage
mem-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 instantly
dead-recursive-lock - Recursive lock acquisition on same serial queue
dead-actor-reentrancy - Actor reentrancy produces unexpected interleaving
dead-semaphore-in-async - Semaphore.wait() inside async context deadlocks thread pool
dead-queue-hierarchy - Dispatch queue target hierarchy inversion deadlocks
dead-mainactor-blocking - Blocking MainActor with synchronous heavy work
4. Async/Await & Structured Concurrency (HIGH)
async-missing-cancellation - Missing Task.isCancelled check wastes resources after navigation
async-detached-task-leak - Detached task without cancellation handle leaks work
async-task-group-error - TaskGroup silently drops child task errors
async-continuation-leak - CheckedContinuation never resumed leaks awaiting task
async-actor-hop-starvation - Excessive MainActor hops in hot loop starve UI updates
async-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 coordination
io-coredata-cross-thread - CoreData NSManagedObject accessed from wrong thread
io-swiftdata-background - SwiftData model accessed from wrong ModelContext
io-plist-concurrent-mutation - UserDefaults concurrent read-write produces stale values
io-filemanager-race - FileManager existence check then use is a TOCTOU race
io-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 runtime
mut-kvo-dealloc-crash - KVO observer not removed before deallocation crashes
mut-index-out-of-bounds - Array index access without bounds check crashes
mut-force-unwrap - Force unwrapping optional in production crashes on nil
mut-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 memory
exhaust-thread-explosion - GCD creates unbounded threads under concurrent load
exhaust-urlsession-leak - URLSession not invalidated leaks delegate and connections
exhaust-file-descriptor-leak - File handle not closed leaks file descriptors
exhaust-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 selector
objc-nsnull-in-json - NSNull in decoded JSON collection crashes on access
objc-bridge-type-mismatch - Swift/ObjC bridge type mismatch crashes at runtime
objc-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
1 --- 2 name: ios-chaos-monkey 3 description: iOS Chaos Monkey — Crash-Hunter Best Practices 4 --- 5 # iOS Chaos Monkey — Crash-Hunter Best Practices 6 7 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. 8 9 10 ## Clinic Architecture Contract (iOS 26 / Swift 6.2) 11 12 All guidance in this skill assumes the clinic modular MVVM-C architecture: 13 14 - Feature modules import `Domain` + `DesignSystem` only (never `Data`, never sibling features) 15 - App target is the convergence point and owns `DependencyContainer`, concrete coordinators, and Route Shell wiring 16 - `Domain` stays pure Swift and defines models plus repository, `*Coordinating`, `ErrorRouting`, and `AppError` contracts 17 - `Data` owns SwiftData/network/sync/retry/background I/O and implements Domain protocols 18 - Read/write flow defaults to stale-while-revalidate reads and optimistic queued writes 19 - ViewModels call repository protocols directly (no default use-case/interactor layer) 20 21 ## When to Apply 22 23 Reference these guidelines when: 24 - Hunting data races, deadlocks, and concurrency crashes in Swift 25 - Auditing memory management for retain cycles and use-after-free 26 - Reviewing async/await code for cancellation and continuation leaks 27 - Stress-testing file I/O and CoreData/SwiftData persistence layers 28 - Writing proof-of-crash tests before implementing fixes 29 30 ## Rule Categories by Priority 31 32 | Priority | Category | Impact | Prefix | 33 |----------|----------|--------|--------| 34 | 1 | Data Races & Thread Safety | CRITICAL | `race-` | 35 | 2 | Memory Corruption & Leaks | CRITICAL | `mem-` | 36 | 3 | Deadlocks & Thread Starvation | HIGH | `dead-` | 37 | 4 | Async/Await & Structured Concurrency | HIGH | `async-` | 38 | 5 | File I/O & Persistence Corruption | MEDIUM-HIGH | `io-` | 39 | 6 | Collection & State Mutation | MEDIUM | `mut-` | 40 | 7 | Resource Exhaustion | MEDIUM | `exhaust-` | 41 | 8 | Objective-C Interop Traps | LOW-MEDIUM | `objc-` | 42 43 ## Quick Reference 44 45 ### 1. Data Races & Thread Safety (CRITICAL) 46 47 - [`race-dictionary-concurrent-write`](references/race-dictionary-concurrent-write.md) - Concurrent Dictionary mutation crashes with EXC_BAD_ACCESS 48 - [`race-array-concurrent-append`](references/race-array-concurrent-append.md) - Concurrent Array append corrupts internal buffer 49 - [`race-property-access`](references/race-property-access.md) - Unsynchronized property read-write across threads 50 - [`race-lazy-initialization`](references/race-lazy-initialization.md) - Lazy property double-initialization under concurrency 51 - [`race-singleton-initialization`](references/race-singleton-initialization.md) - Non-atomic singleton exposes partially constructed state 52 - [`race-bool-flag`](references/race-bool-flag.md) - Non-atomic Bool flag creates check-then-act race 53 - [`race-closure-capture-mutation`](references/race-closure-capture-mutation.md) - Closure captures mutable reference across threads 54 - [`race-delegate-nilification`](references/race-delegate-nilification.md) - Delegate set to nil during active callback 55 56 ### 2. Memory Corruption & Leaks (CRITICAL) 57 58 - [`mem-closure-retain-cycle`](references/mem-closure-retain-cycle.md) - Strong self capture in escaping closures creates retain cycle 59 - [`mem-timer-retain-cycle`](references/mem-timer-retain-cycle.md) - Timer retains target creating undiscoverable retain cycle 60 - [`mem-delegate-strong-reference`](references/mem-delegate-strong-reference.md) - Strong delegate reference prevents deallocation 61 - [`mem-unowned-crash`](references/mem-unowned-crash.md) - Unowned reference crashes after owner deallocation 62 - [`mem-notification-observer-leak`](references/mem-notification-observer-leak.md) - NotificationCenter observer retains closure after removal needed 63 - [`mem-combine-sink-retain`](references/mem-combine-sink-retain.md) - Combine sink retains self without cancellable storage 64 - [`mem-async-task-self-capture`](references/mem-async-task-self-capture.md) - Task captures self extending lifetime beyond expected scope 65 66 ### 3. Deadlocks & Thread Starvation (HIGH) 67 68 - [`dead-sync-on-main`](references/dead-sync-on-main.md) - DispatchQueue.main.sync from main thread deadlocks instantly 69 - [`dead-recursive-lock`](references/dead-recursive-lock.md) - Recursive lock acquisition on same serial queue 70 - [`dead-actor-reentrancy`](references/dead-actor-reentrancy.md) - Actor reentrancy produces unexpected interleaving 71 - [`dead-semaphore-in-async`](references/dead-semaphore-in-async.md) - Semaphore.wait() inside async context deadlocks thread pool 72 - [`dead-queue-hierarchy`](references/dead-queue-hierarchy.md) - Dispatch queue target hierarchy inversion deadlocks 73 - [`dead-mainactor-blocking`](references/dead-mainactor-blocking.md) - Blocking MainActor with synchronous heavy work 74 75 ### 4. Async/Await & Structured Concurrency (HIGH) 76 77 - [`async-missing-cancellation`](references/async-missing-cancellation.md) - Missing Task.isCancelled check wastes resources after navigation 78 - [`async-detached-task-leak`](references/async-detached-task-leak.md) - Detached task without cancellation handle leaks work 79 - [`async-task-group-error`](references/async-task-group-error.md) - TaskGroup silently drops child task errors 80 - [`async-continuation-leak`](references/async-continuation-leak.md) - CheckedContinuation never resumed leaks awaiting task 81 - [`async-actor-hop-starvation`](references/async-actor-hop-starvation.md) - Excessive MainActor hops in hot loop starve UI updates 82 - [`async-unsafe-sendable`](references/async-unsafe-sendable.md) - @unchecked Sendable hides data race from compiler 83 84 ### 5. File I/O & Persistence Corruption (MEDIUM-HIGH) 85 86 - [`io-concurrent-file-write`](references/io-concurrent-file-write.md) - Concurrent file writes corrupt data without coordination 87 - [`io-coredata-cross-thread`](references/io-coredata-cross-thread.md) - CoreData NSManagedObject accessed from wrong thread 88 - [`io-swiftdata-background`](references/io-swiftdata-background.md) - SwiftData model accessed from wrong ModelContext 89 - [`io-plist-concurrent-mutation`](references/io-plist-concurrent-mutation.md) - UserDefaults concurrent read-write produces stale values 90 - [`io-filemanager-race`](references/io-filemanager-race.md) - FileManager existence check then use is a TOCTOU race 91 - [`io-keychain-thread-safety`](references/io-keychain-thread-safety.md) - Keychain access from multiple threads returns unexpected errors 92 93 ### 6. Collection & State Mutation (MEDIUM) 94 95 - [`mut-enumerate-and-mutate`](references/mut-enumerate-and-mutate.md) - Collection mutation during enumeration crashes at runtime 96 - [`mut-kvo-dealloc-crash`](references/mut-kvo-dealloc-crash.md) - KVO observer not removed before deallocation crashes 97 - [`mut-index-out-of-bounds`](references/mut-index-out-of-bounds.md) - Array index access without bounds check crashes 98 - [`mut-force-unwrap`](references/mut-force-unwrap.md) - Force unwrapping optional in production crashes on nil 99 - [`mut-enum-future-cases`](references/mut-enum-future-cases.md) - Non-exhaustive switch crashes on unknown enum case 100 101 ### 7. Resource Exhaustion (MEDIUM) 102 103 - [`exhaust-unbounded-task-spawn`](references/exhaust-unbounded-task-spawn.md) - Unbounded task spawning in loop exhausts memory 104 - [`exhaust-thread-explosion`](references/exhaust-thread-explosion.md) - GCD creates unbounded threads under concurrent load 105 - [`exhaust-urlsession-leak`](references/exhaust-urlsession-leak.md) - URLSession not invalidated leaks delegate and connections 106 - [`exhaust-file-descriptor-leak`](references/exhaust-file-descriptor-leak.md) - File handle not closed leaks file descriptors 107 - [`exhaust-memory-warning-ignored`](references/exhaust-memory-warning-ignored.md) - Low memory warning ignored triggers Jetsam kill 108 109 ### 8. Objective-C Interop Traps (LOW-MEDIUM) 110 111 - [`objc-unrecognized-selector`](references/objc-unrecognized-selector.md) - Missing @objc annotation crashes with unrecognized selector 112 - [`objc-nsnull-in-json`](references/objc-nsnull-in-json.md) - NSNull in decoded JSON collection crashes on access 113 - [`objc-bridge-type-mismatch`](references/objc-bridge-type-mismatch.md) - Swift/ObjC bridge type mismatch crashes at runtime 114 - [`objc-dynamic-dispatch`](references/objc-dynamic-dispatch.md) - Missing dynamic keyword breaks method swizzling 115 116 ## How to Use 117 118 Read individual reference files for detailed explanations and code examples: 119 120 - [Section definitions](references/_sections.md) - Category structure and impact levels 121 - [Rule template](assets/templates/_template.md) - Template for adding new rules 122 123 ## Reference Files 124 125 | File | Description | 126 |------|-------------| 127 | [references/_sections.md](references/_sections.md) | Category definitions and ordering | 128 | [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules | 129 | [metadata.json](metadata.json) | Version and reference information |
ComeOnOliver/skillshub/tree/main/skills/pproenca/dot-skills/ios-chaos-monkey commit c579dbc03f
Frequently asked questions How do I install the IOS Chaos Monkey skill? Run npx skillmds@latest add comeonoliver/ios-chaos-monkey in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the IOS Chaos Monkey skill do? iOS Chaos Monkey — Crash-Hunter Best Practices It is listed under Coding & Dev Tools on SkillMD.
Is IOS Chaos Monkey safe to use? This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: CAUTION, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with IOS Chaos Monkey? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is IOS Chaos Monkey free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published IOS Chaos Monkey? ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.