clilyruntime-aware CLI docs
Reference

Hooks and runtime

The lifecycle hooks and runtime contract that define how clily integrates with larger systems.

Hooks

ClilyHooks currently includes:

  • onParse(rawArgs)
  • onValidate(resolvedConfig)
  • onError(err)
  • onExit(request)
  • onValidationError(issues)
  • onPromptSelect(missingKeys)
  • onHelp(helpText)

Exit reasons

ClilyExitRequest.reason is one of:

  • cancelled
  • runtime-error
  • validation

Runtime shape

interface ClilyRuntime {
  argv: readonly string[]
  env: Record<string, string | undefined>
  cwd: () => string
  stdout: (message: string) => void | Promise<void>
  debug: (message: string, payload?: unknown) => void | Promise<void>
  error: (message: string | Error) => void | Promise<void>
  exit: (request: ClilyExitRequest) => void | Promise<void>
}

When you need deterministic behavior, start here instead of patching process globals after the fact.

On this page