install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/ios-chaos-monkey" ~/.claude/skills/comeonoliver-skillshub-ios-chaos-monkey && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/ios-chaos-monkey/SKILL.mdsource content
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
only (neverDesignSystem
, never sibling features)Data - App target is the convergence point and owns
, concrete coordinators, and Route Shell wiringDependencyContainer
stays pure Swift and defines models plus repository,Domain
,*Coordinating
, andErrorRouting
contractsAppError
owns SwiftData/network/sync/retry/background I/O and implements Domain protocolsData- 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 | |
| 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_ACCESSrace-dictionary-concurrent-write
- Concurrent Array append corrupts internal bufferrace-array-concurrent-append
- Unsynchronized property read-write across threadsrace-property-access
- Lazy property double-initialization under concurrencyrace-lazy-initialization
- Non-atomic singleton exposes partially constructed staterace-singleton-initialization
- Non-atomic Bool flag creates check-then-act racerace-bool-flag
- Closure captures mutable reference across threadsrace-closure-capture-mutation
- Delegate set to nil during active callbackrace-delegate-nilification
2. Memory Corruption & Leaks (CRITICAL)
- Strong self capture in escaping closures creates retain cyclemem-closure-retain-cycle
- Timer retains target creating undiscoverable retain cyclemem-timer-retain-cycle
- Strong delegate reference prevents deallocationmem-delegate-strong-reference
- Unowned reference crashes after owner deallocationmem-unowned-crash
- NotificationCenter observer retains closure after removal neededmem-notification-observer-leak
- Combine sink retains self without cancellable storagemem-combine-sink-retain
- Task captures self extending lifetime beyond expected scopemem-async-task-self-capture
3. Deadlocks & Thread Starvation (HIGH)
- DispatchQueue.main.sync from main thread deadlocks instantlydead-sync-on-main
- Recursive lock acquisition on same serial queuedead-recursive-lock
- Actor reentrancy produces unexpected interleavingdead-actor-reentrancy
- Semaphore.wait() inside async context deadlocks thread pooldead-semaphore-in-async
- Dispatch queue target hierarchy inversion deadlocksdead-queue-hierarchy
- Blocking MainActor with synchronous heavy workdead-mainactor-blocking
4. Async/Await & Structured Concurrency (HIGH)
- Missing Task.isCancelled check wastes resources after navigationasync-missing-cancellation
- Detached task without cancellation handle leaks workasync-detached-task-leak
- TaskGroup silently drops child task errorsasync-task-group-error
- CheckedContinuation never resumed leaks awaiting taskasync-continuation-leak
- Excessive MainActor hops in hot loop starve UI updatesasync-actor-hop-starvation
- @unchecked Sendable hides data race from compilerasync-unsafe-sendable
5. File I/O & Persistence Corruption (MEDIUM-HIGH)
- Concurrent file writes corrupt data without coordinationio-concurrent-file-write
- CoreData NSManagedObject accessed from wrong threadio-coredata-cross-thread
- SwiftData model accessed from wrong ModelContextio-swiftdata-background
- UserDefaults concurrent read-write produces stale valuesio-plist-concurrent-mutation
- FileManager existence check then use is a TOCTOU raceio-filemanager-race
- Keychain access from multiple threads returns unexpected errorsio-keychain-thread-safety
6. Collection & State Mutation (MEDIUM)
- Collection mutation during enumeration crashes at runtimemut-enumerate-and-mutate
- KVO observer not removed before deallocation crashesmut-kvo-dealloc-crash
- Array index access without bounds check crashesmut-index-out-of-bounds
- Force unwrapping optional in production crashes on nilmut-force-unwrap
- Non-exhaustive switch crashes on unknown enum casemut-enum-future-cases
7. Resource Exhaustion (MEDIUM)
- Unbounded task spawning in loop exhausts memoryexhaust-unbounded-task-spawn
- GCD creates unbounded threads under concurrent loadexhaust-thread-explosion
- URLSession not invalidated leaks delegate and connectionsexhaust-urlsession-leak
- File handle not closed leaks file descriptorsexhaust-file-descriptor-leak
- Low memory warning ignored triggers Jetsam killexhaust-memory-warning-ignored
8. Objective-C Interop Traps (LOW-MEDIUM)
- Missing @objc annotation crashes with unrecognized selectorobjc-unrecognized-selector
- NSNull in decoded JSON collection crashes on accessobjc-nsnull-in-json
- Swift/ObjC bridge type mismatch crashes at runtimeobjc-bridge-type-mismatch
- Missing dynamic keyword breaks method swizzlingobjc-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 |