eyaltoledano/claude-task-master · error
Failed to load prompt template: ${error.message}
Error message
Failed to load prompt template: ${error.message} What it means
updateTaskById() loads prompt templates (via promptManager/getPrompt) to build the systemPrompt and userPrompt sent to the AI. If template loading throws, the error is logged and rethrown wrapped as 'Failed to load prompt template: <original message>', preserving the underlying cause.
Source
Thrown at scripts/modules/task-manager/update-task-by-id.js:342
promptParams,
variantKey
);
report(
'info',
`Prompt result type: ${typeof promptResult}, keys: ${promptResult ? Object.keys(promptResult).join(', ') : 'null'}`
);
// Extract prompts - loadPrompt returns { systemPrompt, userPrompt, metadata }
systemPrompt = promptResult.systemPrompt;
userPrompt = promptResult.userPrompt;
report(
'info',
`Loaded prompts - systemPrompt length: ${systemPrompt?.length}, userPrompt length: ${userPrompt?.length}`
);
} catch (error) {
report('error', `Failed to load prompt template: ${error.message}`);
throw new Error(`Failed to load prompt template: ${error.message}`);
}
// If prompts are still not set, throw an error
if (!systemPrompt || !userPrompt) {
throw new Error(
`Failed to load prompts: systemPrompt=${!!systemPrompt}, userPrompt=${!!userPrompt}`
);
}
// --- End Build Prompts ---
let loadingIndicator = null;
let aiServiceResponse = null;
if (!isMCP && outputFormat === 'text') {
loadingIndicator = startLoadingIndicator(
useResearch ? 'Updating task with research...\n' : 'Updating task...\n'
);
}View on GitHub (pinned to c0c98d367c)
Solutions
- Read the wrapped inner message to identify the root cause (file not found vs parse error)
- Reinstall task-master (npm ci / reinstall globally) to restore intact prompt template assets
- If templates were customized, fix the template syntax or restore the originals
- Verify file permissions on the prompts directory and that the configured template path is correct
- Check for a version mismatch and align customized templates with the installed version
Example fix
// before // prompts/update-task.txt deleted or malformed -> throws // after npm ci # or: npm install -g task-master-ai@latest # restores template assets // then retry: await updateTaskById(5, prompt);
Defensive patterns
Strategy: try-catch
Validate before calling
import fs from 'fs';
function assertTemplateAssets(promptsDir) {
if (!fs.existsSync(promptsDir) || fs.readdirSync(promptsDir).length === 0) {
throw new Error(`Prompt templates missing at ${promptsDir}; reinstall task-master`);
}
} Type guard
function templatesAvailable(promptsDir) {
return fs.existsSync(promptsDir) && fs.readdirSync(promptsDir).length > 0;
} Try / catch
try {
await updateTaskById(5, prompt);
} catch (err) {
if (err.message.startsWith('Failed to load prompt template')) {
console.error('Root cause:', err.message); // wrapped inner message
console.error('Reinstall task-master or restore/fix the custom template file');
} else throw err;
} Prevention
- Keep prompt template assets intact — avoid partial installs and manual deletion inside the package
- If customizing templates, validate their syntax after every edit
- Pin and align versions when templates are overridden or vendored
- Check file read permissions on the prompts directory in CI/containers
- Log the inner error message (it is preserved after the prefix) to diagnose the real cause
When it happens
Trigger: Missing or renamed prompt template files in the prompts/assets directory (broken install or partial copy); a customized template file with invalid syntax that the template engine cannot parse; permission errors reading the template path; version mismatch where code expects a template key the installed assets do not define.
Common situations: Partial npm installs or corrupted node_modules / global installs; users overriding prompt directories with bad paths; upgrading Task Master without updating customized prompt files; running from a packaged binary missing asset files.
Related errors
- Prompt template '${promptId}' not found
- Schema validation failed: ${errors}
- Invalid template structure: missing required fields (id, pro
- Could not determine project root directory
- Tasks file not found: ${tasksPath}
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/95912cdf763e1cb3.
Report an issue: GitHub.