Command Line Interface (CLI)
Learn how to use the Motia CLI to manage your projects and workflows
Command Line Interface (CLI)
Motia provides a powerful Command Line Interface (CLI) to help you manage your projects and workflows. The CLI offers various commands for creating projects, generating steps, managing state, and more.
Installation
The Motia CLI is automatically installed when you install the motia package. You can use it by running npx motia followed by the desired command.
Commands
create
Create a new Motia project.
Arguments:
[project-name](optional): The name for your project folder. If not provided, you will be prompted to enter it. Use.or./to create it in the current directory.
Options:
--template <template-name>(optional): The template to use for your project. If not provided, you will be prompted to select one interactively.
Available Templates:
Motia provides several project templates to help you get started quickly:
| Template | Description | Use Case |
|---|---|---|
starter-typescript | Starter (TypeScript) | Minimal TypeScript project with basic examples |
starter-javascript | Starter (JavaScript) | Minimal JavaScript project with basic examples |
starter-python | Starter (Python) | Minimal Python project with basic examples |
motia-tutorial-typescript | Tutorial (TypeScript) | Interactive tutorial project in TypeScript |
motia-tutorial-python | Tutorial (Python) | Interactive tutorial project in Python |
Examples:
Create a TypeScript starter project:
Create a Python tutorial project:
Use interactive mode (no template specified):
build
Build your project, generating zip files for each step and creating a configuration file.
This command:
- Compiles all your steps (both Node.js and Python)
- Bundles each step into a zip file
- Generates a
motia.steps.jsonconfiguration file in thedistdirectory - Organizes the output in the
distdirectory
deploy
Deploy your built steps to the Motia deployment service.
Options:
-k, --api-key <key>(required): Your API key for authentication-n, --project-name <name>: Project name (used when creating a new project)-s, --environment-id <id>: Environment ID (can also be set via MOTIA_ENVIRONMENT_ID env var)--environment-name <name>: Environment name (used when creating a new environment)-v, --version-name <version>(required): The version to deploy-d, --version-description <description>: The description of the version-e, --env-file <path>: Path to environment file
Example:
The deployment process:
- Build your project
- Uploads each zip file individually with its path information
- Starts the deployment process on the server
dev
Start the development server.
Options:
-p, --port <port>: The port to run the server on (default: 3000).-H, --host [host]: The host address for the server (default: localhost).-d, --debug: Enable debug logging.
get-config
Get the generated config for your project.
Options:
-o, --output <path>: Path to write the generated config file.
emit
Emit an event to the Motia server.
Options:
--topic <topic>(required): Event topic/type to emit.--message <message>(required): Event payload as a JSON string.-p, --port <number>: Port number (default: 3000).
generate
Generate Motia resources.
generate step
Create a new step with interactive prompts.
Options:
-d, --dir <step file path>: The path relative to the steps directory to create the step file.
generate openapi
Generate OpenAPI spec for your project.
Options:
-t, --title <tile of the document>: Title for the OpenAPI document. Defaults to project name from package.json.-v, --version <version of the document>: Version of the OpenAPI document. Defaults to 1.0.0.-o, --output <output file name / path>: The file name and path relative to root to create the openapi file. Defaults toopenapi.jsonat the root.
state
Manage application state.
state list
List the current file state.
Debugging
You can enable debug logging by passing the -d or --debug flag to the dev command:
This will set the LOG_LEVEL environment variable to 'debug', providing more detailed logging output.
docker
Tools to help you setup your Motia project with docker and run it inside a container.
docker setup
Setup your Motia project for Docker
docker build
Build your Motia project Docker image
Options:
--project-name <project name>(required): The name of your project.
docker run
Run your Motia project inside a container
Options:
--port <number>: Port number (default: 3000).--project-name <project name>(required): The name of your project.--skip-build: Skip building the Docker image and used the last built image.
Next Steps
- Explore the Core Concepts to learn more about Steps, Flows, Events, and Topics.
- Check out the Examples for common patterns and use cases.
- Join our Community for help and discussions.