---
title: "Reference: create-mastra | CLI"
description: Documentation for the create-mastra command, which creates a new Mastra project with interactive setup options.
packages:
  - "@mastra/create-mastra"
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

# 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

<Tabs>
<TabItem value="npm" label="npm">

```bash
npx create-mastra@beta
```

</TabItem>
<TabItem value="yarn" label="yarn">

```bash
yarn dlx create-mastra@beta
```

</TabItem>
<TabItem value="pnpm" label="pnpm">

```bash
pnpm create mastra@beta
```

</TabItem>
<TabItem value="bun" label="bun">

```bash
bun create mastra@beta
```

</TabItem>
</Tabs>

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

<Tabs>
<TabItem value="npm" label="npm">

```bash
npx create-mastra@beta my-mastra-project -- --template coding-agent
```

</TabItem>
<TabItem value="yarn" label="yarn">

```bash
yarn dlx create-mastra@beta --template coding-agent
```

</TabItem>
<TabItem value="pnpm" label="pnpm">

```bash
pnpm create mastra@beta --template coding-agent
```

</TabItem>
<TabItem value="bun" label="bun">

```bash
bun create mastra@beta --template coding-agent
```

</TabItem>
</Tabs>

Check out the [full list](https://mastra.ai/api/templates.json) 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):

```bash
npx create-mastra@beta my-mastra-project -- --template mastra-ai/template-coding-agent
```

## CLI flags

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

<PropertiesTable
  content={[
    {
      name: "--version",
      type: "boolean",
      description: "Output the version number",
      isOptional: true,
    },
    {
      name: "--project-name",
      type: "string",
      description:
        "Project name that will be used in package.json and as the project directory name",
      isOptional: true,
    },
    {
      name: "--default",
      type: "boolean",
      description: "Quick start with defaults (src, OpenAI, no examples)",
      isOptional: true,
    },
    {
      name: "--components",
      type: "string",
      description:
        "Comma-separated list of components (agents, tools, workflows, scorers)",
      isOptional: true,
    },
    {
      name: "--llm",
      type: "string",
      description:
        "Default model provider (openai, anthropic, groq, google, or cerebras)",
      isOptional: true,
    },
    {
      name: "--llm-api-key",
      type: "string",
      description: "API key for the model provider",
      isOptional: true,
    },
    {
      name: "--example",
      type: "boolean",
      description: "Include example code",
      isOptional: true,
    },
    {
      name: "--no-example",
      type: "boolean",
      description: "Do not include example code",
      isOptional: true,
    },
    {
      name: "--template",
      type: "string",
      description:
        "Create project from a template (use template name, public GitHub URL, or leave blank to select from list)",
      isOptional: true,
    },
    {
      name: "--timeout",
      type: "number",
      description:
        "Configurable timeout for package installation, defaults to 60000 ms",
      isOptional: true,
    },
    {
      name: "--dir",
      type: "string",
      description: "Target directory for Mastra source code (default: src/)",
      isOptional: true,
    },
    {
      name: "--mcp",
      type: "string",
      description:
        "MCP Server for code editor (cursor, cursor-global, windsurf, vscode)",
      isOptional: true,
    },
    {
      name: "--help",
      type: "boolean",
      description: "Display help for command",
      isOptional: true,
    },
  ]}
/>

## 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](https://github.com/mastra-ai/mastra/blob/main/packages/cli/src/analytics/index.ts) to check what's collected.

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

```bash
MASTRA_TELEMETRY_DISABLED=1
```

You can also set this while using other `mastra` commands:

```bash
MASTRA_TELEMETRY_DISABLED=1 npx create-mastra@beta
```
