Skip to content

Token-efficient output format #9

Description

@apgiorgi

Part of the Agentic UX spec series. See sibling issues for related buckets.

Motivation

When the CLI is driven by an LLM agent (Claude Code, Cursor, Kiro, etc.), every byte of output is a token the agent pays for and a token that competes with the rest of its context window. Internal reports show engineer API spend jumping from ~$125/mo subscription to ~$1000/mo on raw API once agentic workflows take over (ai-token-economics channel, 2026-05-27). Our default JSON shapes were designed for humans + scripts, not for agents.

Spec

Make the default agent-facing output as compact as possible without losing fidelity.

Output format

  • Support --output toon (TOON — Token-Oriented Object Notation) alongside today's json/yaml/table. TOON reports ~40% token savings vs JSON for list-shaped data.
  • Keep table as the human default; promote a compact format (TOON or minified JSON) as the agent-mode default (see sibling Agent-mode detection and behavior split #10).

Schema

  • Minimal default schemas: list operations return ≤4 fields per item (e.g. id, name, severity, updated). Full record only on get or with --full.
  • Terse, stable field names: e.g. cost not totalAggregatedCostUsd. Stability is part of the contract — renames are breaking changes.
  • Projection: --fields a,b,c to pick exact fields, and --exclude for the inverse.
  • Content truncation with size hints: long text fields (descriptions, queries, error messages) truncate to N chars with a marker like {"value": "...", "_truncated": 4821}. Escape hatch: --full or --no-truncate.

Defaults

  • Lower default --limit in agent mode (e.g. 25 vs the current default).
  • Document each list endpoint's default + max.

References

Open questions

  • Do we commit to TOON specifically, or keep json minified as the agent default?
  • Are existing JSON field names already a contract (any external consumers parsing them)?
  • Where do we draw the truncation length — global default vs per-field?

Acceptance criteria

  • --output accepts a compact format and emits documented stable shapes
  • List operations default to ≤4 fields; --full returns the wide record
  • --fields and --exclude work on every list/get operation
  • Long text fields truncate with a documented marker; --full disables truncation
  • Each operation documents its default and max --limit
  • Field-name contract documented in README/DISTRIBUTION.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions