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

  1. Read the wrapped inner message to identify the root cause (file not found vs parse error)
  2. Reinstall task-master (npm ci / reinstall globally) to restore intact prompt template assets
  3. If templates were customized, fix the template syntax or restore the originals
  4. Verify file permissions on the prompts directory and that the configured template path is correct
  5. 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

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


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/95912cdf763e1cb3. Report an issue: GitHub.