Getting Started
Build a CLI application with Moost in under a minute.
Prerequisites
- Node.js 18 or higher
- npm, pnpm, or yarn
Scaffold a project
bash
npm create moost -- --cliOr with a project name:
bash
npm create moost my-cli -- --cliThe scaffolder creates:
my-cli/
├── src/
│ ├── controllers/
│ │ └── app.controller.ts
│ ├── main.ts
│ └── bin.ts
├── package.json
└── tsconfig.jsonWhat you get
main.ts — the entry point:
ts
import { CliApp } from '@moostjs/event-cli'
import { AppController } from './controllers/app.controller'
new CliApp()
.controllers(AppController)
.useHelp({ name: 'my-cli' })
.start()app.controller.ts — your first command:
ts
import { Cli, Param, Controller } from '@moostjs/event-cli'
@Controller()
export class AppController {
@Cli('greet/:name')
greet(@Param('name') name: string) {
return `Hello, ${name}!`
}
}Run it
bash
npm install && npx tsx src/bin.ts greet WorldYou'll see Hello, World! in the terminal.
How it works
new CliApp()creates a Moost instance pre-configured for CLI.controllers()registers classes that contain command handlers.useHelp()enables the built-in help system (try--help).start()wires everything together and runs the command fromprocess.argv
The @Cli('greet/:name') decorator registers the method as a CLI command. The :name segment becomes a positional argument, extracted by @Param('name').
AI Agent Skill
Install the unified Moost AI skill for context-aware assistance in AI coding agents (Claude Code, Cursor, Windsurf, Codex, etc.):
bash
npx skills add moostjs/moostjsWhat's next
- Commands — command paths, aliases, and routing patterns
- Options & Arguments — flags, positional args, and boolean options
- Controllers — organize commands into logical groups