Creating a new project
You can create a new project using the create-mastra
package:
npm create mastra@latest
You can also create a new project by using the mastra
CLI directly:
npm install -g mastra@latest
mastra create
Interactive Setup
Running commands without arguments starts a CLI prompt for:
- Project name
- Component selection
- LLM provider configuration
- API key setup
- Example code inclusion
Non-Interactive Setup
To initialize mastra in non-interactive mode use the following command arguments:
Arguments:
--components Specify components: agents, tools, workflows
--llm-provider LLM provider: openai, anthropic, groq, google, or cerebras
--add-example Include example implementation
--llm-api-key Provider API key
--project-name Project name that will be used in package.json and as the project directory name
Generated project structure:
my-project/
├── src/
│ └── mastra/
│ └── index.ts # Mastra entry point
├── package.json
└── tsconfig.json