Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/moasq/ios-dev-agent/foundation-modelsnpx skills add moasq/ios-dev-agent --skill foundation-modelsgit clone --depth 1 https://github.com/moasq/ios-dev-agentWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00028 | $0.00537 |
| Opus 5 | $0.00014 | $0.00269 |
| Sonnet 5 | $0.00006 | $0.00107 |
| Haiku 4.5 | $0.00003 | $0.00054 |
Grade A, and why
foundation-models scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 86 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Foundation Models (On-Device AI)
Use this guide when implementing or modifying on-device AI features.
Framework
import FoundationModels — iOS 26+ only
Availability Check (MANDATORY)
The model may not be available on all devices. Always check first:
guard SystemLanguageModel.default.isAvailable else {
// Show "This feature requires Apple Intelligence" message
return
}
Basic Text Generation
let session = LanguageModelSession()
let response = try await session.respond(to: "Summarize this text: \(userText)")
print(response.content) // String
With System Instructions
let session = LanguageModelSession(
instructions: "You are a helpful health assistant. Keep responses concise and empathetic."
)
let response = try await session.respond(to: prompt)
Streaming Generation
let stream = session.streamResponse(to: prompt)
for try await partial in stream {
displayText += partial.text
}
Structured Output with @Generable
@Generable
struct RecipeSuggestion {
@Guide(description: "Name of the dish") var name: String
@Guide(description: "Estimated prep time in minutes") var prepTime: Int
@Guide(description: "Main ingredients") var ingredients: [String]
}
let session = LanguageModelSession()
let recipe: RecipeSuggestion = try await session.respond(
to: "Suggest a quick pasta dish",
generating: RecipeSuggestion.self
)
Guardrails
- Model output is filtered by Apple's safety system — some prompts may be refused
- No internet required — fully on-device
- Context window is limited (~4K tokens) — keep prompts concise
- Use
session.respond()for single turns; keepsessionalive for multi-turn conversations - Wrap in do/catch — generation can fail for safety or resource reasons
Service Pattern
@MainActor @Observable
final class AIService {
var isAvailable: Bool { SystemLanguageModel.default.isAvailable }
func generate(prompt: String) async -> String? {
guard isAvailable else { return nil }
do {
let session = LanguageModelSession(instructions: "...")
let response = try await session.respond(to: prompt)
return response.content
} catch {
return nil
}
}
}
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 86 lines · 28 tokens per session scan A edaeeae8121a
foundation-models is a skill published in the GitHub repository moasq/ios-dev-agent (4 stars, last pushed 3mo ago), licensed MIT. It adds 28 tokens to every session and 537 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
model-authoring
Empirical rules for authoring PyTorch models for on-device execution on Apple platforms, covering energy-efficient inference, scalable compute, and correctness testing. Use this skill whenever the user is writing, debugging, or reviewing PyTorch model code intended for on-device execution — even if they don't…
working-with-coreai
Use this skill whenever the user mentions coreai-torch, TorchConverter, coreai-build, AIModel, AIProgram, .aimodel, or wants to export/compile/run a PyTorch model on Apple silicon (iPhone, iPad, Mac). Also triggers for "deploy on device", "optimize for on-device performance", onboarding new models to Core AI, or…
ai-model-wechat
Use this skill for WeChat Mini Program AI via wx.cloud.extend.AI (小程序, 企业微信小程序, wx.cloud apps). Features generateText and streamText with callbacks (onText, onEvent, onFinish). Models via wx.cloud.extend.AI.createModel with groups hunyuan-exp (小程序成长计划), cloudbase (main managed), or custom-. Model IDs…
firebase-ai
Use when setting up firebaseai, generating text/chat with Gemini, streaming AI output, building multimodal prompts, or handling AI errors.
litert-compiled-model-migration
Rapidly migrate an Android application from legacy TensorFlow Lite (TFLite) to modern LiteRT CompiledModel API v2.1.6 in Open Source GitHub repositories. Supports True Async Execution (runAsync), Zero-Copy I/O Buffers, NPU JIT compilation, and automated 2-stage verification self-testing.
foundation-models
On-device LLM integration using Apple's Foundation Models framework. Use when implementing AI text generation, structured output, or tool calling.