Motia Icon
Concepts

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.

npx motia create [options]

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. Run npx 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.

npx motia templates

build

Build your project, generating zip files for each step and creating a configuration file.

npx motia build

This command:

  1. Compiles all your steps (both Node.js and Python)
  2. Bundles each step into a zip file
  3. Generates a motia.steps.json configuration file in the dist directory
  4. Organizes the output in the dist directory

deploy

Deploy your built steps to the Motia deployment service.

npx motia deploy [options]

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:

npx motia deploy --api-key your-api-key-here --env production --version 1.0.0

The deployment process:

  1. Uploads each zip file individually with its path information
  2. Uploads the steps configuration from motia.steps.json
  3. Starts the deployment process on the server
  4. Generates deployment results in dist/motia.deployments.json
  5. Creates a human-readable summary in dist/motia.deployments.summary.json

dev

Start the development server.

npx motia dev [options]

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.

npx motia get-config [options]

Options:

  • -o, --output <path>: Path to write the generated config file.

emit

Emit an event to the Motia server.

npx motia emit [options]

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.

npx motia generate step [options]

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.

npx motia state list

Debugging

You can enable debug logging by passing the -d or --debug flag to the dev command:

npx motia dev --debug

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.
Need help? See our Community Resources for questions, examples, and discussions.

On this page