Best for
- Use when wiring Apple Foundation Models, local classifiers, extraction, summarization, grounded answers, and cloud fallbacks.
vasilyu1983/AI-Agents-public/frameworks/shared-skills/skills/software-ios-ai-engine/SKILL.md
Design local AI engines for iOS. Use when wiring Apple Foundation Models, local classifiers, extraction, summarization, grounded answers, and cloud fallbacks.
Decision brief
Use this skill when an iOS app should run useful AI behavior locally before spending cloud quota: Apple Foundation Models, deterministic local NLG, local retrieval stitching, local classifiers, extraction, summarization, tagging, rewrite helpers, and tool calls into app state. T…
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/vasilyu1983/AI-Agents-public --skill "frameworks/shared-skills/skills/software-ios-ai-engine"Inspect the Agent Skill "software-ios-ai-engine" from https://github.com/vasilyu1983/AI-Agents-public/blob/53f6cb73ea53a2646e3e7d4665062ad66f3683ac/frameworks/shared-skills/skills/software-ios-ai-engine/SKILL.md at commit 53f6cb73ea53a2646e3e7d4665062ad66f3683ac. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
A local AI engine generates user-facing content, which puts the app inside several App Store Review Guidelines that have nothing to do with model quality. Treat these as build-time constraints, not a pre-submission afterthought. Full pass/fail map: ../software-ios-design/referen…
1. Name the local task. Is it classification, extraction, summarization, rewrite, tagging, grounded answer composition, or tool-backed action planning? Do not start with "chat" unless the user-facing surface is actually chat. 2. Choose the smallest reliable local engine. Regex/r…
Before concluding a local iOS AI engine recommendation or implementation:
For non-answer tasks, use references/local-ai-task-patterns.md before reaching for the answer-composer references. For reusable app foundations, use references/foundation-models-app-skeleton.md and references/on-device-vector-retrieval-ios.md.
For non-answer tasks, use references/local-ai-task-patterns.md before reaching for the answer-composer references. For reusable app foundations, use references/foundation-models-app-skeleton.md and references/on-device-vector-retrieval-ios.md.
Permission review
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 97/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 82 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Use this skill when an iOS app should run useful AI behavior locally before spending cloud quota: Apple Foundation Models, deterministic local NLG, local retrieval stitching, local classifiers, extraction, summarization, tagging, rewrite helpers, and tool calls into app state. The common constraint is not "make chat smarter"; it is pick the right local engine, shape the data contract, gate capability correctly, and keep cloud as an explicit upgrade or fallback.
A major scenario is a rich, per-user structured context bundle (chart, Human Design, planning cache, knowledge chunks, activity ratings, dream themes, mood/energy, etc.) that needs to produce a real answer without cloud quota. In that case, the fix is never "make the reject card nicer." The fix is adding a local Composer tier between intent routing and cloud fallback.
This skill is for iOS product surfaces and local app-engine design. For pure retrieval/chunking/grounding strategy upstream of the local engine, route to ai-rag. For model serving/quantization tradeoffs beyond Apple platform APIs, route to ai-llm-inference. For evaluation of generated or extracted output, route to ai-evals-observer.
| Pattern | Local engine | Best for | Fallback |
|---|---|---|---|
| Structured generation | Apple Foundation Models + @Generable | Short prose, extraction, classification, tagging, typed transformations | Deterministic local logic or cloud opt-in |
| Deterministic NLG | Sentence bank / templates / rules | Auditable answers, safety copy, older devices, per-locale consistency | Retrieval stitch or cloud opt-in |
| Retrieval stitch | Local top-k chunks + wrappers | Grounded explanations from existing knowledge chunks | Sentence bank or cloud opt-in |
| Local classifier | Regex, NaturalLanguage, embeddings, FM enum output | Routing, intent, entity extraction, safety boundaries | Conservative default route |
| Tool-backed local model | FM tool calling into app state | Model decides when it needs app data | Pre-fetch compact data if tool overhead is too high |
| Reusable app AI foundation | LocalAIEngine facade + deterministic fallback + optional Foundation Models | New iOS app skeletons that need AI-ready architecture before the first AI feature ships | No-op or sentence-bank engine |
| Local semantic/vector search | Natural Language embeddings, local vector table, or bundled retrieval units | User notes, settings, local knowledge, short document sets, app help, offline search | Server vector brain when corpus or sharing exceeds device scope |
For non-answer tasks, use references/local-ai-task-patterns.md before reaching for the answer-composer references. For reusable app foundations, use references/foundation-models-app-skeleton.md and references/on-device-vector-retrieval-ios.md.
| Tier | Engine | Responsibility | Cost / latency |
|---|---|---|---|
| 0. Intent router | Deterministic regex + lightweight classifier | Detect archetype (reflect / interpret / guide / clarify / check_in), extract slots, assemble evidence bundle | ~1 ms, free |
| 1. Composer | One of: Foundation Models (A), sentence bank (B), retrieval stitch (C) | Render the bundle into 40–70-word grounded prose | 0–200 ms, free |
| 2. Cloud LLM | Any cloud model your backend calls, chosen per product policy (not this skill's concern) | Deeper synthesis, multi-turn reasoning, novel question types | ~800 ms, counts against quota |
The Data-first pill owns Tiers 0 + 1. The cloud pill is Tier 2. When the user in your screenshot saw "Core works best with one specific angle", your product was doing Tier 0 correctly — but Tier 1 did not exist, so the answer became a rejection. See references/three-tier-architecture.md.
Three engines. You usually ship more than one, with a fallback chain.
| Option A — Foundation Models | Option B — Sentence Bank | Option C — Retrieval Stitch | |
|---|---|---|---|
| Engine | Apple FoundationModels on-device ~3B LLM (iOS 26+) | Hand-curated prose fragments keyed by (archetype, anchor, mood) | Top-k retrieval over your knowledge chunks + boilerplate wrappers |
| Voice quality | Natural, conversational, feels personal | Curated, brand-consistent, can feel patterned over time | Mechanical, readable, "summary-ish" |
| Ship time | ~1 week (framework + prompt design + eval) | 1–3 days (fragment authoring dominates) | 1–2 days (retrieval already exists) |
| Deterministic | No — sampling | Yes — fully auditable | Mostly — retrieval is stable |
| Offline | Yes | Yes | Yes if retrieval is local |
| Free / no-quota | Yes (compute-free for users) | Yes | Yes |
| Localization | Needs multilingual prompt + per-locale QA | Per-locale fragment files (standard l10n flow) | Depends on knowledge chunks' language coverage |
| Device requirement | Apple Intelligence-capable: A17 Pro+/M-series with 8 GB+ unified memory (iPhone 15 Pro+, all M-series iPads/Macs) | Any | Any |
| Risk | Hallucination if prompt underconstrained | Repetition; "feels canned" after N sessions | Chunk quality leaks into answer quality |
| Deep dive | references/option-a-foundation-models.md | references/option-b-sentence-bank.md | references/option-c-retrieval-stitch.md |
Default recommendation for consumer iOS apps (2026): Ship a deterministic local baseline plus Apple Foundation Models as an upgrade on capable devices. For answer surfaces, that usually means B + A together, with B as universal fallback. B closes the reject-card bug immediately; A then upgrades voice quality on iOS 26+ devices using the same bundle and the same { answer, grounding } output shape. C is useful as a last-chance Tier-1 before falling through to Tier 2 or to deterministic safety copy. Rationale: references/three-tier-architecture.md.
Don't default to "on-device because it's private" or "cloud because it's smarter" — decide per feature against four axes, in this order:
AFM Core, shipped in FoundationModels since iOS 26) is genuinely good at short structured generation, classification, and bundle-grounded prose — not at long multi-document reasoning, open-ended agentic planning, or tasks needing broad world knowledge outside the bundle. If the task exceeds that ceiling, no amount of prompt engineering fixes it; route to Tier 2 as an explicit upgrade, don't fight the model..modelNotReady). A local engine that only works on capable devices is not a local engine — it's a feature flag with unclear rollback. Option B (or a deterministic non-AI path) is the actual floor.Memory ceilings, concretely (2026): Apple Intelligence and the FoundationModels on-device model require 8 GB+ unified memory (A17 Pro / M-series). Do not hardcode a device-model allowlist — check SystemLanguageModel.default.availability, because Apple has already shipped one exception that breaks naive device lists (base iPhone 16e ships 8 GB and qualifies; base iPhone 15/15 Plus have 6 GB and do not, despite being newer-adjacent hardware in some markets).
Thermal and battery reality. On-device inference competes with everything else running on the SoC. Under thermal throttling or low-battery mode, generation latency can jump from ~200 ms to multiple seconds, and in rare cases the session can time out. Put a hard latency ceiling on user-facing calls (see references/option-a-foundation-models.md) and fall through to Option B rather than let the UI hang.
Graceful degradation is not optional. Every feature that uses Option A needs a tested B/C path for: OS below 26, Apple Intelligence disabled, region/language not yet supported, model asset still downloading, and thermal/latency ceiling exceeded. Ship the fallback first; layer A on top.
{ answer, grounding, followUps[], safetyBoundary }; for extraction/classification it means a typed enum/struct.SystemLanguageModel.default.availability == .available; local fallbacks must work when the model is unavailable, disabled, not ready, or unsupported for the active language.For answer composers specifically:
{ answer, grounding, followUps[], safetyBoundary } — composers differ only in how they fill it.emotional_support, the first sentence acknowledges the user's stated feeling. No composer is allowed to skip this.(Full catalogs of patterns, anti-patterns, known traps, and scenarios live in the four sections below. Reflects July 2026 practice on shipped iOS 26 / Apple Intelligence and the FoundationModels framework. WWDC26 (June 2026) announced a third-generation Foundation Models lineup — an on-device AFM Core Advanced (20B, sparse, 12 GB+ unified memory), a LanguageModel protocol letting third-party providers back a LanguageModelSession, image/Vision input, and free Private Cloud Compute access for smaller developers — all scoped to iOS/iPadOS/macOS 27, currently in developer beta and not yet shipped to users. Treat those as roadmap, not as APIs to ship against, until 27 GAs; the shipped ~3B on-device model and the 4096-token session window described throughout this skill are unchanged in the current release.)
A local AI engine generates user-facing content, which puts the app inside several App Store Review Guidelines that have nothing to do with model quality. Treat these as build-time constraints, not a pre-submission afterthought. Full pass/fail map: ../software-ios-design/references/app-review-guidelines-map.md.
@Generable schemas, sentence-bank fragments, writing-style adapters, and retrieval data is allowed. Downloading executable code that changes the app's features or UI after review is not. A composer that pulls new content is fine; one that pulls new behavior is a rejection.Full catalog (P1–P28, A1–A22, T1–T25, S1–S13) in references/patterns-antipatterns-traps-scenarios.md. Key entries inline:
Architecture (P1–P6, A4–A7): every composer emits a single shared Swift value type; compose from a typed EvidenceBundle, never raw text; run the universal post-processor (anchor validator → word-count trimmer → forbidden-phrase filter) after every composer including Option A.
Option A (P13–P17, P27–P28): gate on SystemLanguageModel.default.availability, not OS version; token-budget counts instructions + prompt + tool defs + schemas + response against the 4096-token window; probe any FM capability beyond @Generable + plain completion before shipping it; write A's prompt from scratch for the bundle-first contract — never port a cloud prompt.
Safety (P23–P24, A2, A16): crisis patterns bypass all composers; cloud Tier 2 is an explicit user-visible CTA, never a silent fallback; safety routing is a Tier-0 decision, not a prompt instruction to the FM.
Persistence (A21–A22): answerSource and grounding must live inside the persisted jsonb row, not only in the HTTP envelope. Integration test: no successful compose row has answerSource IS NULL or empty grounding.
Top traps by day-cost: T2 (simulator lies about FM availability — always test on physical device); T6a (tool/schema overhead omitted from 4096-token budget); T13 (trimmer removes grounding line); T19 (fallback-chain silent regression when feature flag flips); T25 (cohort ramp built before any users exist).
LocalAIEngine interface and deterministic fallback even if Foundation Models ships later.@Generable for Foundation Models where the model should emit the type directly; use deterministic structs for rule/template paths. For non-answer examples, see references/local-ai-task-patterns.md.SystemLanguageModel.default.availability. references/option-a-foundation-models.md.iOS local AI request
-> Name task: classify, extract, summarize, rewrite, tag, answer, or plan
-> Choose smallest reliable local engine before cloud
-> Lock typed Swift contract and fallback behavior
-> Assemble evidence bundle, safety boundary, and locale inputs
-> Gate Foundation Models by availability and validation
-> Instrument latency, engine, fallback, and quality metrics
Before marking a local AI engine pass as complete, verify:
formatOrdinal helper (server and client); invariant-test it.answerSource, grounding, bestTime, followUpSuggestions) is also written inside the persisted row, not just the outer HTTP envelope. Integration test asserts no successful compose stores answerSource IS NULL or an empty grounding for a bundle that had anchors.data/sources.json at least quarterly and whenever Apple ships a major iOS/FoundationModels update.software-ios-design — for the surface that renders the answer (bubble, grounding line, action row, follow-up chips, detents).software-ios-native — for broader SwiftUI architecture, Observation, concurrency, and release gates around the composer layer.ai-rag — for the retrieval stage feeding the evidence bundle (chunking, hybrid search, reranking, freshness).ai-context-layer — for the durable per-user context store that assembles the bundle.ai-prompt-engineering — for the prompt contract inside Option A (voice, anchor rules, anti-hallucination).ai-llm-inference — for deeper model-choice tradeoffs (Apple FM vs an MLX-served open-weight model vs cloud), tokenization, and inference perf.ai-evals-observer agent/team — for regression gates and trace grading of composer output when available.software-ios-runtime-debugging — when composer output doesn't match source after a build (stale install, not a composer bug).ai-rag + ai-context-layer + ai-vector-brain for natural conversational surfaces, Path A (Apple Foundation Models) and Path B (vector-DB-only) for three generic domain shapes (consumer reflection, regulated copilot, multi-turn emotional companion)LocalAIEngine facade, Foundation Models service, typed contracts, fallback behavior, and App Intents/tool-call boundaries for generic iOS appsai-vector-brainFoundationModels framework composer, @Generable output, availability gating, guardrailsBefore concluding a local iOS AI engine recommendation or implementation:
answer and the grounding fields.${n}th concats anywhere).{ archetype, composerUsed, anchorCount, wordCount, latencyMs, groundingScore, refusalReason? }.answerSource and grounding inside the jsonb — not just in the HTTP response envelope — so evals, audits, and head-to-head replays can attribute every row to a composer.Before applying this skill on a non-trivial task, read learnings.consolidated.md in this directory (and learnings.md if present).
After applying it, if you encountered a pattern worth remembering, a mistake worth preventing, or a domain fact that surprised you, append one dated bullet to learnings.md via agents-skills-feedback-loop/scripts/append_learning.py. Do not modify SKILL.md itself.
Frequently asked questions
Use this skill when an iOS app should run useful AI behavior locally before spending cloud quota: Apple Foundation Models, deterministic local NLG, local retrieval stitching, local classifiers, extraction, summarization, tagging, rewrite helpers, and tool calls into app state. T…
The source record exposes this install command: npx skills add https://github.com/vasilyu1983/AI-Agents-public --skill "frameworks/shared-skills/skills/software-ios-ai-engine". Inspect the command and pinned source before running it.
Alternatives
coreyhaines31/marketingskills
When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program
coreyhaines31/marketingskills
When the user wants to reduce churn, build cancellation flows, set up save offers, recover failed payments, or implement retention strategies. Also use when the user mentions 'churn,' 'cancel flow,' 'offboarding,' 'save offer,' 'dunning,' 'failed payment recovery,' 'win-back,' 'retention,' 'exit survey,' 'pause subscription,' 'involuntary churn,' 'people keep canceling,' 'churn rate is too high,' 'how do I keep users,' or 'customers are leaving.' Use this whenever someone is losing subscribers o
prowler-cloud/prowler
PostgreSQL indexing best practices for Prowler: index design, partial indexes, partitioned table indexing, EXPLAIN ANALYZE validation, concurrent operations, monitoring, and maintenance. Trigger: When creating or modifying PostgreSQL indexes, analyzing query performance with EXPLAIN, debugging slow queries, reviewing index usage statistics, reindexing, dropping indexes, or working with partitioned table indexes. Also trigger when discussing index strategies, partial indexes, or index maintenance
oaustegard/claude-skills
Generate hierarchical _FEATURES.md files that describe what a codebase DOES from a user/consumer perspective, anchored to source symbols via tree-sitting. Supports large complex codebases through feature-driven decomposition into sub-feature files. Uses a multi-pass synthesis: orientation → detail → overview rewrite. Use when someone says "what does this do", "document features", "feature inventory", "_FEATURES.md", or needs to understand a codebase's purpose before modifying it. Complements tre