Skip to main content

Exit Codes

CLEO uses structured exit codes for programmatic error handling. This reference documents all exit codes and their meanings.

Quick Reference

CodeMeaning
0Success

Error Categories

User Errors (2-6)

Cause: Invalid command usage or argumentsExample:
cleo add   # Missing required title
# Exit: 2
Fix: Check command syntax with cleo <command> --help
Cause: Requested task or resource doesn’t existExample:
cleo show T999   # Task doesn't exist
# Exit: 4
Fix: Verify task exists with cleo exists T999 or cleo list
Cause: Business validation failedCommon causes:
  • Field too long
  • Invalid status transition
  • Shell variable not escaped in notes
Fix: Check error.fix in JSON response for specific guidance

Hierarchy Errors (10-12)

Cause: Specified parent task doesn’t existExample:
cleo add "Subtask" --parent T999
# Exit: 10
Fix: Verify parent exists with cleo exists T999
Cause: Hierarchy exceeds maximum depth (3 levels)Example:
# T001 (epic) → T002 (task) → T003 (subtask) → T004 (too deep!)
cleo add "Too deep" --parent T003
# Exit: 11
Fix: Restructure hierarchy or use a different parent
Cause: Too many children under same parentFix: Move task to different parent or increase hierarchy.maxSiblings

Operation Errors (16-17)

Cause: Trying to delete task with childrenExample:
cleo delete T001 --reason "cleanup"
# Exit: 16 (T001 has children)
Fix: Use --children cascade or --children orphan
Cause: Task already completed, cannot deleteFix: Use cleo archive instead or cleo reopen first

Recoverable Errors (7, 20-22)

These errors may succeed on retry:
CodeErrorRetry Strategy
7E_CONCURRENTExponential backoff (100ms, 200ms, 400ms)
20E_NETWORKNetwork retry with backoff
21E_TIMEOUTIncrease timeout, retry
22E_LOCKEDWait for lock release, retry

Special Codes (100+)

Codes 100+ are not errors - they indicate special conditions.
CodeMeaningExample
100No datacleo list --status done returns empty
101Already existscleo add "Title" when duplicate
102No changecleo update T001 --priority high when already high

JSON Error Response

When an error occurs, JSON output includes:
{
  "success": false,
  "error": {
    "code": "E_PARENT_NOT_FOUND",
    "exit": 10,
    "message": "Parent task T999 not found",
    "fix": "cleo exists T999 --verbose",
    "alternatives": [
      {"action": "List available parents", "command": "cleo list --type epic"},
      {"action": "Create parent first", "command": "cleo add \"Parent\" --type epic"}
    ],
    "context": {
      "requestedParent": "T999"
    }
  }
}

Response Fields

FieldDescription
error.codeMachine-readable error code
error.exitExit code number
error.messageHuman-readable message
error.fixCopy-paste command to resolve
error.alternativesArray of alternative actions
error.contextAdditional error context

Scripting Patterns

cleo add "Task title"
if [ $? -ne 0 ]; then
  echo "Failed to create task"
  exit 1
fi

Next Steps