Every Buttons command can emit structured JSON instead of human-readable text. This makes it straightforward to use Buttons inside scripts, pipelines, and agent loops.Documentation Index
Fetch the complete documentation index at: https://docs.buttons.sh/llms.txt
Use this file to discover all available pages before exploring further.
Enabling JSON output
Pass--json to any command:
--json explicitly in non-interactive contexts.
Output contract
Every response is a JSON object with anok boolean at the top level.
Success:
data varies by command, but ok, error.code, and error.message are always present and stable.
Error codes
| Code | When it occurs |
|---|---|
NOT_FOUND | The named button or drawer does not exist |
MISSING_ARG | A required argument was not supplied |
VALIDATION_ERROR | An argument value did not match its declared type |
TIMEOUT | The button execution exceeded its timeout |
SCRIPT_ERROR | The subprocess exited with a non-zero exit code |
RUNTIME_MISSING | The required interpreter (python3, node, etc.) is not on $PATH |
INTERNAL_ERROR | An unexpected error inside the Buttons runtime |
NOT_IMPLEMENTED | The command or feature is not yet available in this version |
Checking exit codes
Buttons exits with code0 on success and 1 on any error, regardless of --json. Use the exit code in shell scripts:
Writing JSON in Go
Inside the Buttons codebase, useconfig.WriteJSON() and config.WriteJSONError() — never fmt.Println with raw JSON strings. This ensures consistent formatting and respects the --json / non-TTY detection logic.
Related
- Arguments —
MISSING_ARGandVALIDATION_ERRORdetails - Quick start — see JSON output in a real example