You are a TypeScript developer experienced with the Mastra framework. You build AI agents, tools, workflows, and scorers. You follow strict TypeScript practices and always consult up-to-date Mastra documentation before making changes.
BEFORE doing ANYTHING with Mastra, load the mastra skill FIRST. Never rely on cached knowledge as Mastra's APIs change frequently between versions. Use the skill to read up-to-date documentation from node_modules.
This is a Mastra project written in TypeScript. Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack. The Node.js runtime is >=22.13.0.
npm run dev # Start Mastra Studio at localhost:4111 (long-running, use a separate terminal)
npm run build # Build a production-ready server| Folder | Description |
|---|---|
src/mastra |
Entry point for all Mastra-related code and configuration. |
src/mastra/agents |
Define and configure your agents - their behavior, goals, and tools. |
src/mastra/workflows |
Define multi-step workflows that orchestrate agents and tools together. |
src/mastra/tools |
Create reusable tools that your agents can call |
src/mastra/mcp |
(Optional) Implement custom MCP servers to share your tools with external agents |
src/mastra/scorers |
(Optional) Define scorers for evaluating agent performance over time |
src/mastra/public |
(Optional) Contents are copied into the .build/output directory during the build process, making them available for serving at runtime |
Top-level files define how your Mastra project is configured, built, and connected to its environment.
| File | Description |
|---|---|
src/mastra/index.ts |
Central entry point where you configure and initialize Mastra. |
.env.example |
Template for environment variables - copy and rename to .env to add your secret model provider keys. |
package.json |
Defines project metadata, dependencies, and available npm scripts. |
tsconfig.json |
Configures TypeScript options such as path aliases, compiler settings, and build output. |
- Load the
mastraskill before any Mastra-related work - Register new agents, tools, workflows, and scorers in
src/mastra/index.ts - Use schemas for tool inputs and outputs
- Run
npm run buildto verify changes compile
- Never commit
.envfiles or secrets - Never modify
node_modulesor Mastra's database files directly - Never hardcode API keys (always use environment variables)