create-mastra
create-mastra 命令创建一个新的独立 Mastra 项目。使用此命令可以在专用目录中搭建完整的 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.
用法Direct link to 用法
🌐 Usage
- npm
- pnpm
- Yarn
- Bun
npx create-mastra@latest
pnpm dlx create-mastra@latest
yarn dlx create-mastra@latest
bun x create-mastra@latest
create-mastra 会自动以 交互式 模式运行,但你也可以通过命令行参数指定你的项目名称和模板。
- npm
- pnpm
- Yarn
- Bun
npx create-mastra@latest my-mastra-project -- --template coding-agent
pnpm dlx create-mastra@latest my-mastra-project -- --template coding-agent
yarn dlx create-mastra@latest my-mastra-project -- --template coding-agent
bun x create-mastra@latest my-mastra-project -- --template coding-agent
查看完整列表的模板,并使用 slug 作为 --template CLI 标志的输入。
🌐 Check out the full list of templates and use the slug as input to the --template CLI flag.
你也可以使用任何 GitHub 仓库作为模板(它必须是一个有效的 Mastra 项目):
🌐 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
命令行标志Direct link to 命令行标志
🌐 CLI flags
你也可以定义这些命令行参数而不是使用交互式提示。
🌐 Instead of an interactive prompt you can also define these CLI flags.
--version?:
--project-name?:
--default?:
--components?:
--llm?:
--llm-api-key?:
--example?:
--no-example?:
--template?:
--timeout?:
--dir?:
--mcp?:
--help?:
遥测Direct link to 遥测
🌐 Telemetry
默认情况下,Mastra 会收集有关你的项目的匿名信息,如你的操作系统、Mastra 版本或 Node.js 版本。你可以查看 源代码 来了解收集了哪些信息。
🌐 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.
你可以通过设置环境变量来选择退出 CLI 分析:
🌐 You can opt out of the CLI analytics by setting an environment variable:
MASTRA_TELEMETRY_DISABLED=1
你也可以在使用其他 mastra 命令时设置这个:
🌐 You can also set this while using other mastra commands:
MASTRA_TELEMETRY_DISABLED=1 npx create-mastra@latest