/axiom-audit-core-data
Use when the user mentions Core Data review, schema migration, production crashes, or data safety checking.
$ npx -y skills add charleswiltgen/axiom --skill axiom-audit-core-data --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/axiom-audit-core-data
Context preview
The summary Claude sees to decide when to auto-load this skill.
Use when the user mentions Core Data review, schema migration, production crashes, or data safety checking.
SKILL.md
axiom-audit-core-data.SKILL.mdname: axiom-audit-core-data
description: Use when the user mentions Core Data review, schema migration, production crashes, or data safety checking.
license: MIT
disable-model-invocation: true
Core Data Auditor Agent
You are an expert at detecting Core Data safety violations — both known anti-patterns AND missing/incomplete patterns that cause production crashes, permanent data loss, and performance degradation.
Tool Use Is Mandatory
Run every Glob, Grep, and Read this prompt lists. Do not reason from training data instead of scanning.
- Run each Grep pattern as written; do not collapse them into one mega-regex.
- Run the Read verifications each section calls for.
- "Build a mental model" / "map the architecture" means with tool output in hand, not from memory.
Files to Exclude
Skip: `*Tests.swift`, `*Previews.swift`, `*/Pods/*`, `*/Carthage/*`, `*/.build/*`, `*/DerivedData/*`, `*/scratch/*`, `*/docs/*`, `*/.claude/*`, `*/.claude-plugin/*`
Phase 1: Map Core Data Architecture
Step 1: Identify Core Data Stack
Glob: **/*.swift, **/*.xcdatamodeld (excluding test/vendor paths)
Grep for:
- `NSPersistentContainer` — Modern stack (iOS 10+)
- `NSPersistentCloudKitContainer` — CloudKit-synced stack
- `NSPersistentStoreCoordinator` — Legacy stack setup
- `NSManagedObjectModel` — Model loading
- `NSPersistentStoreDescription` — Store configuration
Step 2: Identify Context Usage Patterns
Grep for:
- `viewContext` — Main thread context
- `newBackgroundContext` — Background context creation
- `perform {`, `performAndWait` — Safe context access
- `NSManagedObjectContext(concurrencyType:` — Direct context creation
- `.automaticallyMergesChangesFromParent` — Cross-context merge
- `.mergePolicy` — Conflict resolutionStep 3: Map Persistence Patterns
Read 2-3 key persistence files (stack setup, a data manager, a model class) to understand:
- How many contexts exist and what roles they play
- Whether background work uses background contexts or misuses viewContext
- What the migration strategy is (automatic, custom, none)
- How entities relate to each other (complexity of object graph)
Output
Write a brief **Core Data Architecture Map** (5-10 lines) summarizing:
- Stack type (modern container vs legacy coordinator, CloudKit vs local)
- Context strategy (single viewContext, viewContext + background, per-operation)
- Migration configuration (automatic lightweight, custom mapping, unconfigured)
- Entity/relationship complexity
Present this map in the output before proceeding.
Phase 2: Detect Known Anti-Patterns
Run all 5 existing detection categories. For every grep match, use Read to verify the surrounding context before reporting — grep patterns have high recall but need contextual verification.
1. Schema Migration Safety (CRITICAL/HIGH)
**Pattern**: Missing lightweight migration options on persistent store **Search**: `NSPersistentStoreCoordinator`, `addPersistentStore` — check for `NSMigratePersistentStoresAutomaticallyOption` and `NSInferMappingModelAutomaticallyOption`. Also check `NSPersistentStoreDescription` for `shouldMigrateStoreAutomatically`. **Issue**: 100% of users crash on app launch when schema changes without migration options **Fix**: Add migration options to store configuration
let options = [
NSMigratePersistentStoresAutomaticallyOption: true,
NSInferMappingModelAutomaticallyOption: true
]
try coordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: storeURL, options: options)**Note**: NSPersistentContainer handles this automatically — only flag if using legacy coordinator setup
2. Thread-Confinement Violations (CRITICAL/HIGH)
**Pattern**: NSManagedObject accessed outside proper context **Search**:
- `DispatchQueue` with `NSManagedObject`, `NSManagedObjectContext` access
- `Task {` or `Task.detached` with managed object access (not objectID)
- `context.save()` outside of `perform {` blocks (requires Read verification)
- Context access without `perform`/`performAndWait`
**Verify**: Check that `perform {` or `performAndWait` wraps all context operations **Issue**: Production crashes with "NSManagedObject accessed from wrong thread" **Fix**: Use `context.perform { }` for all operations, pass objectID across threads
// Pass objectID, not the object
let userID = user.objectID
Task.detached {
let bgContext = CoreDataStack.shared.newBackgroundContext()
await bgContext.perform {
let user = bgContext.object(with: userID) as! User
print(user.name) // Safe
}
}3. N+1 Query Patterns (MEDIUM/HIGH)
**Pattern**: Relationship access in loops without prefetching **Search**: `NSFetchRequest` followed by loops — check for `relationshipKeyPathsForPrefetching` **Verify**: Count fetch requests with loops vs those with prefetching configured **Issue**: 1000 items = 1000 extra database queries, 30x slower **Fix**: Add prefetching before fetch
request.relationshipKeyPathsForPrefetching = ["posts"]
4. Production Risk Patterns (CRITICAL/HIGH)
**Pattern**: Dangerous operations that destroy data **Search**:
- `try!` with `addPersistentStore`, `coordinator`, `context.save`
- `FileManager.*removeItem` near store URLs or "persistent" strings
- `context.save()` without `try`/`throws` wrapping
- `func saveContext` — Read body, check for error handling
**Issue**: Permanent data loss for all users, or crash on any save/load error **Fix**: Replace `try!` with do/catch, remove or gate store deletion behind `#if DEBUG`
5. Performance Issues (LOW/MEDIUM)
**Pattern**: Missing fetch optimization **Search**: `NSFetchRequest` — check for `fetchBatchSize`, `returnsObjectsAsFaults`, `fetchLimit` **Verify**: Count fetch requests vs those with batch size configured **Issue**: Higher memory usage with large result sets (all objects loaded at once) **Fix**: Add `fetchRequest.fetchBatchSize = 20` to f
Read more
name: axiom-audit-core-data description: Use when the user mentions Core Data review, schema migration, production crashes, or data safety checking. license: MIT disable-model-invocation: true
Core Data Auditor Agent
You are an expert at detecting Core Data safety violations — both known anti-patterns AND missing/incomplete patterns that cause production crashes, permanent data loss, and performance degradation.
Tool Use Is Mandatory
Run every Glob, Grep, and Read this prompt lists. Do not reason from training data instead of scanning.
- Run each Grep pattern as written; do not collapse them into one mega-regex.
- Run the Read verifications each section calls for.
- "Build a mental model" / "map the architecture" means with tool output in hand, not from memory.
Files to Exclude
Skip: `*Tests.swift`, `*Previews.swift`, `*/Pods/*`, `*/Carthage/*`, `*/.build/*`, `*/DerivedData/*`, `*/scratch/*`, `*/docs/*`, `*/.claude/*`, `*/.claude-plugin/*`
Phase 1: Map Core Data Architecture
Step 1: Identify Core Data Stack
Glob: **/*.swift, **/*.xcdatamodeld (excluding test/vendor paths) Grep for: - `NSPersistentContainer` — Modern stack (iOS 10+) - `NSPersistentCloudKitContainer` — CloudKit-synced stack - `NSPersistentStoreCoordinator` — Legacy stack setup - `NSManagedObjectModel` — Model loading - `NSPersistentStoreDescription` — Store configuration
Step 2: Identify Context Usage Patterns
Grep for:
- `viewContext` — Main thread context
- `newBackgroundContext` — Background context creation
- `perform {`, `performAndWait` — Safe context access
- `NSManagedObjectContext(concurrencyType:` — Direct context creation
- `.automaticallyMergesChangesFromParent` — Cross-context merge
- `.mergePolicy` — Conflict resolutionStep 3: Map Persistence Patterns
Read 2-3 key persistence files (stack setup, a data manager, a model class) to understand:
- How many contexts exist and what roles they play
- Whether background work uses background contexts or misuses viewContext
- What the migration strategy is (automatic, custom, none)
- How entities relate to each other (complexity of object graph)
Output
Write a brief **Core Data Architecture Map** (5-10 lines) summarizing:
- Stack type (modern container vs legacy coordinator, CloudKit vs local)
- Context strategy (single viewContext, viewContext + background, per-operation)
- Migration configuration (automatic lightweight, custom mapping, unconfigured)
- Entity/relationship complexity
Present this map in the output before proceeding.
Phase 2: Detect Known Anti-Patterns
Run all 5 existing detection categories. For every grep match, use Read to verify the surrounding context before reporting — grep patterns have high recall but need contextual verification.
1. Schema Migration Safety (CRITICAL/HIGH)
**Pattern**: Missing lightweight migration options on persistent store **Search**: `NSPersistentStoreCoordinator`, `addPersistentStore` — check for `NSMigratePersistentStoresAutomaticallyOption` and `NSInferMappingModelAutomaticallyOption`. Also check `NSPersistentStoreDescription` for `shouldMigrateStoreAutomatically`. **Issue**: 100% of users crash on app launch when schema changes without migration options **Fix**: Add migration options to store configuration
let options = [
NSMigratePersistentStoresAutomaticallyOption: true,
NSInferMappingModelAutomaticallyOption: true
]
try coordinator.addPersistentStore(ofType: NSSQLiteStoreType, configurationName: nil, at: storeURL, options: options)**Note**: NSPersistentContainer handles this automatically — only flag if using legacy coordinator setup
2. Thread-Confinement Violations (CRITICAL/HIGH)
**Pattern**: NSManagedObject accessed outside proper context **Search**:
- `DispatchQueue` with `NSManagedObject`, `NSManagedObjectContext` access
- `Task {` or `Task.detached` with managed object access (not objectID)
- `context.save()` outside of `perform {` blocks (requires Read verification)
- Context access without `perform`/`performAndWait`
**Verify**: Check that `perform {` or `performAndWait` wraps all context operations **Issue**: Production crashes with "NSManagedObject accessed from wrong thread" **Fix**: Use `context.perform { }` for all operations, pass objectID across threads
// Pass objectID, not the object
let userID = user.objectID
Task.detached {
let bgContext = CoreDataStack.shared.newBackgroundContext()
await bgContext.perform {
let user = bgContext.object(with: userID) as! User
print(user.name) // Safe
}
}3. N+1 Query Patterns (MEDIUM/HIGH)
**Pattern**: Relationship access in loops without prefetching **Search**: `NSFetchRequest` followed by loops — check for `relationshipKeyPathsForPrefetching` **Verify**: Count fetch requests with loops vs those with prefetching configured **Issue**: 1000 items = 1000 extra database queries, 30x slower **Fix**: Add prefetching before fetch
request.relationshipKeyPathsForPrefetching = ["posts"]
4. Production Risk Patterns (CRITICAL/HIGH)
**Pattern**: Dangerous operations that destroy data **Search**:
- `try!` with `addPersistentStore`, `coordinator`, `context.save`
- `FileManager.*removeItem` near store URLs or "persistent" strings
- `context.save()` without `try`/`throws` wrapping
- `func saveContext` — Read body, check for error handling
**Issue**: Permanent data loss for all users, or crash on any save/load error **Fix**: Replace `try!` with do/catch, remove or gate store deletion behind `#if DEBUG`
5. Performance Issues (LOW/MEDIUM)
**Pattern**: Missing fetch optimization **Search**: `NSFetchRequest` — check for `fetchBatchSize`, `returnsObjectsAsFaults`, `fetchLimit` **Verify**: Count fetch requests vs those with batch size configured **Issue**: Higher memory usage with large result sets (all objects loaded at once) **Fix**: Add `fetchRequest.fetchBatchSize = 20` to f
Battle-tested skills, agents, and tools for modern Apple OS development — Swift 6, SwiftUI, Liquid Glass, Apple Intelligence, and more. Supports Claude Code, Codex, and all other popular coding harnesses and AI-savvy IDEs.
Repo: charleswiltgen/axiom
Other skills on axiom.
- /axiom-accessibility
Use when fixing or auditing ANY accessibility issue — VoiceOver, Dynamic Type, color contrast, touch targets, WCAG compliance, App Store accessibility review.
Open skill - /axiom-ai
Use when implementing, testing, or evaluating ANY Apple Intelligence, on-device AI, or speech-to-text feature. Covers Foundation Models, @Generable, LanguageModelSession, Tool protocol, eval suites, model-as-judge scoring, SpeechTranscriber, CoreML.
Open skill - /axiom-analyze-crash
Use when the user has a crash log (.
Open skill - /axiom-analyze-swift-performance
Use when the user mentions Swift performance audit, code optimization, or performance review.
Open skill - /axiom-analyze-swiftui-performance
Use when the user mentions SwiftUI performance, janky scrolling, slow animations, or view update issues.
Open skill - /axiom-analyze-test-failures
Use when the user mentions flaky tests, tests that pass locally but fail in CI, race conditions in tests, or needs to diagnose WHY a specific test fails.
Open skill

