/on-device-ai
Build on-device AI features in React Native and Expo apps with React Native ExecuTorch. Use when adding AI to a mobile app without cloud dependencies — chatbots, image classification, object detection, OCR, semantic or instance segmentation, style transfer, image generation,
$ npx -y skills add software-mansion-labs/skills --skill on-device-ai --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/on-device-ai
Context preview
The summary Claude sees to decide when to auto-load this skill.
Build on-device AI features in React Native and Expo apps with React Native ExecuTorch. Use when adding AI to a mobile app without cloud dependencies — chatbots, image classification, object detection, OCR, semantic or instance segmentation, style transfer, image generation,
SKILL.md
on-device-ai.SKILL.mdname: on-device-ai
description: Build on-device AI features in React Native and Expo apps with React Native ExecuTorch. Use when adding AI to a mobile app without cloud dependencies — chatbots, image classification, object detection, OCR, semantic or instance segmentation, style transfer, image generation, pose estimation, speech-to-text, text-to-speech, voice activity detection, semantic search with embeddings, tokenization, privacy / PII redaction, or vision-language image understanding. Also use when mentioning offline / on-device / privacy AI, reducing cloud cost or latency, or managing ML models. Covers initExecutorch and every hook (useLLM, useClassification, useObjectDetection, useOCR, useSemanticSegmentation, useInstanceSegmentation, useStyleTransfer, useTextToImage, useImageEmbeddings, usePoseEstimation, useSpeechToText, useTextToSpeech, useVAD, useTextEmbeddings, useTokenizer, usePrivacyFilter, useExecutorchModule), tool calling, structured output, VLMs, Expo and bare resource-fetcher adapters, and error handling.
React Native ExecuTorch
Software Mansion's production patterns for on-device AI in React Native and Expo using [React Native ExecuTorch](https://github.com/software-mansion/react-native-executorch).
Targets the current published API (v0.10.x). Load at most one reference file per question. For hook signatures, model constants, or config options not covered here, webfetch the matching page from [docs.swmansion.com/react-native-executorch](https://docs.swmansion.com/react-native-executorch/docs/).
Decision Tree
What does the feature need?
│
├── Generate / chat with text?
│ └── useLLM → see llm.md
│ ├── Plain chat → standard useLLM
│ ├── Image + text input → useLLM with a VLM model (LFM2_VL_*)
│ ├── Tool / function calling → configure with toolsConfig
│ └── Structured JSON output → getStructuredOutputPrompt
│
├── Understand or transform images?
│ ├── What is in this image? → useClassification → see vision.md
│ ├── Where are the objects? → useObjectDetection → see vision.md
│ ├── Per-pixel class → useSemanticSegmentation → see vision.md
│ ├── Per-instance segmentation → useInstanceSegmentation → see vision.md
│ ├── Human pose keypoints → usePoseEstimation → see vision.md
│ ├── Read text from image → useOCR / useVerticalOCR → see vision.md
│ ├── Apply artistic style → useStyleTransfer → see vision.md
│ ├── Generate image from prompt → useTextToImage → see vision.md
│ └── Embed image as vector → useImageEmbeddings → see vision.md
│
├── Speech / audio?
│ ├── Transcribe speech → useSpeechToText → see speech.md
│ ├── Synthesize speech → useTextToSpeech → see speech.md
│ └── Detect speech segments → useVAD → see speech.md
│
├── Text utilities?
│ ├── Embed text as vector → useTextEmbeddings → see vision.md
│ ├── Count or inspect tokens → useTokenizer → see setup.md
│ └── Redact PII from text → usePrivacyFilter → see setup.md
│
├── Full RAG pipeline (retrieval + generation + vector store)?
│ └── react-native-rag (sibling library) → see setup.md
│
└── Custom `.pte` model not covered by a dedicated hook?
└── useExecutorchModule → see setup.mdCritical Rules
- **Call `initExecutorch()` at app entry, before any other API.** The library does not bundle a network/file layer — you must register a resource-fetcher adapter (`ExpoResourceFetcher` for Expo, `BareResourceFetcher` for bare RN). Any hook called before initialization throws `ResourceFetcherAdapterNotInitialized`.
- **Check `isReady` before calling `forward` / `generate` / `transcribe`.** All hooks load asynchronously. Inference before the model is ready throws `ModuleNotLoaded`.
- **Interrupt LLM generation before unmounting.** Unmounting while `isGenerating` is `true` crashes. Call `llm.interrupt()` and wait for `isGenerating === false` before navigating away.
- **Use quantized model variants on mobile.** Full-precision variants exceed device memory on most phones. Every supported model ships a `_QUANTIZED` variant — prefer it unless you've measured otherwise.
- **Audio for speech-to-text and VAD must be 16 kHz mono.** Mismatched sample rates produce silently garbled transcriptions. Decode with `new AudioContext({ sampleRate: 16000 })`.
- **Audio from text-to-speech is 24 kHz.** Create the playback context with `new AudioContext({ sampleRate: 24000 })`.
- **The New Architecture (Fabric) is required.** Old architecture is unsupported. Expo Go is unsupported — use a custom dev build (`npx expo prebuild`). iOS release builds need a real device (the simulator lacks the Metal APIs ExecuTorch relies on).
Minimal Setup
// App.tsx (Expo)
import { initExecutorch } from 'react-native-executorch';
import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher';
initExecutorch({ resourceFetcher: ExpoResourceFetcher });// App.tsx (bare React Native)
import { initExecutorch } from 'react-native-executorch';
import { BareResourceFetcher } from 'react-native-executorch-bare-resource-fetcher';
initExecutorch({ resourceFetcher: BareResourceFetcher });Full setup, Metro config for bundled `.pte` files, custom adapters, model-loading strategies, and error handling: see [setup.md](setup.md).
Hook Quick Reference
| Hook | Purpose | Reference | |---|---|---| | `useLLM` | Text generation, chat, tool calling, VLM | [llm.md](llm.md) | | `useClassification` | Image categorisation | [vision.md](vision.md) | | `useObjectDetection` | Bounding-box detection (YOLO26, RF-DETR, SSDLite) | [vision.md](vision.md) | | `useSemanticSegmentation` | Per-pixel class segmentation | [vision.md](vision.md) | | `useInstanceSegmentation` | Per-instance segmentation | [vision.md](vision.md) | | `usePoseEstimation` | COCO 17-keypoint human
Read more
name: on-device-ai description: Build on-device AI features in React Native and Expo apps with React Native ExecuTorch. Use when adding AI to a mobile app without cloud dependencies — chatbots, image classification, object detection, OCR, semantic or instance segmentation, style transfer, image generation, pose estimation, speech-to-text, text-to-speech, voice activity detection, semantic search with embeddings, tokenization, privacy / PII redaction, or vision-language image understanding. Also use when mentioning offline / on-device / privacy AI, reducing cloud cost or latency, or managing ML models. Covers initExecutorch and every hook (useLLM, useClassification, useObjectDetection, useOCR, useSemanticSegmentation, useInstanceSegmentation, useStyleTransfer, useTextToImage, useImageEmbeddings, usePoseEstimation, useSpeechToText, useTextToSpeech, useVAD, useTextEmbeddings, useTokenizer, usePrivacyFilter, useExecutorchModule), tool calling, structured output, VLMs, Expo and bare resource-fetcher adapters, and error handling.
React Native ExecuTorch
Software Mansion's production patterns for on-device AI in React Native and Expo using [React Native ExecuTorch](https://github.com/software-mansion/react-native-executorch).
Targets the current published API (v0.10.x). Load at most one reference file per question. For hook signatures, model constants, or config options not covered here, webfetch the matching page from [docs.swmansion.com/react-native-executorch](https://docs.swmansion.com/react-native-executorch/docs/).
Decision Tree
What does the feature need?
│
├── Generate / chat with text?
│ └── useLLM → see llm.md
│ ├── Plain chat → standard useLLM
│ ├── Image + text input → useLLM with a VLM model (LFM2_VL_*)
│ ├── Tool / function calling → configure with toolsConfig
│ └── Structured JSON output → getStructuredOutputPrompt
│
├── Understand or transform images?
│ ├── What is in this image? → useClassification → see vision.md
│ ├── Where are the objects? → useObjectDetection → see vision.md
│ ├── Per-pixel class → useSemanticSegmentation → see vision.md
│ ├── Per-instance segmentation → useInstanceSegmentation → see vision.md
│ ├── Human pose keypoints → usePoseEstimation → see vision.md
│ ├── Read text from image → useOCR / useVerticalOCR → see vision.md
│ ├── Apply artistic style → useStyleTransfer → see vision.md
│ ├── Generate image from prompt → useTextToImage → see vision.md
│ └── Embed image as vector → useImageEmbeddings → see vision.md
│
├── Speech / audio?
│ ├── Transcribe speech → useSpeechToText → see speech.md
│ ├── Synthesize speech → useTextToSpeech → see speech.md
│ └── Detect speech segments → useVAD → see speech.md
│
├── Text utilities?
│ ├── Embed text as vector → useTextEmbeddings → see vision.md
│ ├── Count or inspect tokens → useTokenizer → see setup.md
│ └── Redact PII from text → usePrivacyFilter → see setup.md
│
├── Full RAG pipeline (retrieval + generation + vector store)?
│ └── react-native-rag (sibling library) → see setup.md
│
└── Custom `.pte` model not covered by a dedicated hook?
└── useExecutorchModule → see setup.mdCritical Rules
- **Call `initExecutorch()` at app entry, before any other API.** The library does not bundle a network/file layer — you must register a resource-fetcher adapter (`ExpoResourceFetcher` for Expo, `BareResourceFetcher` for bare RN). Any hook called before initialization throws `ResourceFetcherAdapterNotInitialized`.
- **Check `isReady` before calling `forward` / `generate` / `transcribe`.** All hooks load asynchronously. Inference before the model is ready throws `ModuleNotLoaded`.
- **Interrupt LLM generation before unmounting.** Unmounting while `isGenerating` is `true` crashes. Call `llm.interrupt()` and wait for `isGenerating === false` before navigating away.
- **Use quantized model variants on mobile.** Full-precision variants exceed device memory on most phones. Every supported model ships a `_QUANTIZED` variant — prefer it unless you've measured otherwise.
- **Audio for speech-to-text and VAD must be 16 kHz mono.** Mismatched sample rates produce silently garbled transcriptions. Decode with `new AudioContext({ sampleRate: 16000 })`.
- **Audio from text-to-speech is 24 kHz.** Create the playback context with `new AudioContext({ sampleRate: 24000 })`.
- **The New Architecture (Fabric) is required.** Old architecture is unsupported. Expo Go is unsupported — use a custom dev build (`npx expo prebuild`). iOS release builds need a real device (the simulator lacks the Metal APIs ExecuTorch relies on).
Minimal Setup
// App.tsx (Expo)
import { initExecutorch } from 'react-native-executorch';
import { ExpoResourceFetcher } from 'react-native-executorch-expo-resource-fetcher';
initExecutorch({ resourceFetcher: ExpoResourceFetcher });// App.tsx (bare React Native)
import { initExecutorch } from 'react-native-executorch';
import { BareResourceFetcher } from 'react-native-executorch-bare-resource-fetcher';
initExecutorch({ resourceFetcher: BareResourceFetcher });Full setup, Metro config for bundled `.pte` files, custom adapters, model-loading strategies, and error handling: see [setup.md](setup.md).
Hook Quick Reference
| Hook | Purpose | Reference | |---|---|---| | `useLLM` | Text generation, chat, tool calling, VLM | [llm.md](llm.md) | | `useClassification` | Image categorisation | [vision.md](vision.md) | | `useObjectDetection` | Bounding-box detection (YOLO26, RF-DETR, SSDLite) | [vision.md](vision.md) | | `useSemanticSegmentation` | Per-pixel class segmentation | [vision.md](vision.md) | | `useInstanceSegmentation` | Per-instance segmentation | [vision.md](vision.md) | | `usePoseEstimation` | COCO 17-keypoint human
Software Mansion's set of skills for AI-assisted React Native development.
Repo: software-mansion-labs/skills
Other skills on software-mansion-labs-skills.
- /detour-onboarding
Complete onboarding guide for developers who are new to Detour, the open-source deferred deep linking SDK by Software Mansion. Use this skill whenever a user asks what Detour is, how to get started with Detour, how to set up deep linking with Detour, how to install the Detour
Open skill - /migrate-to-detour
Use when the user mentions migrating deep links, switching away from Branch or AppsFlyer, replacing their deep linking SDK, setting up Detour deep linking for the first time, or asks how Branch/AppsFlyer concepts map to Detour. Covers the complete migration end to end - Detour
Open skill - /expo-horizon
Software Mansion's guide for migrating Expo SDK apps to Meta Quest using expo-horizon packages. Use when adding Meta Quest or Meta Horizon OS support to an existing Expo or React Native project. Trigger on: Meta Quest, Horizon OS, Quest 2, Quest 3, Quest 3S, VR app,
Open skill - /fishjam
Software Mansion's Fishjam — hosted WebRTC platform for video, audio, and one-to-many livestreaming. MUST USE before writing, reviewing, or debugging ANY code that talks to a Fishjam instance from a backend (Node, Python) or a client (React web, React Native / Expo). Routes to
Open skill - /js-server-sdk
Node.js / TypeScript server SDK for Fishjam — backends that create rooms, mint peer tokens, listen to server notifications, and run agents. Use when writing a Node.js / Express / Fastify / Hono / NestJS backend that talks to Fishjam, sets up a webhook receiver, runs an AI agent,
Open skill - /platform
Fishjam platform fundamentals — domain model and auth shared by all SDKs. Covers glossary (room, peer, track, agent, streamer, viewer), the four room types (conference / audio_only / livestream / audio_only_livestream), two-tier auth (management vs peer tokens), Sandbox vs
Open skill

