You pick the shape with
metadata.foreground, metadata.background, or both
in truffile.yaml. Foreground apps can run Python tools or use a native remote
MCP connector. See accounts and authentication for a complete
connector example and connection-scoped credentials.
The supported development loop is intentionally CLI-first: scaffold locally,
check the bundle locally, preview the upload, then deploy through the native
installer and builders. Use --update for later code changes that preserve
installed accounts.
The bundled examples live under truffile/app-store/ in the truffile repo. Treat them as reference implementations:
The SDK import surface
App code imports everything it needs fromtruffile.app_runtime. This is the module that ships with the truffile package when you pip install truffile.
truffile.app_runtime in the installed package. Once you pip install truffile, the same runtime is importable from app code running on your device.
There are two other entry points that import the same names:
from truffile.sdk import ...— a curated re-export module with nice grouping. Use this if you prefer one obvious “public API” import.from truffile import ForegroundApp, BackgroundWorkerApp, ToolSpec, ok, err, OAuth, AppHarness— the most common names are also re-exported at the top level.
truffile.app_runtime because it is the clearest app-authoring import surface.
Scaffold a new app
The fastest way to start:truffile create <name>— set the name, prompt for base pathtruffile create <name> --path <dir>— set name and base pathtruffile create— fully interactive
foreground / background sections you keep in truffile.yaml.
Let an agent build the app for you
If you’re working in the truffile repo with a coding agent — Claude Code, Codex, or any other agent that can read skill files — there’s a built-in skill it can follow to build a Truffle app end-to-end:truffle-app-creator (at truffile/skills/truffle-app-creator/SKILL.md).
It’s the fastest path for things like:
- “Create a Truffle app that talks to <service>”
- “Port this MCP server to Truffle”
- “Build an integration with <API> and run it in the background”
truffile create to scaffold, implements the client/auth/tools, writes tests, and runs truffile validate + truffile deploy for you. Just describe the service you want to connect and it takes over from there.
truffile.yaml structure
Every app needs a truffile.yaml. This authenticated process example assumes
you implement the Python entrypoints, including a --verify mode that checks
the API key and exits. For a first ping test, use the generated scaffold as-is.
Supported step types
Steps run during installation on the device, in order. The manifest supports:
See the Install steps reference for every option on each type — field shapes, validators, exit code semantics, and multi-field examples.
Native deployment can present browser/VNC setup cards from firmware. Open the
shown setup URL and follow the app’s flow. The explicit legacy builder supports
only its older step subset; use normal deploy for modern manifests.
Auth patterns
Pick the smallest auth surface that matches the upstream service:
For
text auth, implement a provider check and call it from a connection-scoped
validator. Native OAuth stores tokens for the selected connection. Custom Python
apps use runtime credential helpers; native connectors declare an OAuth
app_var_key matching their connection step. See the account guide
for the complete connector recipe. Older bundled token-file examples should not
be copied into shared state for a multi-account app.
If an update reaches an auth step that cannot be refreshed non-interactively, fail clearly and ask the user to run truffile connections reconnect "My App".
Build and deploy flow
validatechecks bundle structure and basic metadata. Usepython -m compileall -q ./my-appseparately for Python syntax.deploy --dry-runpackages and describes the bundle without changing the device.deploysends the original manifest to firmware for semantic validation, builder execution and account setup.
truffile deploy ./my-app --update. This preserves
accounts, credentials and saved settings. --replace deliberately resets
accounts after confirmation. Current firmware is required for uploaded updates
and replacements; the CLI checks support before either operation.
--interactive opens the explicit legacy builder’s shell. Ordinary native
sign-in prompts do not require that flag. See deployment
for packaging exclusions, timeouts, account selection and scripted setup.
After deployment, use an agent-safe one-shot request as a routing smoke test:
tool_calls in the JSON result. This tests normal agent discovery and
tool routing only. Convo has no per-thread app allowlist, so the CLI cannot
attach the newly deployed app or guarantee that this request uses it. Use
truffile infer --mcp <url> before deployment when you need deterministic
local selection of the app’s MCP server.
Runtime stability pattern
Whatever network clients your app opens — HTTP sessions, database connections, MCP subprocesses — close them on shutdown:Next steps
Build a Foreground App
Use
ForegroundApp to expose MCP tools the agent can call on demand.Build a Background App
Use
BackgroundWorkerApp to run on a schedule and submit context to the proactive agent.