Skip to content

Token-efficient CLI output for tb-prod#5

Open
trogulja wants to merge 1 commit intomainfrom
feature/make-cli-better-again
Open

Token-efficient CLI output for tb-prod#5
trogulja wants to merge 1 commit intomainfrom
feature/make-cli-better-again

Conversation

@trogulja
Copy link
Copy Markdown
Collaborator

Summary

  • CSV default output for query/search — 36x smaller than JSON, with schema-driven columns (displayColumns) and auto-resolved relationship names
  • Auto-apply default filtersdefaultFilters in schema.json scopes queries automatically (e.g. tasks → open tasks in active projects). Eliminates the describe call.
  • Compact output for create/update/delete — one-line confirmation with ID instead of full JSON
  • Bug fix: operator syntax in flat filters ({"field": {"eq": "value"}}) now works correctly
  • Updated prime output — CSV/auto-filter notes, common queries with person_id baked in

Benchmark results (my_tasks)

Metric Before After
CLI tokens 1,323K (3x worse than MCP) 161K (2.5x better than MCP)
Tool calls 18 2
Wall time 88s 24s

⚠️ Note

defaultFilters and displayColumns are hand-edited in schema.json. They need to be added to generate-schema.ts in ai-agent before the next schema regeneration.

Test plan

  • All 104 existing tests pass
  • Smoke tested: query tasks/projects CSV, search CSV, delete compact
  • Benchmark validates CLI ≤ 1.5x MCP tokens (achieved 2.5x better)
  • Integration test with real skill usage (manual)
  • Verify --format json passthrough has no regressions

🤖 Generated with Claude Code

After moving tb-prod to the generic resource layer, CLI token usage
regressed from 4x better than MCP to 3x worse. This restores the
advantage with three key changes:

1. CSV default output for query/search — 36x smaller than JSON, with
   schema-driven column selection (displayColumns) and auto-resolved
   relationship names via sideloaded includes + org cache.

2. Auto-apply default filters — resources with defaultFilters in
   schema.json (tasks, projects, people, etc.) get sensible defaults
   merged with user filters. Eliminates the need to call `describe`
   before querying.

3. Compact output for create/update/delete — one-line confirmation
   with ID instead of full JSON response.

Also fixes:
- Operator syntax in flat filters: {"field": {"eq": "value"}} now
  correctly extracts the operator instead of stringifying the object.
- Prime output updated with CSV/auto-filter notes and common queries
  section with baked-in person_id.
- SKILL.md updated to reflect new defaults.
- Benchmark script updated for current MCP tool names and /tmp CWD.

Benchmark results (my_tasks):
  Before: CLI 1,323K tokens, 18 calls, 88s (3x worse than MCP)
  After:  CLI 161K tokens, 2 calls, 24s (2.5x better than MCP)

Note: defaultFilters and displayColumns are hand-edited in schema.json.
They need to be added to generate-schema.ts in ai-agent before the
next schema regeneration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant