Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build Mastra AI agents and workflows with guidance on current API lookup, tools, memory, and RAG patterns.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: mastra3description: "Comprehensive Mastra framework guide for building agents, workflows, tools, memory, workspaces, and storage with current APIs. Use for documentation lookup, API verification, TypeScript setup, common errors, migrations, and `mastra api` CLI tasks: inspect or call resources on local, Mastra platform, or remote servers."4license: Apache-2.05metadata:6author: Mastra7version: "2.0.0"8repository: https://github.com/mastra-ai/skills9---1011# Mastra Framework Guide1213Build AI applications with Mastra. This skill teaches you how to find current documentation and build agents and workflows.1415## Critical: Do not trust internal knowledge1617Everything you know about Mastra is likely outdated or wrong. Never rely on memory. Always verify against current documentation.1819Your training data contains obsolete APIs, deprecated patterns, and incorrect usage. Mastra evolves rapidly - APIs change between versions, constructor signatures shift, and patterns get refactored.2021## Prerequisites2223Before writing any Mastra code, check if packages are installed:2425```bash26ls node_modules/@mastra/27```2829- If packages exist: Use embedded docs first (most reliable)30- If no packages: Install first or use remote docs3132## Resources3334### References3536| User Question | First Check | How To |37| ----------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------- |38| Create/install Mastra project | [`references/create-mastra.md`](references/create-mastra.md) | Setup guide with CLI and manual steps |39| Choose Agent/Workflow/Tool/Memory/Storage | [`references/core-concepts.md`](references/core-concepts.md) | Core concepts and when to use each primitive |40| How do I use Agent/Workflow/Tool? | [`references/embedded-docs.md`](references/embedded-docs.md) | Look up in `node_modules/@mastra/*/dist/docs/` |41| How do I use X? (no packages) | [`references/remote-docs.md`](references/remote-docs.md) | Fetch from `https://mastra.ai/llms.txt` |42| Choose or validate a model | [`references/model-selection.md`](references/model-selection.md) | Model format and provider registry lookup |43| I'm getting an error... | [`references/common-errors.md`](references/common-errors.md) | Common errors and solutions |44| Upgrade from v0.x to v1.x | [`references/migration-guide.md`](references/migration-guide.md) | Version upgrade workflows |45| Inspect/call server resources via CLI | [`references/mastra-api.md`](references/mastra-api.md) | `mastra api` CLI for local, Mastra platform, or remote servers |4647### Scripts4849- `scripts/provider-registry.mjs`: Look up current providers and models available in the model router. Always run this before using a model to verify provider keys and model names.5051## Priority order for writing code5253Never write code without checking current docs first.54551. Embedded docs first (if packages installed)5657Look up current docs in `node_modules` for a package. This matches the exact installed version and is the most reliable source of truth. See [`references/embedded-docs.md`](references/embedded-docs.md).58592. Source code second (if packages installed)6061If embedded docs don't cover the question, inspect the installed source and type definitions. This is the source of truth when docs are missing or unclear. See [`references/embedded-docs.md`](references/embedded-docs.md).62633. Remote docs third (if packages not installed)6465Use the latest published docs when packages are not installed or when exploring new features. Remote docs may be ahead of the user's installed version. See [`references/remote-docs.md`](references/remote-docs.md).6667## Core concepts6869Use [`references/core-concepts.md`](references/core-concepts.md) when choosing between agents, workflows, tools, memory, and storage.7071- Agent: Use for open-ended tasks that make decisions and use tools.72- Workflow: Use for defined multi-step processes.7374## Mastra Studio7576Studio is the interactive UI for building, testing, and managing agents, workflows, and tools. Use Studio when advising a human to inspect or debug visually.7778Inside a Mastra project, run:7980```bash81npm run dev82```8384Then open `http://localhost:4111` in a browser to show Mastra Studio to your human user.8586## Mastra API CLI8788Use `mastra api` to inspect or call resources on local dev servers, Mastra platform deployments, or remote Mastra endpoints. It is useful for agent-readable state, execution, traces, logs, scores, threads, and workflow operations. See [`references/mastra-api.md`](references/mastra-api.md) for usage patterns.8990## Critical requirements9192### TypeScript config9394Mastra requires ES2022 modules. CommonJS will fail. See [`references/create-mastra.md`](references/create-mastra.md) for setup and [`references/common-errors.md`](references/common-errors.md) for troubleshooting.9596### Model format9798Always use `"provider/model-name"` when defining models using Mastra's model router.99100When the user asks to use a model or provider, always run `scripts/provider-registry.mjs` first to verify the provider key and model name are valid. Do not guess model names from memory as they change frequently. See [`references/model-selection.md`](references/model-selection.md).101102## When you see errors103104Type errors often mean your knowledge is outdated.105106Common signs of outdated knowledge:107108- `Property X does not exist on type Y`109- `Cannot find module`110- `Type mismatch` errors111- Constructor parameter errors112113What to do:1141151. Check [`references/common-errors.md`](references/common-errors.md)1162. Verify current API in embedded docs1173. Don't assume the error is a user mistake - it might be your outdated knowledge118119## Development workflow120121Always verify before writing code:1221231. Check whether Mastra packages are installed1242. Look up current API125- If installed: Use embedded docs [`references/embedded-docs.md`](references/embedded-docs.md)126- If not: Use remote docs [`references/remote-docs.md`](references/remote-docs.md)1273. Write code based on current docs1284. Test with the project scripts or Studio when available129