defineCommand function that gives you full IntelliSense and compile-time validation.
Basic Command Structure
Every command needs a name, description, and either a handler or render function:Command with Options
Add options to make your commands configurable:examples/hello-world/commands/greet.tsx
Handler Arguments
The handler function receives a rich context object:packages/core/src/types.ts:128-149
Using Shell Commands
Theshell argument provides Bun’s shell execution:
examples/git-tool/commands/status.ts:50-89
Interactive Prompts
Use theprompt API for user input:
Spinners for Long Operations
examples/task-runner/commands/build.ts:94-112
TUI Rendering
Commands can also render interactive terminal UIs:examples/hello-world/commands/greet.tsx:6-57
Type-Safe Command Names
Useas const to enable type inference:
Command Aliases
Provide shortcuts for frequently used commands:examples/git-tool/commands/status.ts:7, examples/git-tool/commands/branch.ts:7
Registering Commands
Register your commands with the CLI instance:examples/hello-world/cli.ts
Next Steps
Working with Options
Learn about option types, validation, and transformations
Command Groups
Organize commands into nested hierarchies
Type Generation
Automatic TypeScript type generation for your commands
Global Flags
Add flags available to all commands