Skip to content

AXI P6: Use exit code 2 for usage errors, 1 for runtime errors #14

@LarsEckart

Description

@LarsEckart

Problem

All errors currently exit with code 1, including usage errors like missing required flags. This makes it harder for agents to distinguish between "I called the command wrong" and "something failed at runtime".

$ hccli datasets  # missing --api-key
# exit: 1

$ hccli datasets --api-key bad-key  # API auth failure  
# exit: 1

Fix

Follow the standard convention:

  • Exit 0: success (including no-ops)
  • Exit 1: runtime error (API failure, resource not found, network error)
  • Exit 2: usage error (missing required flag, unknown subcommand, bad argument)

urfave/cli v3 supports cli.Exit(msg, code) for setting exit codes explicitly.

Reference

AXI Principle 6 — Structured errors & exit codes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions