/apple-dev:foundation-models-integrationfrom apple-dev
Add Apple's on-device Foundation Models (Apple Intelligence) to a SwiftUI app: streaming, `@Generable` structured output, `Tool` protocol, availability checks. iOS / iPadOS / macOS / visionOS 26+. Triggers on `SystemLanguageModel`, `LanguageModelSession`, `@Generable`.
Ships in apple-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
On-device LLM features in a SwiftUI app: streaming chat, structured output extraction from text, tool calling against system data (Contacts, Calendar, Location) or custom logic. Runs locally with no network, no API key, no per-request cost. Use this skill instead of a cloud LLM when privacy, offline operation, or predictable cost matter more than frontier reasoning quality.
import FoundationModels at the top of any file that touches the framework.SystemLanguageModel.default.availability and switch on it. Render a fallback view for each .unavailable reason (.deviceNotEligible, .appleIntelligenceNotEnabled, .modelNotReady). Re-read on scenePhase becoming active because download or enable state can change while backgrounded.LanguageModelSession per long-lived conversation, owned by an @Observable service (for example ChatService). Configure tools and instructions in the initializer. Instructions are trusted, prompts are not, so never interpolate user input into the instructions string.session.streamResponse(to:) and yields a growing String. Structured output requires a @Generable type (for example SummaryGenerable) and streams via session.streamResponse(generating:), yielding PartiallyGenerated<T> whose fields are optional and fill in over time. Each iteration replaces; do not append.Tool with name, description, a nested @Generable struct Arguments, and func call(arguments:) async throws -> ToolOutput. Register on the session at init via LanguageModelSession(tools: [WeatherTool()]). Mention each tool by name in the instructions so the model knows when to invoke it.respond and streamResponse call: LanguageModelSession.GenerationError.guardrailViolation, .exceededContextWindowSize, .unsupportedLanguageOrLocale. Map each to a user-visible message. On context overflow, rebuild the session with a condensed transcript or a rolling summary.references/session-streaming-generable.md: availability handling, session lifecycle, free-form streaming wired to SwiftUI state, @Generable types with @Guide, structured streaming with PartiallyGenerated<T>.references/tools-and-errors.md: Tool protocol conformance, registering and triggering tools, the three error cases with try/catch examples and recommended UI copy, context-window recovery.streamResponse(to:) instead of replacing. Each iteration yields the cumulative string. Fix: assign, do not append.LanguageModelSession was created per turn. Fix: store the session on a long-lived @Observable service for the conversation's lifetime.session.prewarm() as soon as user intent is clear (field focused, chat opened).exceededContextWindowSize thrown after a long session. Cause: full-transcript replay grew past the limit. Fix: rebuild the session with a condensed transcript or a rolling summary; see references/tools-and-errors.md.PartiallyGenerated<T> fields are nil even after the stream ends. Cause: structured-output fields are optional by design and only fill as the model emits them; the final value can still be missing fields if generation was cut. Fix: render each field as optional in the view; do not gate on the whole struct.instructions argument. That is the prompt-injection vector.ToolOutput string explaining the failure."..." while streaming. Use an empty string plus a streaming: Bool flag, or keep the placeholder outside your durable store until the stream finishes.LanguageModelSession per turn. You lose conversation context, pay the prewarm cost again, and re-send the schema on every structured call.session.prewarm() as soon as user intent is clear (input field focused, chat view appeared, conversation tapped). It loads weights and primes the KV cache so first-token latency drops.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
8 skills in this plugin
/add-approuterAdopt AppRouter (github.com/dimillian/AppRouter) for type-safe SwiftUI navigation with sheets and deep linking. Use when starting an app's nav layer or replacing ad-hoc `NavigationStack` path management. SimpleRouter or tab Router./ios26-liquid-glass-adoptionAdopt iOS 26 / iPadOS 26 / macOS 26 SwiftUI APIs: Liquid Glass, modernized toolbars and tab bars, matched transitions, scroll position. Triggers: `glassEffect`, `buttonStyle(.glass)`, `ToolbarSpacer`, `matchedTransitionSource`, `tabBarMinimizeBehavior`./modular-package-skeletonScaffold a new iOS, iPadOS, macOS, or visionOS app with the canonical modular SwiftPM layout (Models, Network, Env, DesignSystem, per-feature UI packages). Use when starting a new SwiftUI app or restructuring a monolithic Xcode project into Swift Packages.npx claudepluginhub joaquincampo/my-plugins --plugin apple-dev