
Foundation Models On Device
Wire Apple Intelligence on-device LLM into iOS 26+ apps with availability checks, guided generation, tools, and streaming UI patterns.
Overview
Foundation Models On-Device is an agent skill for the Build phase that teaches Apple FoundationModels patterns for on-device LLM text, @Generable structured output, tool calling, and snapshot streaming on iOS 26+.
Install
npx skills add https://github.com/affaan-m/everything-claude-code --skill foundation-models-on-deviceWhat is this skill?
- Mandates SystemLanguageModel availability handling before creating sessions
- Documents text generation without cloud dependency for privacy
- Covers @Generable for structured outputs from natural language
- Includes custom tool calling for domain-specific on-device actions
- Supports snapshot streaming for real-time structured UI updates
Adoption & trust: 4.4k installs on skills.sh; 210k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need Apple Intelligence in your iOS app but lack a checklist for availability gates, on-device sessions, structured output, and streaming UI without sending data to the cloud.
Who is it for?
Indie iOS developers targeting iOS 26+ who want on-device summarization, NL-to-structured-data, or tool-augmented features under Apple Intelligence constraints.
Skip if: Android or cross-platform stacks, server-hosted Claude/OpenAI integrations, or products that require models on ineligible or Intelligence-disabled devices without fallback UX.
When should I use this skill?
Building AI on Apple Intelligence on-device, generating or summarizing text offline, extracting structured data, custom tool calling, or streaming structured responses with privacy requirements.
What do I get? / Deliverables
You implement privacy-preserving on-device LLM flows in SwiftUI with correct availability handling and the core generation, tooling, and streaming patterns from the skill.
- Availability-gated SwiftUI generative flow
- Patterns for @Generable, tools, and snapshot streaming integrations
Recommended Skills
Journey fit
How it compares
On-device Apple Intelligence integration patterns—not a generic REST LLM client skill or MCP browser tool.
Common Questions / FAQ
Who is foundation-models-on-device for?
Solo builders creating native iOS apps who want Apple’s on-device language model for generation, structure, and tools without cloud inference.
When should I use foundation-models-on-device?
During Build → Frontend while implementing AI features: on-device text generation, @Generable extraction, custom tool calling, or streaming structured UI when privacy and offline matter.
Is foundation-models-on-device safe to install?
It is documentation and code patterns only; review the Security Audits panel on this Prism page before wiring real user data into on-device model sessions.
SKILL.md
READMESKILL.md - Foundation Models On Device
# FoundationModels: On-Device LLM (iOS 26) Patterns for integrating Apple's on-device language model into apps using the FoundationModels framework. Covers text generation, structured output with `@Generable`, custom tool calling, and snapshot streaming — all running on-device for privacy and offline support. ## When to Activate - Building AI-powered features using Apple Intelligence on-device - Generating or summarizing text without cloud dependency - Extracting structured data from natural language input - Implementing custom tool calling for domain-specific AI actions - Streaming structured responses for real-time UI updates - Need privacy-preserving AI (no data leaves the device) ## Core Pattern — Availability Check Always check model availability before creating a session: ```swift struct GenerativeView: View { private var model = SystemLanguageModel.default var body: some View { switch model.availability { case .available: ContentView() case .unavailable(.deviceNotEligible): Text("Device not eligible for Apple Intelligence") case .unavailable(.appleIntelligenceNotEnabled): Text("Please enable Apple Intelligence in Settings") case .unavailable(.modelNotReady): Text("Model is downloading or not ready") case .unavailable(let other): Text("Model unavailable: \(other)") } } } ``` ## Core Pattern — Basic Session ```swift // Single-turn: create a new session each time let session = LanguageModelSession() let response = try await session.respond(to: "What's a good month to visit Paris?") print(response.content) // Multi-turn: reuse session for conversation context let session = LanguageModelSession(instructions: """ You are a cooking assistant. Provide recipe suggestions based on ingredients. Keep suggestions brief and practical. """) let first = try await session.respond(to: "I have chicken and rice") let followUp = try await session.respond(to: "What about a vegetarian option?") ``` Key points for instructions: - Define the model's role ("You are a mentor") - Specify what to do ("Help extract calendar events") - Set style preferences ("Respond as briefly as possible") - Add safety measures ("Respond with 'I can't help with that' for dangerous requests") ## Core Pattern — Guided Generation with @Generable Generate structured Swift types instead of raw strings: ### 1. Define a Generable Type ```swift @Generable(description: "Basic profile information about a cat") struct CatProfile { var name: String @Guide(description: "The age of the cat", .range(0...20)) var age: Int @Guide(description: "A one sentence profile about the cat's personality") var profile: String } ``` ### 2. Request Structured Output ```swift let response = try await session.respond( to: "Generate a cute rescue cat", generating: CatProfile.self ) // Access structured fields directly print("Name: \(response.content.name)") print("Age: \(response.content.age)") print("Profile: \(response.content.profile)") ``` ### Supported @Guide Constraints - `.range(0...20)` — numeric range - `.count(3)` — array element count - `description:` — semantic guidance for generation ## Core Pattern — Tool Calling Let the model invoke custom code for domain-specific tasks: ### 1. Define a Tool ```swift struct RecipeSearchTool: Tool { let name = "recipe_search" let description = "Search for recipes matching a given term and return a list of results." @Generable struct Arguments { var searchTerm: String var numberOfResults: Int } func call(arguments: Arguments) async throws -> ToolOutput { let recipes = await searchRecipes(