create-mastra
Create a standalone Mastra project. By default, create-mastra installs a default starter and configures it for your selected model provider.
- npm
- pnpm
- Yarn
- Bun
npx create-mastra@latest
pnpm dlx create-mastra@latest
yarn dlx create-mastra@latest
bun x create-mastra@latest
Creation modesDirect link to Creation modes
Default starterDirect link to Default starter
The default starter creates an agent harness with workspace tools, memory, task tracking, web access, recurring schedules, storage, and observability. Select OpenAI, Anthropic, Gemini, or xAI as your model provider.
Provide both the project name and provider to create the project without prompts. This example uses Anthropic; you can also pass openai, google, or xai:
- npm
- pnpm
- Yarn
- Bun
npx create-mastra@latest my-mastra-project --llm anthropic
pnpm dlx create-mastra@latest my-mastra-project --llm anthropic
yarn dlx create-mastra@latest my-mastra-project --llm anthropic
bun x create-mastra@latest my-mastra-project --llm anthropic
Omit --llm to select the provider and optionally enter its API key interactively. The interactive setup also offers to connect your project to the Mastra platform. If enabled, the command opens the browser authentication flow and creates a platform project with the same name as the local project. It then writes MASTRA_PLATFORM_ACCESS_TOKEN and MASTRA_PROJECT_ID to .env.
TemplateDirect link to Template
Use a template slug or a public GitHub URL:
- npm
- pnpm
- Yarn
- Bun
npx create-mastra@latest my-mastra-project --template agent-harness
pnpm dlx create-mastra@latest my-mastra-project --template agent-harness
yarn dlx create-mastra@latest my-mastra-project --template agent-harness
bun x create-mastra@latest my-mastra-project --template agent-harness
- npm
- pnpm
- Yarn
- Bun
npx create-mastra@latest my-mastra-project --template https://github.com/mastra-ai/template-agent-harness
pnpm dlx create-mastra@latest my-mastra-project --template https://github.com/mastra-ai/template-agent-harness
yarn dlx create-mastra@latest my-mastra-project --template https://github.com/mastra-ai/template-agent-harness
bun x create-mastra@latest my-mastra-project --template https://github.com/mastra-ai/template-agent-harness
Leave the template value blank to select a template interactively:
- npm
- pnpm
- Yarn
- Bun
npx create-mastra@latest my-mastra-project --template
pnpm dlx create-mastra@latest my-mastra-project --template
yarn dlx create-mastra@latest my-mastra-project --template
bun x create-mastra@latest my-mastra-project --template
Template authors own their dependencies, models, environment variables, and source code. create-mastra doesn't apply --llm or --llm-api-key.
Empty scaffoldDirect link to Empty scaffold
Use --empty to create a provider-free project without agents, examples, model SDKs, or environment files:
- npm
- pnpm
- Yarn
- Bun
npx create-mastra@latest my-empty-project --empty
pnpm dlx create-mastra@latest my-empty-project --empty
yarn dlx create-mastra@latest my-empty-project --empty
bun x create-mastra@latest my-empty-project --empty
Automatic setupDirect link to Automatic setup
After installing dependencies, the command:
- Detects supported coding assistants on
PATHand installs Mastra skills. If none are detected, it installs universal skills. - Creates an initial Git commit when the current directory and generated project aren't already inside Git repositories.
Use --no-skills or --no-git to skip these steps. Skills and Git setup failures produce warnings but don't remove a successfully created project.
Conflicts and validationDirect link to Conflicts and validation
--emptyand--templatecan't be used together.--llmand--llm-api-keyare only valid for the default starter project.- The project name must be a safe, lowercase, single directory name and the target must not already exist.
Invalid input is rejected before templates are fetched or files are created.
Arguments and flagsDirect link to Arguments and flags
[project-name]?:
--empty?:
-l, --llm <provider>?:
-k, --llm-api-key <key>?:
--no-skills?:
--no-git?:
-t, --template [template]?:
--timeout <milliseconds>?:
--version?:
--help?:
TelemetryDirect link to Telemetry
Mastra collects anonymous CLI usage information, such as the operating system, Mastra version, and Node.js version. You can review the analytics source.
Set MASTRA_TELEMETRY_DISABLED=1 to opt out:
MASTRA_TELEMETRY_DISABLED=1 npx create-mastra@latest my-project --empty