Scaffold / maintain CLI help (cli.help.ts)
This skill applies the typed root help pattern used across @finografic CLI tools (genx, gli, and scaffolds from genx).
Read first (repo — canonical for this repository)
.agents/instructions/project/cli-help-patterns.instructions.md— rules, file locations,HelpConfigshape, examples/footer conventions.
Deeper spec (canonical — in this repo)
docs/spec/CLI_CORE.md— fullcore/render-helpAPI (HelpConfig,renderHelp, section shapes), export table, and examples.
Optional context: A temporary bulk-task folder in a monorepo (e.g. ___REFACTORING___) may hold REPORT_CLI_NORMALIZATION.md with migration history. That path is not canonical; use it when you have it for background, not as the spec.
Keep this skill procedural; link to docs/spec/CLI_CORE.md for authoritative types and tables.
Prerequisites
src/core/render-help/exists (shared module; do not rewrite the renderer unless intentionally changingcore/across all CLI repos).tsconfig.jsonincludes"core/*": ["./src/core/*"](or equivalent).- You know the CLI binary name (e.g.
genx) and the commands to list.
Procedure
Open or create
src/cli.help.tsat the repository root ofsrc/(never nested undercommands/for root help).Import types from the barrel only:
import type { HelpConfig } from 'core/render-help';Do not import help types from
src/types/orutils/.Export a single named config
cliHelp(not default export):export const cliHelp: HelpConfig = { main: { bin: '…', args: '<command> [options]' }, // commands, examples, footer — see instruction file };Follow section conventions (details in the instruction file):
- examples:
label= human description,description= exact command line. - footer:
labelmay use<placeholder>tokens;descriptionoptional dim line.
- examples:
Wire
src/cli.ts: importrenderHelpfromcore/render-helpandcliHelpfrom./cli.help.js(use.jsextension if the project usesverbatimModuleSyntax). CallrenderHelp(cliHelp)only from the CLI entry / help branch — not insidecli.help.ts.Optional shared defaults: genx uses
defaultHelpOptionsfromconfig/help.configforminWidth/ alignment — follow existing project pattern if present.Verify:
pnpm typecheckand run the binary with--helpor no args to confirm layout.
When adding a new command
- Add a row to
commands.list(keep descriptions one line). - Add Examples entries where users will copy-paste real invocations.
- Update any command-specific help files (
src/help/*.help.ts) if this repo splits per-command help — root skill covers rootHelpConfigonly.
Design constraints
- Root help stays declarative data (
HelpConfig); rendering is centralized incore/render-help. - Do not duplicate
renderHelplogic in application code.