Skip to content

refactor(cli): make each feature's api.ts its whole REST client - #153

Merged
filipmyllari merged 2 commits into
mainfrom
cli-skill-request-builders
Dec 3, 2026
Merged

filipmyllari merged 2 commits into
mainfrom
cli-skill-request-builders

Conversation

@filipmyllari

@filipmyllari filipmyllari commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to the review of #148 (CGT-86): each feature's api.ts is now its whole REST client, so request building stays out of the command handlers. The cli skill documents the rule so agents keep following it.

  • features/<x>/api.ts holds the feature's resource types, request and body shapes, response projections, and one function per request returning a RestOperation:
    • events: update, delete and usage.
    • data: the table resource types, table creates (with the skipSqlPreview: true guard, which was copied in two handlers), the SQL preview job and wait, and the SQL status and schema reads.
    • warehouse: every resource type, the create commands, list and get (so no handler can forget to filter out secrets), and validate.
    • recordings: targeting-key show and add, including the field-type table and the entities/<field> default.
  • Handlers: they only read and validate input, plus an optional render. They may still call the shared listOperation and getOperation directly.
  • Cleanup:
    • Dropped getFlagOperation, which only passed through, and the one-off SQL_JOBS type.
    • Removed comments that only restated the code.
    • Fixed three tests that couldn't fail: events delete --force, data … --dry-run without login, and the token warehouse setup passes on.
  • Skill: the REST section of .claude/skills/cli/SKILL.md states the rule and lists the commands still outside it. flags list|get|update|archive use the older client (CGT-88), and the recordings policy and rule commands still use the MCP (CGT-87).

Behaviour: unchanged, apart from one message. When data sql preview --wait fails, it now ends with Check "confidence data sql status --name …" instead of Inspect it with "…".

Tested: CLI lint, format and typecheck, and all 359 CLI tests.

🤖 Generated with Claude Code

filipmyllari and others added 2 commits December 3, 2026 15:25
Command handlers now only read and validate argv. The events update, delete
and usage requests, the SQL preview job, warehouse config validation and the
recordings targeting-key requests move from their handlers into
features/<x>/api.ts, matching flags. The cli skill documents the rule so new
commands follow it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resource types, body shapes and response projections move into api.ts for
data, warehouse and recordings: the warehouse create commands, list and get
(so no handler can forget the secret filter), the data table creates with the
skipSqlPreview guard, the SQL status and schema reads, and the recordings
field-type table and entity default. Drops the getFlagOperation pass-through
and the one-off SQL_JOBS type, removes comments that restate the code, makes
three tests able to fail, and corrects the cli skill text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@filipmyllari filipmyllari changed the title refactor(cli): build every custom REST request in the feature's api.ts refactor(cli): make each feature's api.ts its whole REST client Dec 3, 2026
@filipmyllari
filipmyllari marked this pull request as ready for review December 3, 2026 14:52

@bespoyasov bespoyasov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you! 🙌

@filipmyllari
filipmyllari merged commit 89feb5b into main Dec 3, 2026
7 checks passed
@filipmyllari
filipmyllari deleted the cli-skill-request-builders branch December 3, 2026 15:29
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.

2 participants