Skip to main content
Every CostHQ command accepts a --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:
Always check 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

Capture 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:
When no 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:
Use 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 --json calls process.exit(0) immediately after printing — safe to call with execSync.
  • Use --close-stale or --resume alongside cs start --json to avoid session_active errors in unattended scripts.
  • On Windows, use where cs instead of which cs for install detection. All commands work identically on Windows, macOS, and Linux.