Skip to main content
Mage provides a command-line interface (CLI) for managing projects, running pipelines, and performing administrative tasks. The CLI is built using Typer and supports both interactive and scripted usage.

Quick Reference

Command Availability

CommandDescriptionOSSPro
initInitialize a new Mage project at the specified path
startStart the Mage server and web UI
runExecute a pipeline or a specific block within a pipeline
clean-cached-variablesClean up old pipeline run outputs based on retention period
clean-old-logsClean up old pipeline run logs based on retention period
clean-unused-blocksClean up unused blocks from the project (interactive)
create-secretCreate or update a secret for the given Mage project
run-post-start-hooksExecute post-start hooks with graceful error handling
restart-jobsRestart failed or cancelled pipeline runs with optional filters
update-workspaceUpdate a workspace configuration synchronously
update-all-workspacesUpdate all workspaces in the cluster synchronously
re-add-workspace-routesRe-add workspace routes to the ingress (Kubernetes)
recover-pipelines-from-file-versionsRecover pipelines from file versions in .file_versions folder

Getting Help

To see all available commands:
To get help for a specific command:

Command Categories


Available Commands

Project Management

init - Initialize Mage Project

Available in: ✅ OSS, ✅ Pro Initialize a new Mage project at the specified path. Usage:
Parameters:
  • project_path (required): Path of the Mage project to be created
  • --project-type (optional): Type of project to create. Options: main, sub, or standalone (default: standalone)
  • --cluster-type (optional): Type of instance to create for workspace management (Pro only)
  • --project-uuid (optional): Project UUID for the new project
Example:

start - Start Mage Server and UI

Available in: ✅ OSS, ✅ Pro Start the Mage server and web UI. Usage:
Parameters:
  • project_path (optional): Path of the Mage project to be loaded (default: current directory)
  • --host (optional): Specify the host (default: localhost)
  • --port (optional): Specify the port (default: 6789)
  • --manage-instance (optional): Enable manage instance (default: 0)
  • --dbt-docs-instance (optional): Enable dbt docs instance (default: 0)
  • --instance-type (optional): Specify the instance type (default: server_and_scheduler)
  • --project-type (optional): Create project of this type if it does not exist. Options: main, sub, or standalone (default: standalone)
  • --cluster-type (optional): Type of instance to create for workspace management (Pro only)
  • --project-uuid (optional): Set project UUID for the repo that is being started
Example:

Pipeline Execution

run - Run Pipeline

Available in: ✅ OSS, ✅ Pro Execute a pipeline or a specific block within a pipeline. Usage:
Parameters:
  • project_path (required): Path of the Mage project that contains the pipeline
  • pipeline_uuid (required): UUID of the pipeline to be run
  • --test (optional): Specify if tests should be run (default: False)
  • --block-uuid (optional): UUID of the block to be run (if not specified, runs entire pipeline)
  • --execution-partition (optional): Execution partition identifier
  • --executor-type (optional): Executor type to use
  • --callback-url (optional): Callback URL for block execution
  • --block-run-id (optional): Block run ID
  • --pipeline-run-id (optional): Pipeline run ID
  • --runtime-vars (optional): Runtime variables in JSON format. These will overwrite the pipeline global variables
  • --skip-sensors (optional): Specify if the sensors should be skipped (default: False)
  • --template-runtime-configuration (optional): Runtime configuration of data integration block runs (JSON format)
Examples:

Maintenance Commands

clean-cached-variables - Clean Cached Variables

Available in: ✅ OSS, ✅ Pro Clean up old pipeline run outputs based on retention period. Usage:
Parameters:
  • project_path (required): Path of the Mage project to clean variables
  • --pipeline-uuid (optional): UUID of the pipeline to clean (if not specified, cleans all pipelines)
  • --retention-period (optional): Default retention period, e.g., 7d, 2w (days or weeks)
Example:

clean-old-logs - Clean Old Logs

Available in: ✅ OSS, ✅ Pro Clean up old pipeline run logs based on retention period. Usage:
Parameters:
  • project_path (required): Path of the Mage project to clean old logs
  • --pipeline-uuid (optional): UUID of the pipeline to clean (if not specified, cleans all pipelines)
  • --retention-period (optional): Default retention period, e.g., 7d, 2w (days or weeks)
Example:

Mage Pro Only Commands

The following commands are exclusively available in Mage Pro:

clean-unused-blocks - Clean Unused Blocks

Available in: ❌ OSS, ✅ Pro Clean up unused blocks from the given Mage project. This command interactively prompts you to delete blocks that are not referenced by any pipeline. Usage:
Parameters:
  • project_path (required): Path of the Mage project
  • --block-type (optional): The type of block to clean up (e.g., data_loader, transformer, data_exporter)
Example:
Interactive Options:
  • y: Yes, delete the block
  • N: No, skip the block
  • c: Check content of the block before deciding
  • q: Quit the operation

create-secret - Create or Update Secret

Available in: ❌ OSS, ✅ Pro Create or update a secret for the given Mage project. Usage:
Parameters:
  • project_path (required): Path of the Mage project
  • name (required): Name of the secret
  • value (required): Value of the secret
  • --update-exists (optional): Whether to update the secret if it already exists (default: True)
Example:

run-post-start-hooks - Execute Post-Start Hooks

Available in: ❌ OSS, ✅ Pro Execute post-start hooks with graceful error handling. This command reads POST_START_COMMAND and POST_START_HOOK_PATH from environment variables if not provided as arguments. Usage:
Parameters:
  • --post-start-command (optional): Post-start command to execute (JSON array or shell command string). Can also be set via POST_START_COMMAND environment variable
  • --post-start-hook-path (optional): Path to post-start hook script file. Can also be set via POST_START_HOOK_PATH environment variable
Example:

restart-jobs - Restart Failed or Cancelled Pipeline Runs

Available in: ❌ OSS, ✅ Pro Restart failed or cancelled pipeline runs with optional filters. Usage:
Parameters:
  • project_path (required): Path of the Mage project to restart jobs from
  • --pipeline-uuid (optional): UUID of the pipeline to filter jobs by
  • --status (optional): Status filter: failed, cancelled, or both (default: failed)
  • --start-time (optional): Start time filter (ISO format: 2024-01-01T00:00:00)
  • --end-time (optional): End time filter (ISO format: 2024-01-01T23:59:59)
  • --limit (optional): Maximum number of jobs to restart (default: 100)
  • --skip-confirmation (optional): Skip confirmation prompt (default: False)
Example:

update-workspace - Update Workspace Configuration

Available in: ❌ OSS, ✅ Pro Update a workspace configuration synchronously. The cluster type is determined by the CLUSTER_TYPE environment variable, defaulting to k8s if not set. Usage:
Parameters:
  • workspace_name (required): Name of the workspace to update
  • --project-path (optional): Path to the Mage project (defaults to current directory)
  • --container-config (optional): YAML string for container configuration updates
  • --update-workspace-settings / --no-update-workspace-settings (optional): Whether to update workspace settings with current cluster environment variables (default: False)
Example:

update-all-workspaces - Update All Workspaces

Available in: ❌ OSS, ✅ Pro Update all workspaces in the cluster synchronously. Usage:
Parameters:
  • --project-path (optional): Path to the Mage project (defaults to current directory)
  • --container-config (optional): YAML string for container configuration updates
  • --update-workspace-settings / --no-update-workspace-settings (optional): Whether to update workspace settings with current cluster environment variables (default: False)
  • --cluster-type (optional): Type of cluster: k8s or docker (default: k8s)
Example:

re-add-workspace-routes - Re-add Workspace Routes to Ingress

Available in: ❌ OSS, ✅ Pro Re-add workspace routes to the ingress. This is useful for Kubernetes deployments where workspace routes need to be refreshed. Usage:
Parameters:
  • project_path (required): Path of the Mage project
Example:

recover-pipelines-from-file-versions - Recover Pipelines from File Versions

Available in: ❌ OSS, ✅ Pro Recover pipelines from file versions. This command lists all pipelines that have file versions in the .file_versions folder and allows you to recover pipeline files from those versions. Usage:
Parameters:
  • project_path (required): Path of the Mage project
  • --pipeline-uuid (optional): UUID of the pipeline to recover. If not specified, all pipelines are processed
  • --all / --no-all (optional): Recover all files automatically without confirmation. Uses the most recent version for each file (default: False)
  • --verbose / -v (optional): Show detailed pipeline information including individual files and blocks (default: False)
Examples:

Common Use Cases

Initializing a New Project

Running a Pipeline with Variables

Cleaning Up Old Data

Pro: Managing Secrets

Pro: Updating Workspace Configuration


Environment Variables

Some commands can be configured via environment variables:
  • CLUSTER_TYPE: Cluster type for workspace operations (default: k8s)
  • POST_START_COMMAND: Post-start command for run-post-start-hooks
  • POST_START_HOOK_PATH: Post-start hook script path for run-post-start-hooks
  • ENV_VAR_INSTANCE_TYPE: Instance type override for start command

Additional Resources


Notes

  • All paths can be absolute or relative to the current working directory
  • JSON parameters should be properly escaped when used in shell commands
  • Pro-only commands require appropriate cluster/workspace configuration
  • Some commands may require database connections to be properly configured