Back to Skills

apple-on-device-ai

Integrate on-device AI using Foundation Models framework, Core ML, and open-source LLM runtimes on Apple Silicon. Covers Foundation Models (LanguageModelSession, @Generable, @Guide, SystemLanguageModel, structured output, tool calling), Core ML (coremltools, model conversion, quantization, palettization, pruning, Neural Engine, MLTensor), MLX Swift (transformer inference, unified memory), and llama.cpp (GGUF, cross-platform LLM). Use when building tool-calling AI features, working with guided ge

741stars40forksUpdated 6/15/2026

Security Assessment

Safe(95/100)
Security Score95/100

About apple-on-device-ai

This skill is a reference and decision guide for integrating on-device AI on Apple platforms. It addresses the problem of choosing among several overlapping frameworks — Apple Foundation Models, Core ML, MLX Swift, and llama.cpp — and deploying models efficiently on Apple Silicon. It provides a framework-selection router that maps use cases (text generation, structured output, image classification, custom model conversion, cross-platform LLM inference) to the appropriate technology, plus best practices and common-mistake checklists.

The content covers Apple Foundation Models (LanguageModelSession, @Generable and @Guide for guided generation, SystemLanguageModel availability checking, tool calling, locale handling, and always-on guardrails), Core ML (coremltools conversion from PyTorch, TensorFlow, scikit-learn, and XGBoost; quantization, palettization, and pruning; Neural Engine targeting; stateful and multifunction models; deployment targets and compute units), MLX Swift for high-throughput inference of open-source LLMs, and llama.cpp for GGUF-based cross-platform deployment. Supporting reference files detail Core ML conversion and optimization, Foundation Models, and MLX Swift. Code examples show availability checks, conversion pipelines, and input/output type definitions.

It targets iOS, macOS, and Apple Silicon developers building privacy-preserving, on-device AI features, as well as ML engineers converting and optimizing custom models. Use cases include adding tool-calling AI features on Apple Intelligence devices, generating structured output with @Generable types, converting a PyTorch or TensorFlow model to Core ML, and running open-source LLMs with maximum throughput on a Mac. It is a documentation-oriented skill; its examples are standard SDK and CLI usage (pip install, coremltools conversion) with no destructive or network-exfiltration behavior.

FAQ

Which framework should I use for text generation on newer iPhones?

Apple Foundation Models, for devices on iOS 26+/macOS 26+ with Apple Intelligence enabled. It needs no app-managed API key, network round trip, or model hosting, though you must still handle system model asset readiness.

How do I convert a PyTorch model to Core ML?

Use coremltools: call model.eval(), trace with torch.jit.trace (or use torch.export beta), then ct.convert() with input TensorType and a minimum_deployment_target, and save as an .mlpackage (mlprogram format).

Do I have to check model availability before using Foundation Models?

Yes. The skill states availability must always be checked via SystemLanguageModel.default.availability and you should never crash on unavailability; you should also resolve locale support before generating.

When should I pick MLX Swift versus llama.cpp?

MLX Swift is best for maximum sustained token throughput on Apple Silicon and running mlx-community Hugging Face models; llama.cpp is best for GGUF quantized models and cross-platform apps spanning iOS, Android, and desktop.

Can Foundation Models handle complex math or code generation?

The source advises against it — Foundation Models is not suited for complex math, code generation, or strict factual-accuracy tasks, nor for pre-iOS 26 devices.

All Files

6 files
evals/evals.json4.3 KB
View
references/coreml-conversion.md12.8 KB
View
references/coreml-optimization.md10.2 KB
View
references/foundation-models.md15.7 KB
View
references/mlx-swift.md8.2 KB
View
SKILL.md17.7 KB
View

Install apple-on-device-ai

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill