{"record":{"id":"e4c659385a32a1e4","repo":"mastra-ai/mastra","slug":"the-empty-and-template-options-can-t-be-used-t","errorCode":null,"errorMessage":"The --empty and --template options can't be used together","messagePattern":"The --empty and --template options can't be used together","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/create/command.ts","lineNumber":107,"sourceCode":"    llmProvider: options.llm,\n    llmApiKey: options.llmApiKey,\n    skills: options.skills,\n    git: options.git,\n    template: options.template,\n    timeout: options.timeout,\n    install: options.install,\n  };\n}\n\nexport function getCreateMode(options: Pick<NormalizedCreateOptions, 'empty' | 'template'>): CreateMode {\n  if (options.empty) return 'empty';\n  if (options.template !== undefined) return 'template';\n  return 'managed';\n}\n\nexport function validateCreateOptionConflicts(options: NormalizedCreateOptions): CreateMode {\n  if (options.empty && options.template !== undefined) {\n    throw new Error(`The --empty and --template options can't be used together`);\n  }\n\n  const mode = getCreateMode(options);\n  if (mode !== 'managed' && options.llmProvider !== undefined) {\n    throw new Error('The --llm option can only be used with the default template');\n  }\n  if (mode !== 'managed' && options.llmApiKey !== undefined) {\n    throw new Error('The --llm-api-key option can only be used with the default template');\n  }\n\n  return mode;\n}\n\nconst WINDOWS_RESERVED_BASENAME = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\\..*)?$/i;\nconst PROJECT_NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;\n\nexport function validateProjectName(value: string): string {\n  const projectName = value.trim();","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/create/command.ts#L89-L125","documentation":"`validateCreateOptionConflicts` in packages/cli/src/commands/create/command.ts:107 rejects mutually exclusive `mastra create` flags. `--empty` scaffolds a bare project while `--template` scaffolds from a template; the CLI cannot do both, so it throws before any file system work. This is a fast-fail input validation guard so users get an immediate, actionable message.","triggerScenarios":"Running e.g. `mastra create my-app --empty --template <slug>` or passing both `{ empty: true, template: 'x' }` to the programmatic `create()` API (both are normalized into NormalizedCreateOptions and checked together).","commonSituations":"Scripting the CLI and appending both flags from separate config values; combining a saved alias like `mastra create --empty -t my-template`; migrating shell scripts where a template flag was added to an existing empty-project command.","solutions":["Remove either the `--empty` flag or the `--template` flag — pick one mode","If you want a template, drop `--empty`: `mastra create my-app --template <slug>`","If you want an empty scaffold, drop `--template`: `mastra create my-app --empty`"],"exampleFix":"// before\nmastra create my-app --empty --template template-agent-harness\n// after\nmastra create my-app --template template-agent-harness","handlingStrategy":"validation","validationCode":"const empty = process.argv.includes('--empty');\nconst hasTemplate = process.argv.includes('-t') || process.argv.includes('--template');\nif (empty && hasTemplate) {\n  throw new Error('Remove either --empty or --template before running mastra create');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide the create mode (managed|template|empty) once in your scripts and only emit the flags for that mode","Lint shell scripts/aliases for accidental flag combinations","Remember --llm/--llm-api-key also only pair with the default flow"],"tags":["cli","input-validation","flag-conflict"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}