Skip to main content

create-mastra

The create-mastra command creates a new standalone Mastra project. Use this command to scaffold a complete Mastra setup in a dedicated directory. You can run it with additional flags to customize the setup process.

Usage

npx create-mastra@latest

create-mastra automatically runs in interactive mode, but you can also specify your project name and template with command line arguments.

npx create-mastra@latest my-mastra-project -- --template coding-agent

Check out the full list of templates and use the slug as input to the --template CLI flag.

You can also use any GitHub repo as a template (it has to be a valid Mastra project):

npx create-mastra@latest my-mastra-project -- --template mastra-ai/template-coding-agent

CLI flags

Instead of an interactive prompt you can also define these CLI flags.

--version?:

boolean
Output the version number

--project-name?:

string
Project name that will be used in package.json and as the project directory name

--default?:

boolean
Quick start with defaults (src, OpenAI, no examples)

--components?:

string
Comma-separated list of components (agents, tools, workflows)

--llm?:

string
Default model provider (openai, anthropic, groq, google, or cerebras)

--llm-api-key?:

string
API key for the model provider

--example?:

boolean
Include example code

--no-example?:

boolean
Do not include example code

--template?:

string
Create project from a template (use template name, public GitHub URL, or leave blank to select from list)

--timeout?:

number
Configurable timeout for package installation, defaults to 60000 ms

--dir?:

string
Target directory for Mastra source code (default: src/)

--mcp?:

string
MCP Server for code editor (cursor, cursor-global, windsurf, vscode)

--help?:

boolean
Display help for command