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.
Options:
-n, --name <project name>
: The name for your project, used to create a directory. Use.
or./
to create it in the current directory.-t, --template <template name>
: The Motia template to use for your project. Runnpx motia templates
to see available templates.-c, --cursor
: Enable Cursor IDE integration by adding.cursor
configuration folder
templates
Print the list of available project templates.
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.json
configuration file in thedist
directory - Organizes the output in the
dist
directory
deploy
Deploy your built steps to the Motia deployment service.
Options:
-k, --api-key <key>
(required): Your API key for authentication-e, --env <environment>
: The environment to deploy to (default:dev
)-v, --version <version>
: The version to deploy (default:latest
)
Example:
The deployment process:
- Uploads each zip file individually with its path information
- Uploads the steps configuration from
motia.steps.json
- Starts the deployment process on the server
- Generates deployment results in
dist/motia.deployments.json
- Creates a human-readable summary in
dist/motia.deployments.summary.json
dev
Start the development server.
Options:
-p, --port <port>
: The port to run the server on (default: 3000).-v, --verbose
: Enable verbose logging.-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.
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.
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.