eyaltoledano/claude-task-master · error
Command failed with exit code ${result.status}: ${errorOutpu
Error message
Command failed with exit code ${result.status}: ${errorOutput} What it means
When the spawned task-master CLI process launches but exits with a non-zero status, executeTaskMasterCommand throws this error containing the exit code and the process's stderr (or stdout fallback, or 'Unknown error'). It signals the underlying command ran and failed, unlike the spawn-level failure error.
Source
Thrown at mcp-server/src/tools/utils.js:389
// If global CLI is not available, try fallback to the local script
if (result.error && result.error.code === 'ENOENT') {
log.info('Global task-master not found, falling back to local script');
// Pass the same spawnOptions (including env) to the fallback
result = spawnSync('node', ['scripts/dev.js', ...fullArgs], spawnOptions);
}
if (result.error) {
throw new Error(`Command execution error: ${result.error.message}`);
}
if (result.status !== 0) {
// Improve error handling by combining stderr and stdout if stderr is empty
const errorOutput = result.stderr
? result.stderr.trim()
: result.stdout
? result.stdout.trim()
: 'Unknown error';
throw new Error(
`Command failed with exit code ${result.status}: ${errorOutput}`
);
}
return {
success: true,
stdout: result.stdout,
stderr: result.stderr
};
} catch (error) {
log.error(`Error executing task-master command: ${error.message}`);
return {
success: false,
error: error.message
};
}
}
View on GitHub (pinned to c0c98d367c)
Solutions
- Read the errorOutput portion of the message — it contains the CLI's actual stderr/stdout diagnosis.
- Run the same command manually in a terminal to reproduce and see full output.
- Verify project setup (.taskmaster directory, PRD, config) and API keys the CLI needs.
- Check argument forwarding: confirm fullArgs matches what the CLI expects.
Example fix
// before await executeTaskMasterCommand(['list', '--bad-flag']); // exit code 1: unknown option // after await executeTaskMasterCommand(['list']); // valid args
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate args before invoking: const known = new Set(['list','parse-prd','next',...]); if (!known.has(args[0])) throw new Error('Unknown task-master subcommand'); Type guard
null
Try / catch
try { const r = await executeTaskMasterCommand(args); } catch (e) { const m = e.message.match(/^Command failed with exit code (\d+): ([\s\S]*)$/); if (m) { logger.error('CLI failed', { exitCode: +m[1], output: m[2] }); return { success: false, stderr: m[2] }; } throw e; } Prevention
- Reproduce failing commands manually to read full stderr
- Verify project setup (.taskmaster dir, PRD, API keys) before invoking
- Validate tool arguments against the CLI's accepted flags
- Keep CLI and server versions in sync
When it happens
Trigger: Any task-master subcommand failing at runtime: invalid arguments, unreadable .taskmaster directory, API/key errors inside the CLI, unhandled CLI exceptions.
Common situations: Missing PRD/tasks files in the project; invalid model or API key configured for the CLI; passing unsupported tool arguments through the MCP tool; Node version incompatibilities with the CLI.
Related errors
- Command execution error: ${result.error.message}
- MFA_VERIFICATION_FAILED
- MFA_VERIFICATION_FAILED
- NO_TOKEN
- MFA_REQUIRED
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/7421e9d62c64e0cb.
Report an issue: GitHub.