Using the CLI
The ctx command is the official ContextJS CLI. It handles project scaffolding, building, watching, and running code with compiler extensions.
Available Commands
ctx new
Scaffolds a new project:
bash
ctx new api my-apiCreates a folder with project config, base services, and tsconfig support.
ctx build
Compiles your project using custom transformers:
bash
ctx buildSupports all TypeScript CLI flags:
bash
ctx build --target ES2022 --noEmitOnErrorSpecify the project to build:
bash
ctx build -p my-api
# or
ctx build project my-apictx watch
Watches for changes and recompiles automatically:
bash
ctx watchctx run
Executes the project’s entry file (while ensuring all decorators and metadata are executed):
bash
ctx run
# or
ctx run -p my-api
# or
ctx run project my-apiBy default ctx run will build the project first, but you can skip this with --no-build option:
bash
ctx run -p my-api --no-build