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, scorers)

--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

Telemetry

By default, Mastra collects anonymous information about your project like your OS, Mastra version or Node.js version. You can read the source code to check what's collected.

You can opt out of the CLI analytics by setting an environment variable:

MASTRA_TELEMETRY_DISABLED=1

You can also set this while using other mastra commands:

MASTRA_TELEMETRY_DISABLED=1 npx create-mastra@latest

On this page