mastra-expert
Skill1 starsChanged 2 months agoMITView on GitHub
Expert guidance for the Mastra TypeScript AI framework — agents, workflows, memory, RAG, MCP, tools, voice, model routing, evals, observability, and deployment. USE WHEN Mastra, createWorkflow, createStep, createTool, MCPClient, Mastra agent, mastra dev, mastra build, suspend resume workflow, vector store, agent network, deploy Mastra. NOT FOR the raw Claude API or Anthropic SDK (use claude-api) or general project scaffolding (use app-scaffold).
In this repository21 other files it gives its agents.
- mastra-expert/Agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- app-scaffoldSkill
- blog-writerSkill
- claude-apiSkill
- community-managerSkill
- content-planSkill
- content-reviewSkill
- defense-analystSkill
- disclosure-writerSkill
- loop-runnerSkill
- project-ideasSkill
- prompt-injection-probeSkill
- red-team-scaffoldSkill
- script-writerSkill
- secure-reviewSkill
- seo-optimizeSkill
- social-repurposeSkill
- stack-checkSkill
- tool-reviewSkill
- vuln-triageSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 176
Full guide: Read Agents.md
- Distinctive: line 234
After building with Mastra:
- Very specific: line 235
Run /stack-check to verify all dependency versions are current
- Very specific: line 236
Run /secure-review to audit the application's security
- Very specific: line 237
Run /script-writer [Mastra topic] youtube to create content about the build
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
MastraExpert
Expert guidance for the Mastra TypeScript AI framework — building agents, workflows, memory systems, RAG pipelines, MCP integration, voice capabilities, model routing, evals, observability, server configuration, and deployment.
Workflow Routing
| Workflow | Trigger | File |
| CreateAgent | "create agent", "new agent", "build agent", "agent with tools" | Workflows/CreateAgent.md |
| BuildWorkflow | "create workflow", "build workflow", "orchestrate steps", "suspend resume" | Workflows/BuildWorkflow.md |
| SetupProject | "setup mastra", "new mastra project", "init mastra", "getting started" | Workflows/SetupProject.md |
| ConfigureMemory | "add memory", "configure memory", "RAG pipeline", "vector store", "semantic search" | Workflows/ConfigureMemory.md |
| AddEvals | "add evals", "create scorer", "evaluate agent", "observability", "tracing" | Workflows/AddEvals.md |
| DeployProject | "deploy mastra", "mastra build", "production deploy", "cloud deploy" | Workflows/DeployProject.md |
Examples
Example 1: Create an AI agent with tools
User: "Create a Mastra agent that can search and summarize documents"
-> Invokes CreateAgent workflow
-> Guides through Agent class, tool creation, memory setup
-> Generates agent + tool + registration codeExample 2: Build a multi-step workflow
User: "Build a workflow that processes documents with human approval"
-> Invokes BuildWorkflow workflow
-> Guides through createWorkflow, createStep, suspend/resume
-> Generates workflow with HITL patternExample 3: Set up a new Mastra project
User: "Set up a new Mastra project with TypeScript"
-> Invokes SetupProject workflow
-> Runs through npx create-mastra@latest or manual install
-> Creates project structure with agent, tool, and Mastra entry pointExample 4: Configure memory and RAG
User: "Add semantic memory to my agent with vector search"
-> Invokes ConfigureMemory workflow
-> Sets up Memory class, vector store, embeddings, chunking
-> Generates complete RAG pipeline codeExample 5: Add evaluation scorers
User: "Add evals to measure my agent's response quality"
-> Invokes AddEvals workflow
-> Creates scorers with createScorer()
-> Sets up CI integration and observabilityExample 6: Deploy to production
User: "Deploy my Mastra app to Vercel"
-> Invokes DeployProject workflow
-> Runs mastra build, configures deployment target
-> Sets up environment variables and monitoringQuick Reference
Core Domains
| Domain | Context File |
| Agents, networks, guardrails, processors | Agents.md |
| Workflow engine, control flow, HITL | WorkflowEngine.md |
| Memory system + RAG pipeline | MemoryAndRag.md |
| Server, auth, middleware, client | ServerAndDeployment.md |
| Voice providers, streaming patterns | VoiceAndStreaming.md |
| Evals, scorers, tracing, logging | EvalsAndObservability.md |
| MCP client/server, tool creation | McpAndTools.md |
| Model routing, gateways, providers | ModelsAndProviders.md |
Key APIs
| API | Import | Purpose |
Agent | @mastra/core/agent | Create AI agents with tools, memory, voice |
createWorkflow | @mastra/core/workflows | Graph-based workflow orchestration |
createStep | @mastra/core/workflows | Individual workflow step |
createTool | @mastra/core/tools | Define tools for agents |
Memory | @mastra/memory | Agent memory (history, working, semantic) |
MDocument | @mastra/rag | Document chunking for RAG |
MCPClient | @mastra/mcp | Connect to MCP servers |
MCPServer | @mastra/mcp | Expose resources as MCP |
Mastra | @mastra/core | Central orchestrator/registry |
MastraClient | @mastra/client-js | Type-safe API client |
createScorer | @mastra/evals | Build evaluation scorers |
CompositeVoice | @mastra/core/voice | Mix voice providers |
ModelRouterEmbeddingModel | @mastra/core/llm | Unified embedding access |
Model Format
// Direct provider: "provider/model-name"
model: "openai/gpt-5.1"
model: "anthropic/claude-opus-4-8"
model: "google/gemini-2.5-flash"
// Gateway: "gateway/provider/model"
model: "openrouter/anthropic/claude-haiku-4-5"
model: "vercel/alibaba/qwen-3-14b"
// Local/custom
model: { id: "lmstudio/qwen3-30b", url: "http://localhost:1234/v1" }
// Dynamic
model: ({ requestContext }) => requestContext.get("tier") === "enterprise"
? "openai/gpt-5" : "openai/gpt-4o-mini"
// Fallbacks
model: [
{ model: "openai/gpt-5", maxRetries: 3 },
{ model: "anthropic/claude-opus-4-8", maxRetries: 2 },
]Project Structure
src/mastra/
├── index.ts # Mastra entry point
├── agents/ # Agent definitions
├── tools/ # Tool definitions
├── workflows/ # Workflow definitions
└── scorers/ # Eval scorersEssential Commands
# Create new project
npx create-mastra@latest
# Development
mastra dev # Start dev server + Studio
# Build & deploy
mastra build # Build for production
mastra start # Start production server
# Studio
mastra studio # Standalone Studio UIDomain Summaries
Agents
Agentclass with instructions, model, tools, memory, voice- Agent networks for multi-agent routing
- Processors (input/output) for guardrails, moderation, PII detection
- Structured output with Zod schemas
- Tool approval and suspension patterns
- Full guide: Read
Agents.md
Workflow Engine
createWorkflow()+createStep()for graph-based orchestration- Control flow:
.then(),.parallel(),.branch(),.map(),.foreach(),.dountil() - Suspend/resume for human-in-the-loop
- Snapshots for state persistence
- Streaming with
writerAPI - Full guide: Read
WorkflowEngine.md
Memory & RAG
- 4 memory types: message history, working memory, semantic recall, observational
- 10+ storage adapters (PostgreSQL, libSQL, MongoDB, etc.)
- RAG pipeline: chunk -> embed -> store -> query -> rerank
- 17+ vector databases supported
- GraphRAG for relationship-based retrieval
- Full guide: Read
MemoryAndRag.md
Server & Deployment
- Hono-based HTTP server with middleware
- 8+ auth providers (JWT, Supabase, Auth0, Clerk, Firebase, WorkOS)
- RequestContext for dynamic runtime configuration
- MastraClient for type-safe API access
- Deploy to Vercel, Netlify, Cloudflare, AWS, Azure, DO, Mastra Cloud
- Full guide: Read
ServerAndDeployment.md
Voice & Streaming
- 10+ voice providers (OpenAI, ElevenLabs, PlayAI, Google, Deepgram, Azure)
- TTS, STT, real-time speech-to-speech
- CompositeVoice for mixing providers
- AI SDK integration for voice models
- Full guide: Read
VoiceAndStreaming.md
Evals & Observability
createScorer()with fluent builder API- 20+ built-in scorers (hallucination, toxicity, faithfulness)
- CI integration for automated evaluation
- 12+ tracing exporters (Langfuse, LangSmith, Datadog, Sentry)
- Custom span processors and formatters
- Full guide: Read
EvalsAndObservability.md
MCP & Tools
- MCPClient: connect to external MCP servers (stdio, SSE, HTTP)
- MCPServer: expose your agents/tools as MCP
- OAuth, elicitation, resources, prompts
createTool()with lifecycle hookscreateVectorQueryTool()andcreateGraphRAGTool()- Full guide: Read
McpAndTools.md
Models & Providers
- 2,436 models from 81 providers via unified
"provider/model"format - Gateways: OpenRouter (183 models), Vercel (189 models)
- Model fallbacks with automatic retry
- Dynamic model selection via RequestContext
- Embedding models with ModelRouterEmbeddingModel
- Full guide: Read
ModelsAndProviders.md
Next Steps
After building with Mastra:
- Run
/stack-checkto verify all dependency versions are current - Run
/secure-reviewto audit the application's security - Run
/script-writer [Mastra topic] youtubeto create content about the build
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.

