foundation-models — скилл для Claude Code: что делает и как установить
Подключает паттерны работы с Foundation Models Apple: суммаризацию, извлечение данных и классификацию текста на устройстве. Claude Code сверяется с ним при настройке LanguageModelSession и @Generable.
MIT ★ 233 обновлён 2026-01-18
/plugin marketplace add johnrogers/claude-swift-engineering
/plugin install swift-engineering@claude-swift-engineeringЧто делает foundation-models
Скилл собирает справочные файлы по фреймворку Foundation Models — 3B-модели Apple, которая работает прямо на устройстве без обращений к серверу. Отдельные référence-файлы покрывают запуск LanguageModelSession, типобезопасный вывод через @Generable и @Guide, вызов инструментов через протокол Tool и потоковую генерацию с AsyncSequence.
В описании перечислены частые ошибки: блокировка главного потока вызовом модели вместо Task {}, переполнение контекста при вставке больших документов, пропуск проверки SystemLanguageModel.default.availability перед использованием. Модель годится для суммаризации, извлечения ключевой информации и классификации собственного текста пользователя, но не отвечает на вопросы о мировых фактах — для этого скилл рекомендует ChatGPT, Claude или Gemini.
Фреймворк требует iOS 26+, macOS 26+, iPadOS 26+ или visionOS 26+, устройство с Apple Intelligence (iPhone 15 Pro и новее, Mac или iPad на M1+) и включённый Apple Intelligence у пользователя.
Какие задачи решает
- настроить LanguageModelSession и проверить доступность модели
- получить типобезопасный структурированный вывод через @Generable
- суммировать или классифицировать текст пользователя без сети
- подключить внешние данные к модели через протокол Tool
- избежать блокировки главного потока и переполнения контекста
Примеры запросов агенту
- Настрой LanguageModelSession для суммаризации заметок пользователя
- Добавь @Generable структуру для извлечения ключевых полей из текста
- Покажи, как проверить SystemLanguageModel.default.availability перед запуском
Как установить foundation-models
1Через маркетплейс плагинов
/plugin marketplace add johnrogers/claude-swift-engineering/plugin install swift-engineering@claude-swift-engineeringКоманда ставит плагин swift-engineering целиком, со всеми его скиллами
2Через Skills CLI (Vercel)
npx skills add johnrogers/claude-swift-engineering --skill foundation-models -a claude-code3Вручную: положить файлы
~/.claude/skills/foundation-models/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/foundation-models/
1Через Skills CLI (Vercel)
npx skills add johnrogers/claude-swift-engineering --skill foundation-models -a codex2Вручную: положить файлы
.agents/skills/foundation-models/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add johnrogers/claude-swift-engineering --skill foundation-models -a cursor2Вручную: положить файлы
.cursor/skills/foundation-models/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install johnrogers/claude-swift-engineering plugins/swift-engineering/skills/foundation-models2Вручную: положить файлы
.github/skills/foundation-models/SKILL.md1Через Skills CLI (Vercel)
npx skills add johnrogers/claude-swift-engineering --skill foundation-models -a gemini-cli2Командой платформы
gemini skills install https://github.com/johnrogers/claude-swift-engineering --path plugins/swift-engineering/skills/foundation-modelsВручную: положить файлы
.devin/skills/foundation-models/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Claude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о foundation-models
Как установить foundation-models в Claude Code?
Выполните /plugin marketplace add johnrogers/claude-swift-engineering, затем /plugin install swift-engineering@claude-swift-engineering.
Что делает скилл foundation-models?
Он даёт Claude Code справочные материалы по фреймворку Foundation Models Apple: настройку сессии, структурированный вывод через @Generable, вызов инструментов и потоковую генерацию, а также список типичных ошибок при работе с on-device моделью.
Для каких задач подходит модель Foundation Models и для каких нет?
Она справляется с суммаризацией, извлечением информации и классификацией собственного текста пользователя. Для мировых знаний и сложных рассуждений она не годится — скилл советует использовать ChatGPT, Claude или Gemini.
Исходный текст
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