mastra-platform
Skill2 starsChanged 29 days agoApache-2.0View on GitHub
Deploy and operate Mastra applications on the hosted Mastra Platform: mastra deploy, projects and environments, regions, hosted Turso, Neon, and Postgres databases, the GitHub integration, Server and Studio hosting, platform workspaces, hosted observability with MastraPlatformExporter, Trace Intelligence, alerts, the control-plane REST API, and system environment variables. Use this skill whenever the user wants to ship to Mastra Platform, set up CI deploys with an API token, add a staging environment, attach a managed database, send traces to the platform from self-hosted infrastructure, configure alerts, or debug a failed platform deploy. Triggers on mastra deploy, .mastra-project.json, mastra env, mastra auth, MASTRA_API_TOKEN, MASTRA_PROJECT_ID, MASTRA_PLATFORM_ACCESS_TOKEN, MastraPlatformExporter, PlatformSandbox, @mastra/platform-workspace, projects.mastra.ai, mastra server deploy. Also triggers on preflight errors about file:./mastra.db.
- Reads credentials
In this repository46 other files it gives its agents.
- mastra-a2a-acpSkill
- mastra-agent-approval-hitlSkill
- mastra-agentic-uiSkill
- mastra-agent-skillsSkill
- mastra-agentsSkill
- mastra-authSkill
- mastra-browserSkill
- mastra-build-playbookSkill
- mastra-channelsSkill
- mastra-classifierSkill
- mastra-cli-apiSkill
- mastra-client-sdkSkill
- mastra-datasets-experimentsSkill
- mastra-deploymentSkill
- mastra-evalsSkill
- mastra-file-based-agentsSkill
- mastra-framework-integrationSkill
- mastra-guideSkill
- mastra-harnessSkill
- mastra-knowledgeSkill
- mastra-mcpSkill
- mastra-memorySkill
- mastra-migrationsSkill
- mastra-modelsSkill
- mastra-multi-agentSkill
- mastra-observabilitySkill
- mastra-observational-memorySkill
- mastra-processors-guardrailsSkill
- mastra-project-setupSkill
- mastra-ragSkill
- mastra-schedulesSkill
- mastra-semantic-recallSkill
- mastra-serverSkill
- mastra-signalsSkill
- mastra-storageSkill
- mastra-streamingSkill
- mastra-structured-outputSkill
- mastra-studio-editorSkill
- mastra-tool-integrationsSkill
- mastra-toolsSkill
- mastra-troubleshootingSkill
- mastra-vector-storesSkill
- mastra-voiceSkill
- mastra-workflowsSkill
- mastra-workflow-suspend-resumeSkill
- mastra-workspace-sandboxSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 96
Verify the API: If node_modules/@mastra/ exists, read node_modules/@mastra/core/dist/docs/.
- Very specific: line 97
Check credentials: Run mastra auth whoami. If there is no session and no MASTRA_API_TOKEN, ask the user to run mastra auth login in their …
- Very specific: line 98
Check the project link: If .mastra-project.json exists, reuse it.
- Very specific: line 104
Diagnose failures: Run the mastra env diagnosis <deploy-id> command the CLI prints.
- Very specific: line 119
Keep MASTRA_API_TOKEN and MASTRA_ORG_ID in the shell or CI secrets, not in the app's .env.
≈ “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
Mastra Platform
Deploy a Mastra app to the hosted Mastra Platform, manage its environments and databases, and wire hosted observability, while leaving sign-in and secret creation to the human.
When to use
- First deploy of a Mastra app with
mastra deploy, or redeploys from CI - Adding
stagingorpreviewenvironments, choosing theusoreuregion - Attaching a managed Turso, Neon, or Postgres database
- Linking a GitHub repository for push-to-deploy
- Using
PlatformFilesystemandPlatformSandboxworkspaces - Sending traces to the platform with
MastraPlatformExporter, including from self-hosted apps - Configuring alerts, reading deploy status, diagnosing a failed deploy
- Moving off the deprecated
mastra server deployandmastra studio deploy
When NOT to use
- Self-hosting on Vercel, Docker, Kubernetes, and other clouds (use
mastra-deployment) - Calling agents, workflows, or querying traces with
mastra api(usemastra-cli-api) - Platform Connect provider connections and
@mastra/connect(usemastra-tool-integrations) - Tracing configuration beyond the platform exporter (use
mastra-observability) - Storage adapter options (use
mastra-storage) - Workspace and sandbox APIs in depth (use
mastra-workspace-sandbox) - Studio features and auth inside Studio (use
mastra-studio-editor,mastra-auth) - Upgrading
@mastra/coreto reach a platform minimum version (usemastra-migrations)
Required inputs
- Whether the user is signed in (
mastra auth whoami) or has an API token set up for CI - Organization and project to target, or confirmation to create a new project
- Target environment (
productionby default) and region (usoreu, fixed at creation) - Model-provider keys and other runtime variables the app needs, and where they are stored
- Storage plan: managed database or an existing hosted one
Human steps stay human: signing up, creating an organization, mastra auth login, and creating API tokens. Never ask for secret values in chat, never print them, and never commit them. If a credential, org, or project is missing, stop and ask.
The framework: organization, project, environment
Organization (team, members, API tokens, alerts)
Project (.mastra-project.json links a directory to it)
Environment: production | staging | preview
URL, stored variables, deploy history, region
Optional hosted database (environment- or project-scoped)
Workspace: one bucket + on-demand sandboxesProducts on a project: Observability (always included), Studio (hosted UI, protected by platform auth), Server (production API).
One command builds, preflights, uploads, deploys, and streams logs:
mastra deploy
mastra deploy --env staging
mastra deploy --env production --region euThe first deploy creates the project (named from package.json) and the production environment, and writes .mastra-project.json. Commit that file. It holds no secrets.
Project resolution order for deploys: MASTRA_PROJECT_ID, then --project <name|slug|id>, then .mastra-project.json.
Storage must survive the ephemeral filesystem. Guard any local path with an env var:
import { LibSQLStore } from '@mastra/libsql'
export const storage = new LibSQLStore({
id: 'mastra-storage',
// Uses the hosted database when deployed, a local file during development
url: process.env.TURSO_DATABASE_URL ?? 'file:./mastra.db',
authToken: process.env.TURSO_AUTH_TOKEN,
})Workflow
- Verify the API. If
node_modules/@mastra/exists, readnode_modules/@mastra/core/dist/docs/. Fetchhttps://mastra.ai/docs/mastra-platform/deploy.mdand checkmastra deploy --help. For REST calls, checkhttps://platform.mastra.ai/openapi.json. Trust these over memory. - Check credentials. Run
mastra auth whoami. If there is no session and noMASTRA_API_TOKEN, ask the user to runmastra auth loginin their own terminal. Do not read~/.mastra/credentials.json. - Check the project link. If
.mastra-project.jsonexists, reuse it. Otherwise confirm with the user whether to create a new project or deploy into an existing one (--projectreplaces what runs there). - Fix storage. Guard local paths with env vars. Attach a managed database with
mastra env db create <env> --kind turso|neon|postgres(admin role required). - Check runtime variables. List the keys the app reads. If they are not stored on the environment, ask the user to put them in a gitignored env file and deploy with
--env-file. Never fill that file from your own shell. - Run preflight.
mastra lint --preflightcatches local storage paths and missing variables without deploying. It cannot see platform-stored variables. - Deploy.
mastra deploy --env <name> --yesfor non-interactive runs. Avoid--skip-preflight. - Verify. The CLI exits non-zero on failure and prints the Server URL on success. Hit
<url>/api/agentsand<url>/health, then runmastra api --url <url> agent list(seemastra-cli-api). - Diagnose failures. Run the
mastra env diagnosis <deploy-id>command the CLI prints. - Automate. For CI, the user creates a token (
mastra auth tokens create ci-deploy) and stores it as a CI secret withMASTRA_ORG_IDandMASTRA_PROJECT_ID. Or link GitHub for push-to-deploy.
Deep dive: credentials and variables
Two credential families. Do not mix them.
| Variable | Used by | Purpose |
MASTRA_API_TOKEN | CLI, control-plane REST | Headless deploys. Wins over a saved login. Requires MASTRA_ORG_ID and MASTRA_PROJECT_ID. |
MASTRA_ORG_ID, MASTRA_PROJECT_ID | CLI | Org and project selection. |
MASTRA_PLATFORM_ACCESS_TOKEN | App runtime | Observability export and workspaces. Injected on deploy. Not a deploy credential. |
Keep MASTRA_API_TOKEN and MASTRA_ORG_ID in the shell or CI secrets, not in the app's .env. Deploy uploads the selected env file as-is.
Variable precedence on deploy (last wins): variables stored on the environment, then managed database variables, then platform system variables (MASTRA_ENVIRONMENT_NAME, MASTRA_PLATFORM_REGION, and others). A local env file is layered on top of stored variables and saved to the environment. Apply dashboard changes without redeploying with mastra env restart <env>.
Failure patterns
- Preflight blocks
file:./mastra.db. Guard the URL withprocess.env.TURSO_DATABASE_URL ?? 'file:./mastra.db'and attach a database. Build contains a host-local storage URL. The path is hard-coded. Add the env var guard; the inline fix cannot help.- Deploy succeeds but agent calls fail. Provider key missing on the environment. Ask the user to add it to a gitignored env file and redeploy with
--env-file. - CI job hangs. Missing
--yes. Headless mode also needsMASTRA_API_TOKEN,MASTRA_ORG_ID, andMASTRA_PROJECT_ID. MASTRA_CORE_TOO_OLD. The environment pipeline needs@mastra/core >= 1.44. Upgrade, then usemastra deploy.- 401. Wrong credential type.
MASTRA_PLATFORM_ACCESS_TOKENcannot replaceMASTRA_API_TOKEN. - 403. Role too low (viewer creating projects, non-admin creating databases or enabling workspaces).
- Neon and Postgres attached to one environment. Both inject
DATABASE_URL. Use one. - Shared and environment-scoped database of the same provider. Variable name conflict. Delete the shared one first (this destroys its data).
- Stored variable ignored at runtime. It collides with a system variable name. Rename it.
- Server never idles. Persistent DB connections, timers, pings, or Socket Mode chat bots keep it awake. Close idle clients or use the Persistent Server add-on.
- Streaming turns cut off during a deploy. The platform does not guarantee extra drain time. Use durable agents or handle interrupted streams in the client.
- Traces missing from an EU project. EU data lives at
https://observability.eu.mastra.ai. SetMASTRA_PLATFORM_OBSERVABILITY_ENDPOINTor query with--url.
Output format
A finished platform delivery contains:
.mastra-project.jsoncommitted, with no secrets in the repo- Storage guarded by env vars, and the attached database listed (
mastra env db list) - The list of runtime variable names the app needs and where each is stored
- A CI workflow using
mastra deploy --yeswith secrets, or a linked GitHub repo - Observability configured (
MastraPlatformExporter) with a stableserviceName - Verification: deploy status
running,<url>/api/agentsreturns JSON, one agent call succeeds
Reference files
references/api.md- CLI commands and flags, REST routes, env vars, regions, database kinds, alert triggers.references/examples.md- First deploy, CI deploy, staging with its own database, hosted observability, workspaces.references/checklist.md- Platform deploy checklist.
Live docs
- https://mastra.ai/docs/mastra-platform/overview
- https://mastra.ai/docs/mastra-platform/deploy
- https://mastra.ai/docs/mastra-platform/configuration
- https://mastra.ai/docs/mastra-platform/environments
- https://mastra.ai/docs/mastra-platform/regions
- https://mastra.ai/docs/mastra-platform/database
- https://mastra.ai/docs/mastra-platform/github
- https://mastra.ai/docs/mastra-platform/server
- https://mastra.ai/docs/mastra-platform/studio
- https://mastra.ai/docs/mastra-platform/workspaces
- https://mastra.ai/docs/mastra-platform/observability
- https://mastra.ai/docs/mastra-platform/trace-intelligence
- https://mastra.ai/docs/mastra-platform/alerts
- https://mastra.ai/docs/mastra-platform/api
- https://mastra.ai/docs/mastra-platform/system-environment-variables
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.

