$npx -y skills add rshankras/claude-code-apple-skills --skill core-mlCore ML, Create ML, Vision framework, Natural Language framework, on-device ML integration. Use when user wants image classification, text analysis, object detection, sound classification, model optimization, or custom model integration. Covers Core ML vs Foundation Models decisi
| 1 | # Core ML Skills |
| 2 | |
| 3 | Combined advisory, generator, and workflow skill for integrating machine learning into Apple platform apps. Covers Core ML model integration, Vision framework image analysis, NaturalLanguage framework text processing, Create ML training, and on-device model optimization. |
| 4 | |
| 5 | ## When This Skill Activates |
| 6 | |
| 7 | Use this skill when the user: |
| 8 | - Wants to add ML capabilities to their app |
| 9 | - Needs to integrate a Core ML model (.mlmodel) into an Xcode project |
| 10 | - Wants to use the Vision framework for image analysis (faces, text recognition, body pose, object detection) |
| 11 | - Wants to use the NaturalLanguage framework for text processing (sentiment, entities, language detection) |
| 12 | - Needs to train a custom model with Create ML |
| 13 | - Wants to optimize a model for on-device use (quantization, pruning, palettization) |
| 14 | - Needs to choose between Core ML and Foundation Models (Apple Intelligence) |
| 15 | - Asks about image classification, object detection, sound classification, or tabular data prediction |
| 16 | - Wants real-time camera + ML processing |
| 17 | |
| 18 | ## Decision Guide: Core ML vs Foundation Models |
| 19 | |
| 20 | Before generating code, determine which framework is appropriate. |
| 21 | |
| 22 | ### Use Foundation Models (Apple Intelligence) When: |
| 23 | - You need general-purpose text generation, summarization, or conversational AI |
| 24 | - Target is iOS 26+ / macOS 26+ (Foundation Models requires Apple Silicon + latest OS) |
| 25 | - The task is open-ended language understanding or generation |
| 26 | - You want `@Generable` structured output from natural language |
| 27 | - See `apple-intelligence/foundation-models/` skill for implementation |
| 28 | |
| 29 | ### Use Core ML When: |
| 30 | - You need specialized ML: image classification, object detection, sound classification, custom regression/classification |
| 31 | - You have a trained model (.mlmodel, .mlpackage) or plan to train one |
| 32 | - You need broad device support (iOS 14+ / macOS 11+) |
| 33 | - The task requires domain-specific predictions (medical imaging, product recognition, custom NLP) |
| 34 | - Performance-critical inference on Neural Engine or GPU |
| 35 | |
| 36 | ### Use Vision Framework When (No Custom Model Needed): |
| 37 | - Image classification using Apple's built-in models |
| 38 | - Face detection and facial landmark analysis |
| 39 | - Text recognition (OCR) with `VNRecognizeTextRequest` |
| 40 | - Body and hand pose detection |
| 41 | - Barcode and QR code scanning |
| 42 | - Image similarity and saliency detection |
| 43 | - Horizon detection, rectangle detection |
| 44 | |
| 45 | ### Use NaturalLanguage Framework When (No Custom Model Needed): |
| 46 | - Sentiment analysis on text |
| 47 | - Language identification |
| 48 | - Tokenization (word, sentence, paragraph boundaries) |
| 49 | - Named entity recognition (people, places, organizations) |
| 50 | - Word and sentence embeddings for similarity comparison |
| 51 | - Lemmatization and part-of-speech tagging |
| 52 | |
| 53 | ## Pre-Generation Checks |
| 54 | |
| 55 | ### 1. Project Context Detection |
| 56 | - [ ] Check deployment target (Core ML requires iOS 11+ / macOS 10.13+; Vision requires iOS 11+; NaturalLanguage requires iOS 12+) |
| 57 | - [ ] Check for existing ML code or models |
| 58 | - [ ] Identify project structure and source file locations |
| 59 | - [ ] Determine if SwiftUI or UIKit/AppKit |
| 60 | |
| 61 | ### 2. Conflict Detection |
| 62 | Search for existing ML integration: |
| 63 | ``` |
| 64 | Glob: **/*Model*.swift, **/*Classifier*.swift, **/*Predictor*.swift, **/*.mlmodel, **/*.mlmodelc, **/*.mlpackage |
| 65 | Grep: "import CoreML" or "import Vision" or "import NaturalLanguage" |
| 66 | ``` |
| 67 | |
| 68 | If found, ask user: |
| 69 | - Extend existing ML setup? |
| 70 | - Replace with new implementation? |
| 71 | - Add additional model/capability? |
| 72 | |
| 73 | ## Configuration Questions |
| 74 | |
| 75 | Ask user via AskUserQuestion: |
| 76 | |
| 77 | 1. **What ML capability do you need?** |
| 78 | - Image classification (identify objects in photos) |
| 79 | - Object detection (locate objects with bounding boxes) |
| 80 | - Text analysis (sentiment, entities, language) |
| 81 | - Custom Core ML model integration |
| 82 | - Vision framework (OCR, faces, poses) |
| 83 | - Sound classification |
| 84 | - Tabular data prediction |
| 85 | |
| 86 | 2. **Do you have a trained model, or need to train one?** |
| 87 | - I have a .mlmodel / .mlpackage file |
| 88 | - I want to train with Create ML |
| 89 | - I want to use Apple's built-in models (Vision / NaturalLanguage) |
| 90 | |
| 91 | 3. **Performance requirements?** |
| 92 | - Real-time (camera feed, < 33ms per prediction) |
| 93 | - Interactive (user-initiated, < 500ms acceptable) |
| 94 | - Background processing (batch, latency not critical) |
| 95 | |
| 96 | ## Core ML Model Integration |
| 97 | |
| 98 | ### Adding a Model to Xcode |
| 99 | 1. Drag `.mlmodel` or `.mlpackage` into Xcode project navigator |
| 100 | 2. Xcode auto-generates a Swift class with the model name |
| 101 | 3. The generated class provides type-safe input/output interfaces |
| 102 | 4. Xcode compiles to `.mlmodelc` at build time (optimized for device) |
| 103 | |
| 104 | ### Loading Models |