Agent skill · AI & Agents

foundation-models

Apple Foundation Models framework for on-device AI, @Generable macro, guided generation, tool calling, and streaming. Use when user asks about on-device AI, Apple Intelligence, Foundation Models, @Generable, LLM, or local machine learning.

majiayu000github.com/majiayu000GitHub ↗
claude-codecan modify filesMIT
Install
npx skills add majiayu000/claude-skill-registry --skill foundation-models --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 18 KB
Bundled scripts: none
Allowed tools: BashReadWriteEdit
Path: skills/ai-llm/foundation-models/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Provides a comprehensive guide to Apple's Foundation Models framework for on-device AI inference, structured output generation, tool calling, and streaming responses in iOS 26. It covers creating sessions, configuring parameters like maxTokens, temperature, topP, penalties, and examples of basic text responses. It also details the @Generable macro for structured outputs, complex nested data, and adding descriptions. Additionally, it describes Guided Generation with system instructions and constrained outputs, Tool Calling with defining tools and integrating them into a session, Streaming Responses with basic and structured output, Multi-Turn Conversations for maintaining context and explicit message history, Error Handling for common errors and timeouts, and SwiftUI integration including a complete chat interface and UI-friendly structured output.

How it works

  • Import FoundationModels and create a LanguageModelSession (with optional Configuration(maxTokens, temperature, topP, frequencyPenalty, presencePenalty))
  • Use session.respond(to: ...) to get text responses; access response.content for plain text
  • Check availability via LanguageModelSession.isAvailable to determine Foundation Models support
  • Use the @Generable macro to define structured outputs (e.g., MovieRecommendation, RecipeAnalysis, Recipe, TaskExtraction) and obtain typed results from session.respond
  • Use systemInstructions to steer output in Guided Generation, or provide constrained outputs via appropriate Generable types
  • Define Tools with @Tool and @ToolFunction, then invoke session.respond with tools to have the model call tool functions and incorporate results
  • Stream responses using session.streamResponse(to: ...), handling partial content and optional structured updates via PartiallyGenerated<...>
  • Manage multi-turn conversations by reusing the LanguageModelSession to preserve context or by supplying explicit message history
  • Handle errors with specific catches (LanguageModelError.unavailable, .contentFiltered, .contextLengthExceeded, .cancelled) and implement timeouts using withTimeout pattern
  • Integrate with SwiftUI for chat interfaces and render streaming or structured outputs in the UI

When to use it

  • When building on-device AI capabilities on Apple devices without cloud dependency
  • When you need privacy-first, offline-capable LLM interactions with low latency
  • When you want type-safe, structured outputs for AI responses using @Generable
  • When integrating tool calls (weather, restaurant data, etc.) into AI responses

What it can touch

  • The framework is accessed via Swift imports (e.g., FoundationModels)
  • Uses session creation and configuration objects, and optional tools passed to session.respond
  • Demonstrates usage of @Generable-annotated structs/enums to constrain output

Caveats

  • Requires iOS 26+, macOS Tahoe+, iPadOS 26+, visionOS 26+ and compatible hardware (A17 Pro+ or M-series) with Apple Intelligence support
  • Inference runs locally with no data leaving the device; no API fees or cloud dependency
  • Example code shows specific parameter defaults (maxTokens, temperature, topP, penalties) and may require adaptation for real apps
  • Availability may vary by device capability; check LanguageModelSession.isAvailable before usage
From the SKILL.md

# Apple Foundation Models Framework Comprehensive guide to Apple's Foundation Models framework for on-device AI inference, structured output generation, tool calling, and streaming responses in iOS 26. ## Prerequisites - iOS 26+, macOS Tahoe+, iPadOS 26+, or visionOS 26+ - Device with Apple Intelligence support (A17 Pro or later, M-series) - Xcode 26+ --- ## Framework Overview ### What is Foundation Models? Apple's Foundation Models framework provides: - **~3B parameter on-device LLM** powered by Apple Intelligence - **Privacy-first**: All inference runs locally, no data leaves device - **Cost-free**: No API fees, no cloud dependency - **Offline-capable**: Works without network connection - **Low-latency**: Direct device access for fast responses ### Import ```swift import FoundationModels ``` ### Basic Usage ```swift let session = LanguageModelSession() let response = try await session.respond( to: "What's the capital of France?" ) print(response.content) // "Paris is the capital of France." ``` --- ## LanguageModelSession ### Creating a Session ```swift // Default session let session = LanguageModelSession() // With custom configuration let config = LanguageModelSession.Configura

What's inside
Steps it walks through
  1. Prerequisites
  2. Framework Overview
  3. What is Foundation Models?
  4. Import
  5. Basic Usage
  6. LanguageModelSession
  7. Creating a Session
  8. Session Configuration Options
  9. Simple Text Response
  10. Check Availability
  11. @Generable Macro
  12. Basic Structured Output
  13. @Generable Requirements
  14. Complex Nested Structures
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the foundation-models skill do?

Apple Foundation Models framework for on-device AI, @Generable macro, guided generation, tool calling, and streaming. Use when user asks about on-device AI, Apple Intelligence, Foundation Models, @Generable, LLM, or local machine learning.

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill foundation-models --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going