mastra-ai/mastra · error · Error
Template "${template}" not found
Error message
Template "${template}" not found What it means
Thrown when the template name passed to `mastra create <template>` matches none of the templates returned by loadTemplates(). Before throwing, the CLI logs all available templates with their slugs so the caller can pick a valid one.
Source
Thrown at packages/cli/src/commands/create/create.ts:760
p.log.error('This does not appear to be a valid Mastra project:');
validation.errors.forEach(error => p.log.error(` - ${error}`));
throw new Error('Invalid Mastra project');
}
spinner.stop('Valid Mastra project ✓');
return createFromGitHubUrl(githubUrl);
}
if (looksLikeGitHubUrl(template)) {
throw new Error('Invalid GitHub repository URL. Use https://github.com/<owner>/<repository>.');
}
const templates = await loadTemplates();
const found = findTemplateByName(templates, template);
if (!found) {
p.log.error(`Template "${template}" not found. Available templates:`);
templates.forEach(availableTemplate =>
p.log.info(` - ${availableTemplate.title} (use: ${availableTemplate.slug.replace('template-', '')})`),
);
throw new Error(`Template "${template}" not found`);
}
return found;
}
View on GitHub (pinned to 75dd419e61)
Solutions
- Run the command again and read the 'Available templates' list printed with the error; copy the exact 'use:' value.
- Drop the 'template-' prefix — the CLI expects the short slug (e.g. 'hello-world', not 'template-hello-world').
- Check the template still exists in the current CLI version; update or downgrade the CLI if the template changed names.
- If no template fits, scaffold with a GitHub starter URL via `mastra create --github <url>` instead.
Example fix
// before mastra create template-hello-world // after mastra create hello-world
Defensive patterns
Strategy: fallback
Validate before calling
const templates = await loadTemplates();
const shortName = template.replace(/^template-/, '');
if (!findTemplateByName(templates, shortName)) {
console.log('Available:', templates.map(t => t.slug.replace('template-', '')).join(', '));
} Try / catch
try {
await resolveTemplate(name);
} catch (e) {
if (/not found/.test((e as Error).message) && /Template/.test((e as Error).message)) {
const templates = await loadTemplates();
console.error(`Unknown template "${name}". Try: ${templates.map(t => t.slug.replace('template-', '')).join(', ')}`);
}
} Prevention
- Use the short slug shown after 'use:' in the available-templates list, without the 'template-' prefix.
- Run `mastra create` with an empty/invalid name once to print all valid templates.
- Pin the CLI version in CI so template names don't drift with upgrades.
When it happens
Trigger: `mastra create my-template` where findTemplateByName() finds no title/slug match in the loaded template registry.
Common situations: Typo in the template name, using the full slug ('template-hello-world') instead of the shortened name ('hello-world'), or referencing a template that was removed/renamed in a newer CLI version.
Related errors
- Invalid GitHub URL format
- No template selected
- Database not found: ${dbArg}. List databases with: mastra en
- Environment not found: ${envArg}. List environments with: ma
- Unsupported database kind: ${kind}. Supported kinds: turso,
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/1959db8999e91c8b.
Report an issue: GitHub.