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 skills
@moostjs/event-cli ships with structured skill files for AI coding agents (Claude Code, Cursor, Windsurf, Codex, etc.). Install them to get context-aware assistance:
bash
# Project-local (recommended — version-locked, commits with your repo)
npx moostjs-event-cli-skill
# Global (available across all your projects)
npx moostjs-event-cli-skill --globalTo keep skills automatically up-to-date, add a postinstall script:
json
{
"scripts": {
"postinstall": "moostjs-event-cli-skill --postinstall"
}
}What's next
- Commands — command paths, aliases, and routing patterns
- Options & Arguments — flags, positional args, and boolean options
- Controllers — organize commands into logical groups