agentleFS
kelvinkosbabkelvinkosbab/AppBootstrapAI/.claude/skills/foundation-models-pro/SKILL.md

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.

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
  1. Very specific:

    Availability: every .unavailable reason handled distinctly, plus a user preference.

    line 19
  2. Distinctive:

    Testability: only the real implementation imports FoundationModels.

    line 23

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Ownership: the session lives in a @MainActor @Observable final class, one per conversation, recreated only when its configuration changes.
  2. Availability: every .unavailable reason handled distinctly, plus a user preference; no session created before the check.
  3. 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.
  4. Streaming: placeholder appended first and removed on error; Task.isCancelled checked in the loop; defer { isGenerating = false }; send disabled while generating.
  5. Errors: caught broadly, shown localized, logged in full; no matching on beta error cases.
  6. Testability: only the real implementation imports FoundationModels; mock and simulator implementations exist and are injected.
  7. 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.