Skip to content

CLI: unify command surface in ccusage style (flags/ergonomics, not scope) #4

Description

@axisrow

Part of #2 (umbrella). Layer-1 CLI is merged (#1): src/cli/analyzeSession.ts and src/cli/sessionInventory.ts each carry their own ad-hoc flag grammar. This issue aligns the command surface with ccusage conventions so both tools feel like one CLI — without importing ccusage's scope.

Scope boundary (hard)

  • ccusage = macro usage aggregates (daily/weekly/monthly/blocks) across many agent sources, statusline.
  • claude-devtools = deep per-session audit of Claude Code sessions (ledger, waste findings, subagents, inventory).
  • Do not add: daily/monthly/blocks aggregates, multi-agent sources, statusline hooks, pricing-sync network logic. Complementary tools, zero feature mixing.

What to do

  1. Unified flag grammar across both commands, matching ccusage semantics:
    • --json — already present in both; keep as the single machine-readable mode
    • --breakdown — per-model token/cost breakdown (new)
    • --since / --until — date-range filtering (new; applies to analyze:sessions list and analyze:session turn filtering)
    • --last N — relative shortcut for --since (new)
    • --no-cost — hide cost columns / JSON cost fields (new)
    • existing flags stay: --project, --min-minutes, --sort, --limit, --subagent-min-minutes
  2. Shared arg parsing + help/exit-code/table conventions so both commands behave identically (small shared module under src/cli/, no new dependencies). Keep script names analyze:session / analyze:sessions stable — issue [FEAT] Layer 2: package the CLI as a Claude Code plugin (marketplace + plugin.json + skills) #3's skills reference them; a unified analyze entrypoint is optional only if it is near-zero extra code.
  3. README section for the CLI: usage, examples, and explicit positioning vs ccusage (one paragraph, the boundary above).
  4. Tests: extend test/main/cli/analyzeSession.test.ts, add coverage for inventory flags (test/main/cli/sessionInventory.test.ts).

Files

  • src/cli/analyzeSession.ts, src/cli/sessionInventory.ts
  • new src/cli/args.ts (or similar shared parser) only if it removes duplication
  • test/main/cli/analyzeSession.test.ts, test/main/cli/sessionInventory.test.ts
  • README.md

Acceptance criteria

  • Both commands support the unified flag set with ccusage-compatible semantics
  • pnpm analyze:session --help / pnpm analyze:sessions --help consistent (usage, exit codes, table rendering)
  • README documents both commands + ccusage positioning
  • pnpm typecheck && pnpm lint && pnpm test green; no app-build changes; existing pnpm analyze:* invocations keep working

Implementation

Use the ponytail skill (/ponytail): shortest working diff, no new dependencies, no speculative abstractions — shared parser only if it measurably removes duplication.

Оценка

  • LOC: ~250–450 (src ~120–250 / tests+README ~130–200)
  • Размер: M–L
  • Время (код): ~40–90 мин
  • Время (review): ~15–30 мин (чисто логический CLI-код, security-множителей нет)
  • Время (итого): ~55–120 мин

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions