CLI tool that scaffolds new Nitro applications with a single command. Part of the nitrojs ecosystem.
Keep AGENTS.md updated with project structure and architecture.
src/cli.ts # Main CLI entry point (single-file CLI)
nitro-app/ # Reference Nitro starter template
build.config.mjs # obuild config (bundles CLI + injects pkg metadata)
dist/ # Compiled output (single bundled .mjs executable)
The CLI runs in three modes based on environment:
- Interactive (TTY) — full prompts for all options
- Non-interactive (no TTY) — skips prompts, uses defaults
- AI Agent (
isAgentfromstd-env) — no args: shows usage + exits 1; with args: uses defaults (non-interactive)
Interactive flow:
- Check for agent/help — show usage if needed
- Display ASCII banner
- Prompt for target directory (default:
nitro-app) - Handle existing directory (override/rename/abort)
- Select template from registry
- Download template via
gigetfromhttps://raw.githubusercontent.com/nitrojs/starter/templates - Detect/select package manager and install dependencies
- Optionally initialize git repo
- Display next steps
Non-interactive/agent defaults: dir=nitro-app, template=vite, PM=detected or npm, gitInit=false.
| Arg | Description |
|---|---|
dir (positional) |
Target directory |
--template/-t |
Template name |
--force |
Overwrite existing directory |
--forceClean |
Remove existing dir before cloning |
--offline / --preferOffline |
Cache behavior |
--install |
Install deps (default: true) |
--packageManager/-p |
Specify PM (npm, pnpm, yarn, bun) |
--gitInit |
Initialize git repo |
--help/-h |
Show usage information |
Hardcoded in src/cli.ts:
- vite - Full-stack with Vite
- cli - Backend with Nitro CLI
Uses obuild (rolldown-based bundler) to produce a single dist/cli.mjs executable (~793KB). Build-time injected globals:
globalThis.__pkg_version__globalThis.__pkg_name__globalThis.__pkg_description__
| Package | Purpose |
|---|---|
| citty | CLI framework (commands, args) |
| consola | Logging and interactive prompts |
| giget | Template downloading from GitHub registry |
| nypm | Package manager detection and dep installation |
| tinyexec | Shell command execution (git init) |
pnpm build # Bundle CLI with obuild
pnpm create-nitro-app # Test CLI locally (node ./src/cli.ts)
pnpm lint # ESLint + Prettier check
pnpm fmt # automd + ESLint fix + Prettier format
pnpm test # lint + type check
pnpm release # test + changelog + publish + push- ESM only (
"type": "module") - UnJS ESLint preset
- Semantic commit messages with changelogen
- TypeScript strict mode
- 2-space indentation