LogoRobo.js

@robojs/cli

Build standalone CLI apps with file-based routing powered by Robo.js.

Install @robojs/cli with:

Create professional command-line applications with minimal boilerplate. Define commands as files, and @robojs/cli generates a standalone executable during robo build. Full TypeScript inference, automatic help generation, subcommand nesting, and extensible hooks come out of the box.

Features

File-based Routing

Commands map directly to files in your project

Type-safe Options

Full TypeScript inference for command options

Subcommands

Nested directories become subcommands automatically

Auto Help

Help text generated from your config

Zero Config

Works out of the box with sensible defaults

Installation

Add to your existing Robo.js project:

npx robo add @robojs/cli@next

Or scaffold a new project with the plugin:

npx create-robo@next my-cli -p @robojs/cli@next

Quick start

Create a command

hello.ts
src/cli/hello.ts
import { createCliCommandConfig, type CliContext } from 'robo.js/cli.js'

export const config = createCliCommandConfig({
	description: 'Say hello to someone',
	options: [
		{ alias: '-n', name: '--name', description: 'Name to greet', type: 'string', default: 'World' }
	]
} as const)

export default (ctx: CliContext<typeof config>) => {
	console.log(`Hello, ${ctx.options.name}!`)
}
src/cli/hello.js
export const config = {
	description: 'Say hello to someone',
	options: [
		{ alias: '-n', name: '--name', description: 'Name to greet', type: 'string', default: 'World' }
	]
}

export default (ctx) => {
	console.log(`Hello, ${ctx.options.name}!`)
}
npx robo build
npm link

The bin field is automatically added to package.json during build, and npm link makes your CLI available by name.

Run

my-cli hello
# Hello, World!

my-cli hello --name Robo
# Hello, Robo!

During robo dev, you can also use /cli link in the interactive terminal or /cli run to test commands inline. See the Development guide for more.

Project structure

hello.tsmycli hello
migrate.tsmycli db migrate
seed.tsmycli db seed
package.json

Next steps

On this page