CLI Generation
Customize a CLI
The generated CLI can be customized through gen.yaml, shared OpenAPI-driven generation settings, and a small set of CLI-specific runtime defaults. This page focuses on the options that most directly affect generated CLI behavior. For the full set of target options, see the CLI configuration reference.
CLI-specific generator settings
Section titled “CLI-specific generator settings”The CLI target exposes a focused set of generator settings that control naming, runtime UX, and release artifacts.
cliNameclienvVarPrefixCLIremoveStutterusers list-users → users list.truegenerateRelease.goreleaser.yaml, GitHub release workflow, and install scripts.trueinteractiveModetrueinteractiveAuthtrueinteractiveThemeenableCustomCodeRegionsfalseExample gen.yaml
Section titled “Example gen.yaml”cli: cliName: petstore envVarPrefix: PETSTORE removeStutter: true generateRelease: true interactiveMode: true interactiveAuth: true interactiveTheme: accentColor: "#38BDF8" dimmedColor: "#64748B" subtleColor: "#475569" errorColor: "#F87171" successColor: "#4ADE80"Command naming and stutter removal
Section titled “Command naming and stutter removal”By default, the CLI applies stutter removal to keep command names readable. When an operation name overlaps with its tag group, the redundant part is removed.
Prefix stutter
Section titled “Prefix stutter”An operation like users-list under a users tag becomes list:
# removeStutter: truepetstore users listpetstore users get
# removeStutter: falsepetstore users users-listpetstore users users-getSuffix stutter
Section titled “Suffix stutter”An operation like list-users under a users tag also becomes list:
# removeStutter: truepetstore users listpetstore users create
# removeStutter: falsepetstore users list-userspetstore users create-userSingular/plural variants are also handled, so create-user under users can become create.
Environment variable prefix
Section titled “Environment variable prefix”The envVarPrefix setting controls the prefix for environment variables consumed by the generated CLI. This affects authentication, server overrides, and global parameters.
cli: envVarPrefix: PETSTOREWith this configuration, the CLI will look for values such as:
PETSTORE_API_KEYPETSTORE_BEARER_TOKENPETSTORE_SERVER_URLPETSTORE_TIMEOUT
The exact auth-related variable names depend on the security schemes in the OpenAPI document.
Interactive mode
Section titled “Interactive mode”interactiveMode controls whether the generated CLI includes richer terminal UX for human users.
cli: interactiveMode: trueWhen enabled, the generator adds:
- an
explorecommand for browsing and launching commands from a TUI - auto-prompting for unresolved required fields on eligible operation commands
- auto-launch of the explorer when the CLI is invoked with no subcommand from a real TTY
- the global
--no-interactiveflag to disable prompting/TUI behavior at runtime
petstore explorepetstore users create --no-interactiveWhen disabled, the CLI remains fully functional as a flag-driven command-line tool; it simply omits these interactive surfaces.
Interactive auth flows
Section titled “Interactive auth flows”interactiveAuth controls richer auth-specific flows layered on top of the standard config/auth behavior.
cli: interactiveAuth: trueWhen enabled, and when the API defines global security, the generated CLI can add:
auth loginauth whoamiauth logout- richer
configureflows using terminal forms rather than plain prompts
These flows automatically degrade when interactivity is unavailable and are suppressed in agent mode.
Interactive theme
Section titled “Interactive theme”Tune the generated form and TUI palette with interactiveTheme:
cli: interactiveTheme: accentColor: "#2563EB" dimmedColor: "#64748B" subtleColor: "#475569" errorColor: "#DC2626" successColor: "#16A34A"The theme values are hex colors used for:
- accents and borders
- secondary/dimmed text
- subtle placeholders and muted elements
- validation errors
- success indicators and confirmations
Release artifact generation
Section titled “Release artifact generation”By default, the CLI target generates release infrastructure for distributing binaries:
cli: generateRelease: trueWhen enabled, the generator produces:
.goreleaser.yaml.github/workflows/release.yamlscripts/install.shscripts/install.ps1
Set generateRelease: false to manage packaging and binary distribution separately.
CLI name and binary identity
Section titled “CLI name and binary identity”The cliName setting affects more than just the executable:
- binary name
- config directory path (
~/.config/<cliName>/config.yaml) - shell completion command name
- generated install and usage examples
- user-facing documentation and generated README snippets
cli: cliName: petstoreCustom code regions
Section titled “Custom code regions”Enable custom code regions to preserve hand-written code inside supported files across regenerations.
cli: enableCustomCodeRegions: trueExample:
// #region custom-importsimport "my-custom-package"// #endregion custom-importsFor more details, see the custom code regions documentation.
OpenAPI-driven behavior that also affects the CLI
Section titled “OpenAPI-driven behavior that also affects the CLI”Many CLI features are driven by the OpenAPI document or shared generation/runtime settings rather than a CLI-only flag. Examples include:
- authentication schemes and credential flags
- server definitions and server variable flags
- pagination support
- retries configuration
- response/header behavior
- request body structure and generated flag shape
- streaming endpoints (SSE / JSONL)
- binary responses and bytes request fields
The CLI target wraps a generated Go SDK, so many shared SDK/runtime customizations also influence CLI behavior.
Underlying Go SDK behavior
Section titled “Underlying Go SDK behavior”The CLI target generates and embeds a Go SDK under the hood. Many shared SDK/runtime concepts still apply, including:
- Server configuration
- Authentication and security
- Retries
- Pagination
- Error handling
- Global parameters
For Go-specific SDK configuration, see the Go configuration reference.
Next step
Section titled “Next step”For release packaging and installation workflows, see Distribute a CLI.