--json flag that produces machine-readable output on stdout. Use this flag in agent workflows, CI pipelines, and any automation that needs to parse command results programmatically rather than scrape human-readable text.
Schema Versioning
Every--json response includes top-level metadata fields regardless of the command:
schemaVersion before parsing the rest of the object. If the value is higher than your integration expects, emit a warning and degrade gracefully — never silently break.
cs start --json
id immediately — you can pass it to subsequent commands via -s <id> to target this session explicitly when running multiple sessions concurrently.
cs status --json
Returns the following shape when a session is active:
cs status --json exits with code 1 and returns:
cs end --json
cs show --json
cs show --json returns the full session detail including files, commits, AI usage records, and annotations:
cs log-ai --json
In addition to the logged values, the response includes a pricing object so you can verify which pricing source was used:
pricing.source is one of "built-in", "custom", or "manual". If pricing.modelKnown is false, the model is not in the built-in pricing table and you should provide an explicit cost via -c.
cs dashboard --json
Returns the startup metadata for the dashboard process:
pid if you need to manage the dashboard process lifecycle from a parent script.
Non-Interactive Guarantees
When you pass--json, CostHQ makes the following guarantees for safe use in automation:
- All commands are fully non-interactive — no prompts, no TTY input required.
cs start --jsoncallsprocess.exit(0)immediately after printing — safe to call withexecSync.- Use
--close-staleor--resumealongsidecs start --jsonto avoidsession_activeerrors in unattended scripts. - On Windows, use
where csinstead ofwhich csfor install detection. All commands work identically on Windows, macOS, and Linux.