Skip to main content
skill CX Codex

foundation-models — Claude Code skill: what it does, how to install

Gives Claude Code reference patterns for Apple's on-device Foundation Models framework: summarization, extraction, classification. Covers setting up a LanguageModelSession and typed output with @Generable.

MIT ★ 233 updated 2026-01-18

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add johnrogers/claude-swift-engineering
/plugin install swift-engineering@claude-swift-engineering
Open on GitHub

What foundation-models does

The skill bundles reference files for Apple's Foundation Models framework, a 3B-parameter language model that runs locally without network calls. Separate reference files cover starting a LanguageModelSession, getting typed structured output through @Generable and @Guide, calling external tools via the Tool protocol, and streaming responses with AsyncSequence and partially generated types.

It lists recurring mistakes: calling the model on the main thread instead of wrapping it in Task {}, feeding it oversized documents that overflow context, and skipping the SystemLanguageModel.default.availability check before use. The model is meant for summarizing, extracting, or classifying a user's own text, not for answering factual or world-knowledge questions — the skill points to ChatGPT, Claude, or Gemini for those.

The framework needs iOS 26+, macOS 26+, iPadOS 26+, or visionOS 26+, an Apple Intelligence-capable device (iPhone 15 Pro or later, M1+ Mac or iPad), and Apple Intelligence turned on for the user.

What it helps with

  • set up a LanguageModelSession and check model availability
  • get typed structured output from the model with @Generable
  • summarize or classify a user's text without a network call
  • wire external data into the model through the Tool protocol
  • avoid blocking the main thread or overflowing the context window

Example prompts for the agent

  • Set up a LanguageModelSession to summarize the user's notes
  • Add a @Generable struct to pull key fields out of a block of text
  • Show how to check SystemLanguageModel.default.availability before running a session

How to install foundation-models

1Plugin marketplace

/plugin marketplace add johnrogers/claude-swift-engineering
/plugin install swift-engineering@claude-swift-engineering

This installs the whole swift-engineering plugin with all its skills

2Skills CLI (Vercel)

npx skills add johnrogers/claude-swift-engineering --skill foundation-models -a claude-code

3Manually: put the files in place

~/.claude/skills/foundation-models/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/foundation-models/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about foundation-models

How do I install foundation-models in Claude Code?

Run /plugin marketplace add johnrogers/claude-swift-engineering, then /plugin install swift-engineering@claude-swift-engineering.

What does the foundation-models skill do?

It gives Claude Code reference material on Apple's Foundation Models framework: session setup, typed output via @Generable, tool calling, streaming, and a list of common mistakes when working with the on-device model.

What tasks is the Foundation Models framework good for, and what should it avoid?

It handles summarization, extraction, and classification of a user's own content well. It isn't built for world knowledge or complex reasoning, where the skill recommends ChatGPT, Claude, or Gemini instead.

Source text

SKILL.md · MIT
---
name: foundation-models
description: Use when implementing on-device AI with Apple's Foundation Models framework (iOS 26+), building summarization/extraction/classification features, or using @Generable for type-safe structured output.
---

# Foundation Models

Apple's on-device AI framework providing access to a 3B parameter language model for summarization, extraction, classification, and content generation. Runs entirely on-device with no network required.

## Overview

Foundation Models enable intelligent text processing directly on device without server round-trips, user data sharing, or network dependencies. The core principle: leverage on-device AI for specific, contained tasks (not for general knowledge).

## Reference Loading Guide

**ALWAYS load reference files if there is even a small chance the content may be required.** It's better to have the context than to miss a pattern or make a mistake.

| Reference | Load When |
|-----------|-----------|
| **[Getting Started](references/getting-started.md)** | Setting up LanguageModelSession, checking availability, basic prompts |
| **[Structured Output](references/structured-output.md)** | Using `@Generable` for type-safe responses, `@Guide` constraints |
| **[Tool Calling](references/tool-calling.md)** | Integrating external data (weather, contacts, MapKit) via Tool protocol |
| **[Streaming](references/streaming.md)** | AsyncSequence for progressive UI updates, PartiallyGenerated types |
| **[Troubleshooting](references/troubleshooting.md)** | Context overflow, guardrails, errors, anti-patterns |

## Core Workflow

1. Check availability with `SystemLanguageModel.default.availability`
2. Create `LanguageModelSession` with optional instructions
3. Choose output type: plain String or @Generable struct
4. Use streaming for long generations (>1 second)
5. Handle errors: context overflow, guardrails, unsupported language

## Model Capabilities

| Use Case | Foundation Models? | Alternative |
|----------|-------------------|-------------|
| Summarization | Yes | - |
| Extraction (key info) | Yes | - |
| Classification | Yes | - |
| Content tagging | Yes (built-in adapter) | - |
| World knowledge | No | ChatGPT, Claude, Gemini |
| Complex reasoning | No | Server LLMs |

## Platform Requirements

- iOS 26+, macOS 26+, iPadOS 26+, visionOS 26+
- Apple Intelligence-enabled device (iPhone 15 Pro+, M1+ iPad/Mac)
- User opted into Apple Intelligence

## Common Mistakes

1. **Using Foundation Models for world knowledge** — The 3B model is trained for on-device tasks only. It won't know current events, specific facts, or "who is X". Use ChatGPT/Claude for that. Keep prompts to: summarizing user's own content, extracting info, classifying text.

2. **Blocking the main thread** — LanguageModelSession calls must run on a background thread or async context. Blocking the main thread locks UI. Always use `Task { }` or background queue.

3. **Ignoring context overflow** — The model has finite context. If the user pastes a 50KB document, it will fail silently or truncate. Check input length and trim/truncate proactively.

4. **Forgetting to check availability** — Not all devices support Foundation Models. Check `SystemLanguageModel.default.availability` before using. Graceful degradation is required.

5. **Ignoring guardrails** — The model won't answer harmful queries. Instead of fighting it, design prompts that respect safety guidelines. Rephrasing requests usually works.

© John Rogers (@johnrogers) · MIT · johnrogers/claude-swift-engineering

Similar skills

All skills for Mobile →

From the same set33

The whole set →
swift-code-reviewer swift-code-reviewer inspects Swift and iOS implementations for concurrency safety, HIG rules, TCA patterns, and security before testing. CX Codex ★ 233repo stars ios-26-platform The ios-26-platform skill guides iOS 26 feature work in SwiftUI and helps preserve support for iOS 17/18. Use it when updating an interface or handling backward compatibility. CX Codex +1 ★ 233repo stars swiftui-specialist swiftui-specialist builds SwiftUI screens that follow Apple HIG once the core logic and TCA layer are already in place. CX Codex ★ 233repo stars swift-ui-design swift-ui-design inspects mockups, screenshots, or UI descriptions to plan SwiftUI views and architecture before implementation begins. CX Codex ★ 233repo stars tca-engineer tca-engineer writes the code for a TCA feature from a finished design: reducers, state, actions, dependency clients with test doubles. Views are out of scope. CX Codex ★ 233repo stars sqlite-data Guides database modeling in Swift with the SQLiteData library, macro queries, migrations, and private CloudKit database sync. CX Codex +1 ★ 233repo stars composable-architecture This skill guides feature work with The Composable Architecture (TCA), from reducer structure and effects to navigation and tests. Use it while building or checking TCA features. CX Codex +1 ★ 233repo stars modern-swift modern-swift — a Claude skill that steers the agent through Swift 6.2 concurrency: async/await, actors, Sendable and task cancellation. CX Codex +1 ★ 233repo stars

Project sponsors

Companies that keep this analytics open