add-resource-command
add-resource-command
Authoritative contract for adding a resource end-to-end. The work spans five layers — domain schema, resource methods, presentation view, commands, tests — plus a mandatory close-out (/review then /simplify) before the task is done. The order matters: earlier layers feed types into later ones, and deviating from house style at any step produces drift the type-checker can't catch.
A resource straddles both workspace packages. The schema and the endpoint knowledge are client surface and land in packages/client/src/domain/ and packages/client/src/resources/; the presentation binding and the commands that consume them are CLI surface and land in packages/cli/. Adding a domain file alone is not the unit of work — a schema without a method is unreachable, a resource without a command isn't useful, and a command without an e2e test isn't trustworthy.
The one-line shape of the whole thing: a command resolves its flags, calls client.<resource>.<method>(…), and renders the result. Every /api/ path, every query-parameter name, and every call to the HTTP transport lives in packages/client/src/resources/<r>.ts.
Step 0 — Pre-flight (mandatory)
Anchor to the existing house style. Skip this and you will produce drift the type-checker won't catch.
ls packages/client/src/domain/and read one existing resource schema file end-to-end (e.g.packages/client/src/domain/segment.ts).- Read the matching
packages/client/src/resources/segment.tsand its wire testpackages/client/src/resources/segment.test.ts, thenpackages/client/src/client.tsfor how a namespace is composed onto the client. - Read
packages/cli/src/output/view.ts(the CLI-sideColumnDef<T>/ResourceView<T>contract) and one existingpackages/cli/src/output/views/<r>.tspresentation binding. - Read one existing list command and one existing get command (look under
packages/cli/src/commands/<noun>/). Note how<Resource>ListEnvelope,outputSchema,capabilities,parseId,renderList,renderItem, anddefineMetabaseCommandcompose. - Read one existing e2e test (
tests/e2e/<noun>.e2e.test.ts) and the harness (tests/e2e/run-cli.ts,tests/e2e/bootstrap-data.ts). Theadd-e2e-testskill's runtime contract is binding here — re-read it before writing the e2e file. - Read
packages/cli/src/output/types.tsforlistEnvelopeSchema, theListEnvelope<T>interface, andListRange; thenpackages/cli/src/output/window.tsfor the three window helpers (windowList,windowServerPage,collectForOutput) and thePageSource<T>/PageRequestcontract.