foundation-models-pro
Skill8 starsChanged 12 days agoMITView on GitHub
Writes and reviews Apple Foundation Models code — LanguageModelSession ownership in a MainActor Observable holder, availability gating per unavailable reason, streaming with placeholders and cancellation, Private Cloud Compute and external models through LanguageModelExecutor, multimodal input, error handling, testability with protocol mocks, and VoiceOver for streamed output. Use when adding an on-device AI feature or reviewing one.
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- android-accessibility-proSkill
- android-adaptive-layout-proSkill
- android-compose-proSkill
- android-coroutines-proSkill
- android-design-system-proSkill
- android-gradle-architecture-proSkill
- android-library-proSkill
- android-memory-storage-proSkill
- android-modularization-proSkill
- app-intents-proSkill
- beta-deployment-proSkill
- coredata-swift6-proSkill
- cross-platform-parity-proSkill
- flaky-tests-proSkill
- instruments-profiling-proSkill
- linting-proSkill
- localization-proSkill
- motion-design-proSkill
- r8-shrink-proSkill
- store-compliance-proSkill
- swift-accessibility-proSkill
- swift-adaptive-layout-proSkill
- swift-concurrency-proSkill
- swiftdata-proSkill
- swift-design-system-proSkill
- swift-docc-proSkill
- swift-error-handling-proSkill
- swift-library-proSkill
- swift-logging-proSkill
- swift-memory-storage-proSkill
- swift-modularization-proSkill
- swift-package-proSkill
- swift-testing-proSkill
- swiftui-proSkill
- visionos-proSkill
- xcode-security-proSkill
- xml-to-compose-migration-proSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
Availability: every .unavailable reason handled distinctly, plus a user preference.
- Distinctive: line 23
Testability: only the real implementation imports FoundationModels.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Make on-device and Apple-hosted model features reliable: available only where they work, responsive while streaming, cancellable, private by default, and testable without a device. This is the deep companion to the always-on apple-foundation-models.md rule. Report only genuine problems.
Several APIs here (
PrivateCloudComputeLanguageModel,LanguageModelExecutor,LanguageModelCapabilities, multimodal input) come from the Xcode 27 seeds. Verify each symbol against the SDK in use before citing it in a finding.
Load references/foundation-models.md for the full guidance: session ownership, availability gating with a switch over every unavailable reason, choosing between on-device, Private Cloud Compute, and external models, multimodal input, streaming, error handling, the protocol + mock + simulator pattern, SwiftUI integration, accessibility for streamed output, and complete code patterns. If doing a partial review, read only the matching section.
Review Checklist
- Ownership: the session lives in a
@MainActor @Observable final class, one per conversation, recreated only when its configuration changes. - Availability: every
.unavailablereason handled distinctly, plus a user preference; no session created before the check. - Model choice: the holder depends on
any LanguageModel; data that leaves the device has consent, minimum context, a privacy-manifest entry, and per-storefront gating. - Streaming: placeholder appended first and removed on error;
Task.isCancelledchecked in the loop;defer { isGenerating = false }; send disabled while generating. - Errors: caught broadly, shown localized, logged in full; no matching on beta error cases.
- Testability: only the real implementation imports FoundationModels; mock and simulator implementations exist and are injected.
- Accessibility: a localized thinking label while streaming, the final text set once.
Output Format
Group findings by severity: blocking (no availability check, data sent off-device without consent, generation that can't be cancelled, isGenerating stuck after an error), degraded (session recreated per prompt, empty bubble left on error, untestable direct imports), polish (naming, accessibility labels). Give each as file:line, the user-visible effect, and the fix with before/after. End with the count per severity and the first three fixes.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

