| name | hexbus |
| description | Use when creating, improving, or reviewing high-quality CLIs with hexbus, including command design, argument parsing, CliContext services, help/version output, telemetry, errors, spinners, testing, and package manager/framework detection. |
Hexbus
Use this skill to create good CLIs with hexbus, the opinionated TypeScript ESM CLI framework from https://github.com/inthhq/hexbus.
Start Here
Consumer Pattern
Build CLIs around a small command table and one resolved context:
import {
createCliContext,
displayIntro,
globalFlags,
isVersionRequest,
printVersionInfo,
showHelpMenu,
startBackgroundUpdateCheck,
} from "hexbus";
import type { CliCommand } from "hexbus";
- Define
CliCommand[] with stable name, label, hint, description, and an async action(context).
- Handle
-v / --version early with isVersionRequest and printVersionInfo.
- Call
createCliContext({ rawArgs, commands, appName, configName }) once.
- Start update checks with
startBackgroundUpdateCheck during normal command execution.
- Render
--help with showHelpMenu(context, appInfo, commands, globalFlags).
- Route to the matched command via
context.commandName; show help for unknown commands.
Context Services
Prefer existing CliContext services over ad hoc utilities:
context.logger for user-facing output and progress steps.
context.confirm() for prompts; it respects -y / --yes.
context.config.loadConfig() and requireConfig() for config loading.
context.fs for project-rooted package info and file access.
context.packageManager for install, add, run, and exec command strings.
context.framework for detected framework/package metadata.
context.telemetry for best-effort lifecycle and command events.
context.error for normalized cancellation and error exits.
Extend CliContext<TPackage> when a product CLI injects app-specific services, but keep command implementations typed against the smallest context they need.
Errors And UX
- Throw
CliError for expected user-facing failures.
- Use
extendErrorCatalog for product-specific error codes.
- Wrap top-level execution with
withErrorHandling or use context.error.handleError for consistent rendering and telemetry.
- Use
displayIntro, createCliLogger, createSpinner, withSpinner, and showHelpMenu for terminal UX.
- Do not print raw stack traces for expected CLI failures.
Editing Hexbus
- If the user's workspace is a checkout of https://github.com/inthhq/hexbus, edit local files there. Otherwise, explain the relevant GitHub paths and provide patches or guidance against the upstream source.
- Keep public exports centralized in
packages/hexbus/src/index.ts in the upstream repo.
- Add or update focused Vitest coverage when changing parser, context, detection, errors, telemetry, color, or update behavior.
- Preserve the framework-style boundary: shared CLI primitives belong in
hexbus; product decisions belong in consuming packages.
- Prefer small explicit APIs over broad abstractions.
- Update
packages/hexbus/readie.json in the upstream repo when README-facing docs change, then regenerate docs with the repo script.
Bundled Resources
- Load
references/good-cli-checklist.md when designing, reviewing, or improving CLI UX.
- Load
references/testing-hexbus-clis.md when adding tests or planning coverage.
- Load
examples/cli-entrypoint.ts when scaffolding a new production-style CLI entrypoint.
Commands
When working in an upstream hexbus checkout, use Bun from that repo root:
bun run test --filter=hexbus
bun run check-types --filter=hexbus
bun run lint --filter=hexbus
bun run build --filter=hexbus
bun run readie
bun x ultracite fix