Skip to content

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 -- --cli

Or with a project name:

bash
npm create moost my-cli -- --cli

The scaffolder creates:

my-cli/
├── src/
│   ├── controllers/
│   │   └── app.controller.ts
│   ├── main.ts
│   └── bin.ts
├── package.json
└── tsconfig.json

What 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 World

You'll see Hello, World! in the terminal.

How it works

  1. new CliApp() creates a Moost instance pre-configured for CLI
  2. .controllers() registers classes that contain command handlers
  3. .useHelp() enables the built-in help system (try --help)
  4. .start() wires everything together and runs the command from process.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 --global

To keep skills automatically up-to-date, add a postinstall script:

json
{
  "scripts": {
    "postinstall": "moostjs-event-cli-skill --postinstall"
  }
}

What's next

Released under the MIT License.