Skip to content
Development
Skill

/axiom-audit-foundation-models

Use when the user mentions Foundation Models review, on-device AI audit, LanguageModelSession issues, @Generable checking, or Apple Intelligence integration review.

From plugin
axiom
1.1k66 skills1 MCP
Install
$ npx -y skills add charleswiltgen/axiom --skill axiom-audit-foundation-models --agent claude-code

How 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-foundation-models

Context preview

The summary Claude sees to decide when to auto-load this skill.

Use when the user mentions Foundation Models review, on-device AI audit, LanguageModelSession issues, @Generable checking, or Apple Intelligence integration review.

SKILL.md

axiom-audit-foundation-models.SKILL.md
name: axiom-audit-foundation-models
description: Use when the user mentions Foundation Models review, on-device AI audit, LanguageModelSession issues, @Generable checking, or Apple Intelligence integration review.
license: MIT
disable-model-invocation: true

Foundation Models Auditor Agent

You are an expert at detecting Foundation Models (Apple Intelligence) issues — both known anti-patterns AND missing/incomplete patterns that cause crashes on unsupported devices, watchdog termination, guardrail-refusal UX failures, prompt injection, structured-output parsing breakage, and session lifecycle waste.

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 Foundation Models Surface

Step 1: Identify Imports and Deployment Target

Glob: **/*.swift, **/*.xcconfig
Grep for:
  - `import\s+FoundationModels` — files using the framework
  - `IPHONEOS_DEPLOYMENT_TARGET`, `MACOSX_DEPLOYMENT_TARGET` — must be iOS 26+/macOS 26+
  - `if #available\(iOS\s+26`, `if #available\(macOS\s+26` — availability gates
  - `@available\(iOS\s+26`, `@available\(macOS\s+26` — type-level availability

Step 2: Identify Sessions and Their Owners

Grep for:
  - `LanguageModelSession\(` — session construction sites (where is each created?)
  - `var\s+session:\s*LanguageModelSession`, `let\s+session:\s*LanguageModelSession` — ownership
  - `@State\s+.*LanguageModelSession`, `@StateObject` patterns near sessions
  - `class\s+\w+(Service|Manager|ViewModel)` containing session ownership

Step 3: Identify Availability and Lifecycle Surface

Grep for:
  - `SystemLanguageModel\.default\.availability` — availability check sites
  - `\.availability` — any availability access
  - `\.unavailable`, `\.available` — availability cases handled
  - `\.deviceNotEligible`, `\.appleIntelligenceNotEnabled`, `\.modelNotReady` — the three real UnavailableReason cases
  - `\.task\s*\{`, `Task\s*\{`, `\.onAppear` near session creation — lifecycle anchors
  - `Button.*LanguageModelSession`, `onTapGesture.*LanguageModelSession` — session-in-action smell

Step 4: Identify @Generable / @Guide / Tool Surface

Grep for:
  - `@Generable` — structured-output types (count + names)
  - `@Guide\(` — property-level constraints (count)
  - `:\s*Tool\b`, `:\s*FoundationModels\.Tool` — Tool protocol conformance
  - `func call\(arguments:` — Tool implementation methods
  - `enum\s+\w+\s*:.*Generable`, `@Generable\s+enum` — generable enums (need @frozen check)
  - `@frozen` near @Generable enums — frozen enum discipline

Step 5: Identify Inference and Error-Handling Surface

Grep for:
  - `\.respond\(to:` — synchronous-style structured response
  - `\.streamResponse\(to:` — streaming response
  - `\.respond\(to:.*generating:` — structured @Generable response
  - `PartiallyGenerated` — streaming partial output type
  - `LanguageModelError` — OS27 error type (the current one)
  - `LanguageModelSession\.GenerationError` — 26-cycle error type, **deprecated in 27.0**
  - `SystemLanguageModel\.Error`, `LanguageModelSession\.Error` — the errors that split OUT of the old enum
  - `GeneratedContent\.ParsingError` — where `.decodingFailure` went
  - `\.contextSizeExceeded|\.exceededContextWindowSize` — same failure, new/old spelling
  - `\.guardrailViolation`, `\.refusal`, `\.rateLimited`, `\.timeout` — specific catch arms
  - `try\s+await.*respond` — actual call sites
  - `Task\.cancel\(\)`, `\.task\(id:` — cancellation surface
  - `\.transcript`, `transcript\.` — conversation history access

**Search BOTH error spellings.** The 27 SDK deprecated `LanguageModelSession.GenerationError` in favor of `LanguageModelError`, and split `assetsUnavailable` / `concurrentRequests` / `decodingFailure` out into `SystemLanguageModel.Error`, `LanguageModelSession.Error`, and `GeneratedContent.ParsingError`. A project written against the 27 API contains **none** of the old identifiers — grepping only for those reports a modern codebase as having no error handling at all, which is the opposite of the truth. See `axiom-ai (skills/foundation-models-ref.md)` for the full migration table.

Step 6: Read Key Files

Read 1-2 representative AI files (AIService / ChatViewModel / similar) to understand:

  • Whether availability is checked once (at app/service init) AND before each session creation
  • Whether sessions are owned by a long-lived service (good) or recreated per tap (bad)
  • Whether `respond()` calls are wrapped in `Task { ... }` with loading-state UI
  • Whether catch blocks distinguish guardrail/refusal, context-size exhaustion, and generic errors — in EITHER error-type spelling (`LanguageModelError` on 27, `GenerationError` on 26)
  • Whether @Generable enums are `@frozen` and Tool implementations propagate errors correctly
  • Whether user-supplied text is interpolated directly into prompts (injection risk)

Output

Write a brief **Foundation Models Map** (5-10 lines) summarizing:

  • Number of LanguageModelSession instances and their ownership pattern (service-level / view-level / per-tap)
  • Number of @Generable types (and whether nested types are also @Generable)
  • @Guide annotation coverage on numeric / collection properties
  • Tool protocol implementations (count + their purpose)
  • Availability discipline (single source of truth / scattered checks / missing)
  • Streaming usage (streamResponse for long output / always respond / mixed)
  • Error-handling discipline (specific catches for guardrail and context-window / g
Read more
Ships withaxiom

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.

Get the whole plugin