foundation-models

Implement on-device Foundation Models with @Generable structured outputs across Apple platforms.

1.1k|81|Updated Nov 30, 2025
One-click install
npx skills add https://github.com/CharlesWiltgen/Axiom --skill foundation-models
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: foundation-models
Source: https://github.com/CharlesWiltgen/Axiom/tree/main/plugins/axiom/skills/foundation-models
Command: npx skills add https://github.com/CharlesWiltgen/Axiom --skill foundation-models

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers implement on-device AI with Apple's Foundation Models framework while avoiding common pitfalls like context overflow, blocking the UI, manual JSON parsing, and using the model for inappropriate tasks (e.g., world knowledge).

Core Features & Use Cases

  • Anti-Pattern Prevention: Identifies and corrects common mistakes such as using the model for world knowledge, blocking the main thread, or ignoring availability checks.
  • Structured Output with @Generable: Guides on using the @Generable macro for type-safe, guaranteed structured output, eliminating manual JSON parsing and runtime errors.
  • Context & Tool Management: Strategies for handling context window limits, implementing tool calling for external data, and optimizing performance with streaming and prewarming.
  • Use Case: When you need to extract structured data from an invoice using the on-device model, use this skill to define an @Generable struct for the invoice fields, ensuring type-safe and error-free data extraction.

Quick Start

Before writing any Foundation Models code, check availability with switch SystemLanguageModel.default.availability { case .available: print("✅ Foundation Models available") case .unavailable(let reason): print("❌ Unavailable: \(reason)") } to ensure the feature can run on the user's device.

Frequently Asked Questions about foundation-models

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement on-device AI with Foundation Models on iOS without blocking the UI?

On-device Foundation Models run asynchronously by default, but you must execute model calls off the main thread. Use Swift's async/await or background tasks to prevent UI blocking. Check availability first with `SystemLanguageModel.default.availability` before attempting any model operations.

What's the best way to extract structured data from text using on-device Foundation Models?

Use the `@Generable` macro to define type-safe structs for your output schema. This eliminates manual JSON parsing and guarantees structured results at compile time. The model generates validated outputs matching your Swift types directly.

Can I use Foundation Models for general knowledge questions on Apple platforms?

No. On-device Foundation Models are designed for local text processing tasks like summarization, classification, and extraction—not world knowledge. For factual queries, integrate external APIs or knowledge sources via tool calling instead.

How do I handle context window limits when processing large documents with Foundation Models?

Implement context management by splitting large inputs into chunks, summarizing progressively, or using tool calling to fetch only relevant data. Monitor token usage and validate input length before sending to the model to prevent overflow errors.

Does Foundation Models support streaming responses for real-time text generation on macOS and iOS?

Yes. Foundation Models supports streaming output across iOS 18+, macOS 15+, iPadOS 18+, and visionOS 2+. Stream results incrementally to display generated content in real time without waiting for full completion.

What do I need to check before deploying Foundation Models code to users?

Verify device and OS compatibility (iOS 18+, macOS 15+, iPadOS 18+, visionOS 2+) and check runtime availability using `SystemLanguageModel.default.availability`. Handle unavailable states gracefully by offering fallback UI or cloud alternatives.