CLI Reference
The ninjadog CLI is distributed as a .NET global tool for project scaffolding and code generation.
Table of contents
Installation
dotnet tool install -g Ninjadog
After installation, run
ninjadog --helpto verify the tool is available.
Typical Workflow
ninjadog init Create a new project (interactive)
|
edit config Define your entities in ninjadog.json
| --- or ---
ninjadog add-entity (Optional) Add more ninjadog ui
| entities from the CLI Launch the visual
ninjadog validate Check your config config builder
| for errors |
ninjadog build Run the generators ninjadog build
|
dotnet run Launch your API
ninjadog update Refresh schema after upgrading the CLI
Commands
ninjadog init
Initializes a new Ninjadog project in the current directory. By default, init runs in interactive mode, prompting you for project details, then writes the configuration with a sample Person entity to get you started.
ninjadog init
Options:
| Option | Description |
|---|---|
--default |
Skip prompts and use default values. |
--name <name> |
Set the project name (skips the name prompt). |
--namespace <ns> |
Set the root namespace (skips the namespace prompt). |
--template <name> |
Template to use (e.g. CrudWebAPI). Skips the template prompt. |
--use-case <name> |
Use case to scaffold (TodoApp, RestaurantBooking, or Custom). Skips the use case prompt. |
--from-prompt <text> |
Generate config from a natural language description using AI. Requires ANTHROPIC_API_KEY environment variable. |
Template and use case selection
When you run ninjadog init interactively, the CLI first asks you to choose a template and a use case:
| Prompt | Choices | Description |
|---|---|---|
| Template | CrudWebAPI |
The code generation template to use. Currently only CrudWebAPI is available. |
| Use case | TodoApp, RestaurantBooking, Custom |
A pre-built use case with entities already defined, or Custom to define your own entities interactively. |
Selecting TodoApp or RestaurantBooking creates a fully configured ninjadog.json with pre-defined entities, relationships, and seed data. Selecting Custom continues with the interactive prompts below.
Interactive prompts (Custom use case)
When you select the Custom use case, the CLI asks for the following project settings:
| Prompt | Default | Description |
|---|---|---|
| Project name | NinjadogApp |
The display name for your API project. |
| Version | 1.0.0 |
The initial semantic version. |
| Description | Welcome to Ninjadog! |
A short description of the project. |
| Root namespace | NinjadogApp |
The C# root namespace for generated code. |
| Output path | . |
Directory where generated files are written (relative to the config file). |
Press Enter at any prompt to accept the default value.
Example session
$ ninjadog init
? Project name: MyApi
? Version: 1.0.0
? Description: My REST API
? Root namespace: MyApi
? Output path: src/applications/MyApi
Ninjadog settings file created successfully.
This creates a ninjadog.json in the current directory:
{
"config": {
"name": "MyApi",
"version": "1.0.0",
"description": "My REST API",
"rootNamespace": "MyApi",
"outputPath": "src/applications/MyApi",
"saveGeneratedFiles": true
},
"entities": {
"Person": {
"properties": {
"Id": { "type": "Guid", "isKey": true },
"FirstName": { "type": "string" },
"LastName": { "type": "string" },
"BirthDate": { "type": "DateTime" }
}
}
}
}
Examples:
# Interactive mode (prompts for template and use case)
ninjadog init
# Scaffold TodoApp use case directly
ninjadog init --use-case TodoApp
# Scaffold RestaurantBooking use case
ninjadog init -u RestaurantBooking
# Non-interactive with defaults
ninjadog init --default
# Non-interactive with custom values
ninjadog init --name MyApi --namespace MyApi.Web
# Generate from natural language (requires ANTHROPIC_API_KEY)
ninjadog init --from-prompt "A blog platform with users, posts, tags, and comments"
The generated
Personentity is a starter template. Replace or extend it with your own domain entities before runningninjadog build.
A
ninjadog.jsonfile must not already exist in the current directory. If one is found, the command exits with an error to avoid overwriting your configuration.
ninjadog validate
Validates your ninjadog.json configuration file against the schema and checks for common errors.
ninjadog validate [OPTIONS]
Options:
| Option | Description |
|---|---|
--file <path> |
Path to the configuration file. Default: ninjadog.json |
--strict |
Treat warnings as errors (exit code 1). |
Exit codes:
| Code | Meaning |
|---|---|
0 |
Configuration is valid. |
1 |
Validation errors found. |
2 |
File not found or JSON parse error. |
Example output:
$ ninjadog validate
Validating ninjadog.json...
ERROR NINJ001 Entity "Product" has no properties defined.
ERROR NINJ003 Property "Product.Id" is marked as key but type "string" has no maxLength.
WARN NINJ007 Entity "Order" has no key property. A Guid key named "Id" will be added.
Result: 2 errors, 1 warning
Validation rules:
| Code | Severity | Description |
|---|---|---|
| NINJ001 | Error | Entity has no properties defined. |
| NINJ002 | Error | Entity has multiple key properties. |
| NINJ003 | Error | String key property has no maxLength. |
| NINJ004 | Error | Property type is not recognized. |
| NINJ005 | Error | Relationship references a non-existent entity. |
| NINJ006 | Error | Enum name conflicts with an entity name. |
| NINJ007 | Warning | Entity has no key property (a default will be added). |
| NINJ008 | Warning | Seed data property does not match any entity property. |
| NINJ009 | Warning | outputPath directory does not exist. |
| NINJ010 | Warning | Config file does not include $schema property. |
Run
ninjadog validatebeforeninjadog buildto catch configuration mistakes early. In CI pipelines, use--strictto ensure warnings are not ignored.
ninjadog add-entity
Adds a new entity to your existing ninjadog.json configuration file. The entity is created with a default Guid primary key.
ninjadog add-entity <EntityName>
The entity name should be in PascalCase (e.g.,
Product,OrderItem). Aninjadog.jsonfile must already exist in the current directory – runninjadog initfirst if you haven’t already.
Example:
ninjadog add-entity Product
This appends a Product entity to the entities section of your ninjadog.json:
{
"entities": {
"Person": { ... },
"Product": {
"properties": {
"Id": {
"type": "Guid",
"isKey": true
}
}
}
}
}
After adding an entity, open
ninjadog.jsonto define additional properties before runningninjadog build.
ninjadog update
Updates the ninjadog.schema.json file in the current directory to the version embedded in the installed CLI tool. This is useful after upgrading Ninjadog to get IDE autocompletion and validation for newly added configuration options.
ninjadog update
Example:
$ ninjadog update
Schema file updated successfully.
-> ninjadog.schema.json
Run
ninjadog updateafter upgrading the CLI tool to ensure your local schema stays in sync with the installed version.
ninjadog build
Builds and runs the generator engine against your project configuration. This reads the ninjadog.json file in the current directory and produces the generated source files.
ninjadog build
ninjadog ui
Launches a local web server that hosts a visual configuration builder for your ninjadog.json file. The UI lets you create and edit entities, enums, and seed data through a browser-based interface instead of editing JSON by hand.
ninjadog ui [OPTIONS]
Options:
| Option | Description | Default |
|---|---|---|
--port <number> |
Port number for the local web server | 5111 |
--path <path> |
Path to the ninjadog.json file to edit |
./ninjadog.json |
--no-open |
Do not open the browser automatically | false |
Visual builder features:
- Entity editor – Add, rename, clone, and remove entities. Define properties with types, key markers, and validation rules. Drag-and-drop property reordering, quick-add presets (ID, Name, Timestamps, Email, Description), and bulk property actions.
- Enum editor – Define enums with named values. Inline add/remove with two-click delete confirmation.
- Seed data editor – Populate initial data rows for each entity. Auto-generated key values (Guid, int, long), CSV/JSON import, and cell-level type validation.
- Live JSON preview – See the generated
ninjadog.jsonupdate in real time with Monaco Editor syntax highlighting and schema validation. - Validation – Live schema validation with error paths displayed inline.
- Undo / Redo – Full undo/redo history (up to 50 states) with Ctrl+Z / Ctrl+Y keyboard shortcuts.
- AI Assistant – Describe your API in plain English and generate a complete configuration. Toggle the chat panel with the sparkle icon or Ctrl+Shift+A. Supports multi-turn conversation for iterating on the schema. Requires
ANTHROPIC_API_KEYenvironment variable. - Keyboard shortcuts – Ctrl+S save, Ctrl+B build, Ctrl+E add entity, Ctrl+Shift+A AI assistant, 1–4 switch tabs, ? show shortcut overlay.
- Auto-save – Optional auto-save to localStorage with 3-second debounce.
- View modes – Toggle between Split View (form + JSON), Form Only, or JSON Only layouts.
- Template picker – Start from pre-built templates (Blank, Todo App, Blog API, E-Commerce) instead of an empty configuration.
- Import – Import seed data from CSV or JSON arrays via a modal dialog.
- Export – Download the current configuration as a JSON file.
- Entity color coding – Each entity gets a unique color dot for quick visual identification across all tabs.
By default,
ninjadog uiopens your browser automatically. Use--no-openif you are running on a headless server or want to open the URL manually.
A
ninjadog.jsonfile must already exist in the target directory. Runninjadog initfirst if you haven’t already.
Example:
# Start on the default port and open the browser
ninjadog ui
# Start on a custom port without opening a browser
ninjadog ui --port 8080 --no-open
Next Steps
- Getting Started – Step-by-step tutorial using the CLI tool
- Configuration Reference – Full reference for ninjadog.json
- Architecture – Understand the project structure
- Generators – See what gets generated
- Generated Examples – Real generated code from snapshot tests