Axiom ai

From CharlesWiltgen/Axiom · View interactive version

Axiom ai is an AI agent skill from the GitHub repository CharlesWiltgen/Axiom. 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.

How to use this skill

Skill file

Apple Intelligence & AI

You MUST use this skill for ANY Apple Intelligence or Foundation Models work.

<!-- AXIOM_AUDITOR_INLINE_BEGIN — auto-maintained by scripts/build-inlined-auditors.ts; do not hand-edit -->

Can't launch Axiom agents? Where this router sends you to an agent, follow its procedure inline. Over MCP, axiom_get_agent returns it; elsewhere, read its file below, which needs only file search and read.

Available here: skills/foundation-models-auditor.md.

For any other agent, over MCP axiom_get_agent returns it too; run its xclog, xcsym and xcprof steps with the axiom_xclog_*, axiom_xcsym_* and axiom_xcprof_* tools. Elsewhere, search Axiom's skills for skills/<agent>.md; if there is none, do that work yourself with this suite's skills, using any Axiom tool on your PATH.

<!-- AXIOM_AUDITOR_INLINE_END -->

When to Use

Use this router when:

AI Approach Triage

First, determine which kind of AI the developer needs:

| Developer Intent | Route To |

|-----------------|----------|

| On-device text generation (Apple Intelligence) | Stay here → Foundation Models skills |

| Custom ML model deployment (PyTorch, TensorFlow) — classic Core ML | See skills/ios-ml.md (hub) → conversion / compression / training / deployment / ref / diag files |

| Core ML model fails to load, is slow, grows memory, or loses accuracy after compression | See skills/coreml-diag.md |

| Custom LLM-scale / transformer model on-device (27-cycle) | See skills/core-ai.md → Core AI conversion, runtime, specialization |

| Computer vision (image analysis, OCR, segmentation) | /skill axiom-vision → Vision framework |

| Cloud API integration (OpenAI, generic HTTP) | /skill axiom-networking → URLSession patterns |

| Cloud Claude integration (Anthropic SDK, Messages API, Claude Agent SDK) | See claude-api skill (external) → includes automated Opus 4.6 → 4.7 migration |

| Speech-to-text / transcription (SpeechAnalyzer, SpeechTranscriber, DictationTranscriber, mic → transcript) | See skills/speech.md (OS27 input providers, Swift 6 mic-tap isolation, the ~2-analyzer cap on iOS/visionOS; none on macOS) |

| Turnkey Apple Intelligence UI — suggested actions for a messaging conversation (OS27) | See skills/suggested-actions.md → drop-in SuggestedActionsView, entitlement-gated |

| Siri AI calling the app's actions — ToolIntent/@AppIntent(.tool), @AppEntity(.generable), App Skills, SiriEvaluations (27.3) | Use axiom-integration → axiom-integration (skills/siri-ai.md), axiom-integration (skills/siri-evaluations-ref.md) (App Intents, not Foundation Models Tool) |

| System AI features (Writing Tools, Genmoji) | No custom code needed — these are system-provided |

Key boundary: Foundation Models vs ML (custom models)

Training Path Boundaries

When developers say "I need to train / fine-tune / personalize a model," four distinct paths exist. They are often conflated; each has different output, lifecycle, and runtime compatibility.

| Path | Trains | Output | Lifecycle | Routes to |

|------|--------|--------|-----------|-----------|

| FM custom adapter (26-cycle only — runtime obsoleted in 27.0) | Apple's frozen on-device 3B LLM (rank-32 LoRA) | .fmadapter package, ~160 MB | Build-time per OS version, delivered via Background Assets | skills/foundation-models-adapters.md (discipline) + skills/foundation-models-adapters-ref.md (toolkit + runtime) + skills/foundation-models-adapters-diag.md (failure modes); delivery via axiom-integration (skills/background-assets.md) |

| Core ML MLUpdateTask | Your NN-spec model's fully-connected and convolutional layers | Updated .mlmodelc saved to disk | Runtime, per-user (on-device personalization) | skills/coreml-training.md |

| Create ML | A new Core ML model from scratch / transfer learning | .mlmodel | Build-time, on Mac or iOS (per type) | skills/coreml-training.md |

| MLX LM (mlx_lm.lora) | Open-source LLMs on Apple Silicon | adapters/adapters.safetensors — NOT loadable by Foundation Models | Build-time; not an iOS distribution path | External — outside Axiom scope; treat as adjacent research tool |

| Server LLM fine-tune | Cloud-hosted model (e.g., vendor fine-tunes) | Cloud artifact, accessed via API | Build-time; runs in cloud | /skill axiom-networking for the API integration; the fine-tune workflow is the vendor's domain |

Critical distinctions:

For the full "which path applies to me?" disambiguation (decision tree, the three week-costing mistakes, per-path routing) → skills/training-paths.md.

Cross-Domain Routing

Foundation Models + concurrency (UI freezes during generation, concurrent-request errors):

Foundation Models + data (@Generable decoding errors, structured output issues):

Foundation Models + security (prompt injection, securing agent tools, confirmation gating):

Speech-to-text + audio capture (transcription that fights your audio session):

Routing Logic

Custom Core ML Work (your own models, not Apple's LLM)

skills/ios-ml.md is the hub. Each stage has a dedicated file:

Core AI — the 27-cycle path for LLM-scale on-device models (`OS27`)

skills/core-ai.md covers Core AI, the on-device inference framework that powers Apple Intelligence and is now open to your apps. Route here (not skills/ios-ml.md) when the model is LLM-scale / a transformer, or when the developer needs custom Metal kernels, multi-function assets, ahead-of-time compilation, KV-cache states, or the specialization/caching deployment model. Covers the Python toolchain (coreai-torch/coreai-opt), the Swift runtime (import CoreAI → AIModel/InferenceFunction/NDArray), specialization discipline, and the Foundation Models bridge (CoreAILanguageModel from the open-source coreai-models package — not a system-framework type).

Turnkey Apple Intelligence UI — Suggested Actions (`OS27`)

skills/suggested-actions.md covers the SuggestedActions framework: a drop-in SwiftUI SuggestedActionsView that renders Apple-Intelligence-generated suggested actions for a messaging conversation (iOS/macOS/macCatalyst/visionOS 27). This is a system-provided feature — you describe the message (SuggestedActionsMessage) and add the com.apple.developer.suggested-actions entitlement; there's no LanguageModelSession, prompt, or @Generable. Route here for messaging/chat/email apps that want inline system suggestions. If the developer wants to generate their own structured output, that's Foundation Models, not this. The entitlement/capability half also surfaces via axiom-integration, which cross-points back here.

Foundation Models Work

Implementation patterns → skills/foundation-models.md

API reference → skills/foundation-models-ref.md

Diagnostics → skills/foundation-models-diag.md

Guardrails & safety decisions → skills/foundation-models-guardrails.md

Evaluation-driven development — the discipline (OS27) → skills/foundation-models-evaluations.md

Evaluation failures — the suite is lying to you (OS27) → skills/foundation-models-evaluations-diag.md

Evaluations framework API (OS27) → skills/foundation-models-evaluations-ref.md

Custom adapter training (after Approach Triage rungs 1-4) → skills/foundation-models-adapters.md

Adapter toolkit & runtime API → skills/foundation-models-adapters-ref.md

Adapter-specific diagnostics → skills/foundation-models-adapters-diag.md

Automated scanning → Launch foundation-models-auditor agent or /axiom:audit foundation-models

Detects anti-patterns AND architectural gaps:

Scores: PRODUCTION-READY / NEEDS HARDENING / FRAGILE

Decision Tree

  1. Custom ML model / CoreML? → skills/ios-ml.md hub → convert (coreml-conversion.md), compress (coreml-compression.md), train/personalize (coreml-training.md), deploy (coreml-deployment.md), API (coreml-ref.md), failures (coreml-diag.md). LLM-scale / transformer / 27-cycle custom model? → skills/core-ai.md (Core AI)
  2. Computer vision / image analysis / OCR? → /skill axiom-vision
  3. Cloud AI API integration? → /skill axiom-networking
  4. Implementing Foundation Models / @Generable / Tool protocol? → foundation-models
  5. Need API reference / code examples? → foundation-models-ref
  6. Debugging AI issues (blocked, slow, guardrails)? → foundation-models-diag
  7. Foundation Models + UI freezing? → foundation-models-diag (Pattern 5a, main-actor work) + also invoke axiom-concurrency if needed
  8. Considering training a custom adapter? → foundation-models Approach Triage (rungs 1-4) FIRST; only after documented rung-1-4 failures → foundation-models-adapters
  9. Implementing adapter loading, training pipeline, or runtime selection? → foundation-models-adapters + foundation-models-adapters-ref + axiom-integration (skills/background-assets.md) for delivery
  10. Debugging adapter-specific failures (compatibleAdapterNotFound, tool calls don't fire from adapter, accuracy regression after OS update)? → foundation-models-adapters-diag
  11. Want automated Foundation Models code scan? → foundation-models-auditor (Agent — detects 14 anti-patterns AND completeness gaps including prompt injection, frozen-enum discipline, transcript trimming, Cancel UX, missing/uncalibrated eval suites; scores PRODUCTION-READY / NEEDS HARDENING / FRAGILE)
  12. Measuring whether an AI feature improved/regressed, designing an eval dataset, calibrating a model judge, or about to ship on eyeballed outputs? → foundation-models-evaluations (discipline) + foundation-models-evaluations-ref (API) — OS27 Evaluations framework
  13. Adding Apple's built-in suggested actions to a messaging/chat/email app (SuggestedActionsView, suggested-actions entitlement)? → skills/suggested-actions.md (OS27 — turnkey, system-provided; NOT Foundation Models)
  14. Speech-to-text, live captions, or transcribing a file (SpeechAnalyzer, SpeechTranscriber, DictationTranscriber, SFSpeechRecognizer, mic → transcript)? → skills/speech.md

Anti-Rationalization

| Thought | Reality |

|---------|---------|

| "Foundation Models is just LanguageModelSession" | Foundation Models has @Generable, Tool protocol, streaming, and guardrails. foundation-models covers all. |

| "I'll figure out the AI patterns as I go" | AI APIs have specific error handling and fallback requirements. foundation-models prevents runtime failures. |

| "I've used LLMs before, this is similar" | Apple's on-device models have unique constraints (guardrails, context limits). foundation-models is Apple-specific. |

| "I know the Anthropic SDK already" | Opus 4.7 removed temperature, top_p, top_k, and prefill from the Messages API. Code that worked on 4.6 returns HTTP 400 at runtime. Read claude-api (external) before changing model IDs. |

| "We need to train a custom adapter to fix the model's outputs" | Most "we need an adapter" requests resolve via rungs 1-4 of the Approach Triage (prompt engineering, @Generable/@Guide, tool calling, built-in content-tagging adapter). foundation-models has the ladder; foundation-models-adapters is only justified after each rung's failure is documented. |

| "We trained one adapter, ship it for all our users" | Each .fmadapter pins to one base-model version; one adapter does not cover a multi-OS install base. foundation-models-adapters covers per-OS variant strategy and compatibleAdapterIdentifiers(name:) runtime selection. |

| "Skip locale-specific eval, our users are mostly English-speaking" | Apple's 2025 tech report groups eval as English-US / English-outside-US / PFIGSCJK. English-only eval against a multi-locale app ships invisible non-English regressions. foundation-models-adapters covers the four-axis eval requirement. |

| "The output looked good on the prompts I tried — ship it" | Five good results say nothing about the five hundred that fail, and the model changes under you on every OS update with no code change on your side. foundation-models-evaluations turns the prompts you already tried by hand into a gate. |

| "Our model judge agrees with me, I spot-checked it" | Your data skews toward decent output, so a judge that always scores high looks aligned on a spot-check and drifts hardest at scale. Apple's own sample judge starts at Cohen's kappa −0.037. foundation-models-evaluations has the calibration protocol. |

| "Just bundle the .fmadapter file in the app" | Apple's docs explicitly prohibit this. Adapters ship via Background Assets onDemand policy. axiom-integration (skills/background-assets.md) covers the delivery half. |

| "We'll add a custom adapter for our iOS 27 app" | The custom-adapter runtime (SystemLanguageModel.Adapter) is obsoleted in 27.0 and does not compile on a 27 deployment target — no replacement in the 27 SDK. foundation-models-adapters covers the pivot: rungs 1-4 or a custom provider (LanguageModelExecutor). |

External Resources

Cloud Claude integration (claude-api skill, ships outside Axiom). Opus 4.7 removed temperature, top_p, top_k, and prefill from the Messages API — code that built successfully on 4.6 returns HTTP 400 at runtime, not compile time. The claude-api skill automates the migration (model ID swap, sampling-param removal, prefill replacement) and enforces prompt caching from day one. Skipping it costs an afternoon of production debugging when the first 400s arrive.

Apple's on-device Foundation Models and Anthropic's cloud Claude are unrelated stacks; use both in parallel when an app needs both, and treat claude-api as mandatory reading before any Claude model-ID change ships.

Critical Patterns

foundation-models:

foundation-models-diag:

Example Invocations

User: "How do I use Apple Intelligence to generate structured data?"

→ Read: skills/foundation-models.md

User: "My AI generation is being blocked"

→ Read: skills/foundation-models-diag.md

User: "Show me @Generable examples"

→ Read: skills/foundation-models-ref.md

User: "Implement streaming AI generation"

→ Read: skills/foundation-models.md

User: "I want to add AI to my app"

→ First ask: Apple Intelligence (Foundation Models) or custom ML model? Route accordingly.

User: "My Foundation Models session is blocking the UI"

→ Read: skills/foundation-models-diag.md (Pattern 5a: the freeze is main-actor work, not the await) + also invoke axiom-concurrency if needed

User: "Review my Foundation Models code for issues"

→ Invoke: foundation-models-auditor agent

User: "I want to run my PyTorch model on device"

→ Read: skills/ios-ml.md (classic Core ML hub, not Foundation Models) → skills/coreml-conversion.md then skills/coreml-deployment.md

User: "My Core ML model takes seconds to load the first time" / "prediction is slow on iPhone but fast on my Mac"

→ Read: skills/coreml-diag.md

User: "I want to run my own LLM / SAM segmentation model on device" / "convert a PyTorch transformer with Core AI" / "my Core AI model stalls on first launch"

→ Read: skills/core-ai.md (Core AI conversion, runtime, specialization & caching)

User: "How do I train a custom adapter for our app's summarization?"

→ Read: skills/foundation-models.md (Approach Triage rungs 1-4 FIRST), then skills/foundation-models-adapters.md only if rung-1-4 failures are documented

User: "Our adapter loaded fine on iOS 26.0 but throws compatibleAdapterNotFound on 26.1"

→ Read: skills/foundation-models-adapters-diag.md (Pattern 1)

User: "What's the toolkit setup for adapter training?"

→ Read: skills/foundation-models-adapters-ref.md (Toolkit Setup)

User: "How do we ship a custom adapter to users?"

→ Read: skills/foundation-models-adapters.md (runtime lifecycle) + axiom-integration (skills/background-assets.md) (delivery)

User: "How do I measure if my prompt change made the tagging feature better?" / "Write an eval suite for my AI feature" / "The output looks good, can we ship?"

→ Read: skills/foundation-models-evaluations.md (the discipline — dataset design, guardrails vs optimization target, hill-climbing) + skills/foundation-models-evaluations-ref.md (the API — Metrics, .evaluates, model-as-judge, tool-call eval)

User: "My model judge is giving weird scores" / "How do I know I can trust the judge?"

→ Read: skills/foundation-models-evaluations.md (Judge Discipline — the four biases, Cohen's kappa > 0.6 calibration protocol, debugging from rationales)

User: "My eval metric returns -1" / "Our pass rate went up when we added harder test cases" / "The eval suite passes but I don't think it measured anything"

→ Read: skills/foundation-models-evaluations-diag.md (the framework fails silently — a green suite is not evidence a run happened)

User: "Add live transcription with SpeechAnalyzer"

→ Read: skills/speech.md

User: "Add Apple's suggested actions to my messaging app" / "Show smart/on-device suggested replies for a message thread" / "What's the com.apple.developer.suggested-actions entitlement for?"

→ Read: skills/suggested-actions.md (turnkey SuggestedActionsView, system-provided — not Foundation Models)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.