# Foundation models

> Foundation models is an open-source agent skill for developer tools. Guides an agent through building on-device LLM features with Apple's Foundation Models. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/rshankras/claude-code-apple-skills/tree/main/skills/apple-intelligence/foundation-models
- **Repository:** https://github.com/rshankras/claude-code-apple-skills
- **GitHub stars:** 924
- **License:** MIT
- **Skill name:** foundation-models
- **Collection:** https://github.com/rshankras/claude-code-apple-skills
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-02

## About

This skill gives a coding agent working knowledge of Apple's Foundation Models framework for iOS and macOS apps. It covers checking whether the on-device model is available, creating sessions with instructions, generating text, and producing typed Swift output with @Generable and @Guide constraints. It also walks through tool calling, snapshot streaming into SwiftUI, multi-turn conversations, and the iOS 27 error types that replace the older GenerationError.

The material focuses on working within the model's small context window and limited capabilities. It explains how to measure token usage with tokenUsage(for:), how to check whether a prompt fits before sending it, how to condense a transcript when context overflows, and how to choose sampling settings. It also includes prompt-writing patterns for summarization, extraction and classification, and a pre-ship checklist. Companion reference files cover safety guardrails, Private Cloud Compute and utilities.

The skill is written for Swift projects that target Apple platforms. It contains no scripts, and its frontmatter lists the tools it may use, including Read, Write, Edit, Glob, Grep, Bash and AskUserQuestion.

## When your agent uses it

> On-device LLM integration using Apple's Foundation Models framework. Use when implementing AI text generation, structured output, or tool calling.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/rshankras/claude-code-apple-skills/tree/HEAD/skills/apple-intelligence/foundation-models)
- [Asks for: Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion](https://github.com/rshankras/claude-code-apple-skills/blob/HEAD/skills/apple-intelligence/foundation-models/SKILL.md)
- [License: MIT](https://github.com/rshankras/claude-code-apple-skills/tree/HEAD/skills/apple-intelligence/foundation-models)

## Features

- **Model availability checks:** Covers how to test whether the on-device model is ready and how to show fallback UI on unsupported devices.
- **Typed structured output:** Explains defining @Generable types with @Guide constraints so responses arrive as Swift values.
- **Tool calling setup:** Describes defining tools the model can call, with naming rules and session-level tool handling.
- **Token budget management:** Shows measuring instruction, tool and prompt token costs and checking prompts fit the context window.
- **Streaming and sessions:** Covers streaming partial results into SwiftUI and reusing sessions for multi-turn chat.
- **iOS 27 error migration:** Lists the new LanguageModelError and session error types and how they replace the deprecated GenerationError.

## Good for

- Add a summarization feature to an iOS app using the on-device model
- Parse event details from free text into a typed Swift struct
- Build a chat assistant in SwiftUI that keeps conversation context
- Stream a generated response into a SwiftUI view as it arrives
- Check whether a long prompt fits the context window before sending it
- Classify support tickets into fixed categories with guided output

## Install

### Claude Code

This skill ships in the `apple-skills` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add rshankras/claude-code-apple-skills
/plugin install apple-skills@indie-apple-stack
```

Or copy only this skill to `~/.claude/skills/foundation-models`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/foundation-models &&
cp -R "$tmp/skills/apple-intelligence/foundation-models" ~/.claude/skills/foundation-models &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/foundation-models` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/foundation-models` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/foundation-models &&
cp -R "$tmp/skills/apple-intelligence/foundation-models" ~/.agents/skills/foundation-models &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/foundation-models` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/foundation-models` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/foundation-models &&
cp -R "$tmp/skills/apple-intelligence/foundation-models" ~/.cursor/skills/foundation-models &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/foundation-models` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/rshankras/claude-code-apple-skills.git --path skills/apple-intelligence/foundation-models
```

Or copy the folder to `~/.gemini/skills/foundation-models` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/foundation-models`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/foundation-models &&
cp -R "$tmp/skills/apple-intelligence/foundation-models" ~/.copilot/skills/foundation-models &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/foundation-models` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills.git
```

Then copy `claude-code-apple-skills/skills/apple-intelligence/foundation-models` into your agent's skills folder as `foundation-models`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does the skill need to be used?

It is aimed at Swift projects using Apple's Foundation Models framework, targeting iOS 27 and macOS 27 according to its frontmatter, with examples in Swift and SwiftUI.

### What does the on-device model handle well?

The skill says the roughly 3B-parameter on-device model suits summarization, extraction, classification, tagging, revision and short chat, and not math, code generation, facts or world knowledge.

### When does the skill activate?

It activates when the user wants AI text generation, structured data from natural language, prompting or LLM integration, agentic features, summarization or extraction, or questions about Private Cloud Compute and guardrails.

### Does the skill include scripts?

No. The skill folder contains no scripts; it is instructions plus companion reference files.

### How do I install Foundation models in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/foundation-models to use it in all your projects, or to .claude/skills/foundation-models in one project. Or install the apple-skills plugin, which includes it: /plugin marketplace add rshankras/claude-code-apple-skills, then /plugin install apple-skills@indie-apple-stack.

### Does Foundation models run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Foundation models?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Foundation models?

The closest alternatives to Foundation models are Apple intelligence, Axiom audit foundation models, Core ML, Axiom AI and Axiom swift.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Apple intelligence](https://ai-powered.com/skills/apple-intelligence): Apple intelligence is an open-source agent skill for developer tools.
- [Axiom audit foundation models](https://ai-powered.com/skills/axiom-audit-foundation-models): Axiom audit foundation models is an open-source agent skill for developer tools.
- [Core ML](https://ai-powered.com/skills/core-ml): Core ML is an open-source agent skill for ai models and llm tooling.
- [Axiom AI](https://ai-powered.com/skills/axiom-ai-charleswiltgen-2): Axiom AI is an open-source agent skill for developer tools.
- [Axiom swift](https://ai-powered.com/skills/axiom-swift-charleswiltgen-2): Axiom swift is an open-source agent skill for developer tools.
- [Build swiftui interface](https://ai-powered.com/skills/build-swiftui-interface): Build swiftui interface is an open-source agent skill for developer tools.
- [Axiom uikit](https://ai-powered.com/skills/axiom-uikit-charleswiltgen-2): Axiom uikit is an open-source agent skill for developer tools.
- [App intents](https://ai-powered.com/skills/app-intents): App intents is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/foundation-models
