Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

axiom-core-data-diag

БесплатноБез исполняемых скриптовНе проверен

Use when debugging schema migration crashes, concurrency thread-confinement errors, N+1 query performance, SwiftData to Core Data bridging, or testing…

ComeOnOliverот ComeOnOliver★ 67 звёзд на GitHub

Об этом скилле

Core Data Diagnostics & Migration

Overview

Core Data issues manifest as production crashes from schema mismatches, mysterious concurrency errors, performance degradation under load, and data corruption from unsafe migrations. Core principle 85% of Core Data problems stem from misunderstanding thread-confinement, schema migration requirements, and relationship query patterns—not Core Data defects.

Red Flags — Suspect Core Data Issue

If you see ANY of these, suspect a Core Data misunderstanding, not framework breakage:

  • Crash on production launch: "Unresolvable fault" after schema change
  • Thread-confinement error: "Accessing NSManagedObject on a different thread"
  • App suddenly slow after adding a User→Posts relationship
  • SwiftData app needs complex features; considering mixing Core Data alongside
  • Schema migration works in simulator but crashes on production
  • ❌ FORBIDDEN "Core Data is broken, we need a different database"
    • Core Data handles trillions of records in production apps
    • Schema mismatches and thread errors are always developer code, not framework
    • Do not rationalize away the issue—diagnose it

Critical distinction Simulator deletes the database on each rebuild, hiding schema mismatch issues. Real devices keep persistent databases and crash immediately on schema mismatch. MANDATORY: Test migrations on real device with real data before shipping.

Mandatory First Steps

ALWAYS run these FIRST (before changing code):

// 1. Identify the crash/issue type
// Screenshot the crash message and note:
//   - "Unresolvable fault" = schema mismatch
//   - "different thread" = thread-confinement
//   - Slow performance = N+1 queries or fetch size issues
//   - Data corruption = unsafe migration
// Record: "Crash type: [exact message]"

// 2. Check if it's schema mismatch
// Compare these:
let coordinator = persistentStoreCoordinator
let model = coordinator.managedObjectModel
let store = coordinator.persistentStores.first

// Get actual store schema version:
do {
    let metadata = try NSPersistentStoreCoordinator.metadataForPersistentStore(
        ofType: NSSQLiteStoreType,
        at: storeURL,
        options: nil
    )
    print("Store version identifier: \(metadata[NSStoreModelVersionIdentifiersKey] ?? "unknown")")

    // Get app's current model version:
    print("App model version: \(model.versionIdentifiers)")

    // If different = schema mismatch
} catch {
    print("Schema check error: \(error)")
}
// Record: "Store version vs. app model: match or mismatch?"

// 3. Check thread-confinement for concurrency errors
// For any NSManagedObject access:
print("Main thread? \(Thread.isMainThread)")
print("Context concurrency type: \(context.concurrencyType.rawValue)")
print("Accessing from: \(Thread.current)")
// Record: "Thread mismatch? Yes/no"

// 4. Profile relationship access for N+1 problems
// In Xcode, run with arguments:
// -com.apple.CoreData.SQLDebug 1
// Check Console for SQL queries:
//   SELECT * FROM USERS;  (1 query)
//   SELECT * FROM POSTS WHERE user_id = 1;  (1 query per user = N+1!)
// Record: "N+1 found? Yes/no, how many extra queries"

// 5. Check SwiftData vs. Core Data confusion
if #available(iOS 17.0, *) {
    // If using SwiftData @Model + Core Data simultaneously:
    // Error: "Store is locked" or "EXC_BAD_ACCESS"
    // = trying to access same database from both layers
    print("Using both SwiftData and Core Data on same store?")
}
// Record: "Mixing SwiftData + Core Data? Yes/no"

What this tells you

  • Schema mismatch → Proceed to Pattern 1 (lightweight migration decision)
  • Thread-confinement error → Proceed to Pattern 2 (async/await concurrency)
  • N+1 queries → Proceed to Pattern 3 (relationship prefetching)
  • SwiftData + Core Data conflict → Proceed to Pattern 4 (bridging)
  • Slow after migration → Proceed to Pattern 5 (testing safety)

MANDATORY INTERPRETATION

Before changing ANY code, identify ONE of these:

  1. If crash is "Unresolvable fault" AND store/model versions differ → Schema mismatch (not user error)
  2. If crash mentions "different thread" AND you're using DispatchQueue → Thread-confinement (not thread-safe design)
  3. If performance degrades with relationship access → N+1 queries (check SQL log)
  4. If SwiftData and Core Data code exist together → Conflicting data layers (architectural issue)
  5. If migration test passes but production fails → Edge case in real data (testing gap)

If diagnostics are contradictory or unclear

  • STOP. Do NOT proceed to patterns yet
  • Add print statements to every NSManagedObject access (thread check)
  • Add -com.apple.CoreData.SQLDebug 1 and count SQL queries
  • Establish baseline: what's actually happening vs. what you assumed

Decision Tree

Core Data problem suspected?
├─ Crash: "Unresolvable fault"?
│  └─ YES → Schema mismatch (store ≠ app model)
│     ├─ Add new required field? → Pattern 1a (lightweight migration)
│     ├─ Remov
Полный SKILL.md на GitHub

Установить axiom-core-data-diag в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл axiom-core-data-diag?

Use when debugging schema migration crashes, concurrency thread-confinement errors, N+1 query performance, SwiftData to Core Data bridging, or testing migrations without data loss - systematic Core Data diagnostics with safety-first migration patterns

Как установить скилл axiom-core-data-diag?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл axiom-core-data-diag запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить axiom-core-data-diag с