$npx -y skills add medusajs/medusa-agent-skills --skill mcloud-environmentsExecute mcloud environments commands to list, get, create, delete, redeploy, or trigger builds for Cloud environments. Use when managing environment lifecycle, redeploying after variable changes, or starting new builds from source.
| 1 | # Cloud CLI: Environments Commands |
| 2 | |
| 3 | Execute `mcloud environments` commands to manage environment lifecycle and deployments. |
| 4 | |
| 5 | ## Constraints |
| 6 | |
| 7 | - **Production environments cannot be deleted.** Always check `type` via `environments get --json` before attempting delete in automation. |
| 8 | - Use `--yes` for destructive operations (`delete`) in non-interactive contexts. |
| 9 | - `redeploy` vs `trigger-build` are not interchangeable — choose the right one based on where the fix is. |
| 10 | |
| 11 | ## Commands |
| 12 | |
| 13 | ### environments list |
| 14 | |
| 15 | List all environments in a project. |
| 16 | |
| 17 | ```bash |
| 18 | mcloud environments list --organization <org-id> --project <project-id-or-handle> --json |
| 19 | ``` |
| 20 | |
| 21 | **Options:** |
| 22 | - `-o/--organization <id>` — Organization ID (falls back to active context) |
| 23 | - `-p/--project <id-or-handle>` — Project ID or handle (falls back to active context) |
| 24 | - `--json` — Output as JSON |
| 25 | |
| 26 | ### environments get |
| 27 | |
| 28 | Retrieve a single environment by its ID or handle. |
| 29 | |
| 30 | ```bash |
| 31 | mcloud environments get <environment-id-or-handle> --organization <org-id> --project <project-id-or-handle> --json |
| 32 | ``` |
| 33 | |
| 34 | **Arguments:** |
| 35 | - `environment` — Environment ID or handle (required) |
| 36 | |
| 37 | **Options:** |
| 38 | - `-o/--organization <id>`, `-p/--project <id-or-handle>`, `--json` |
| 39 | |
| 40 | ### environments create |
| 41 | |
| 42 | Create a new long-lived environment. |
| 43 | |
| 44 | ```bash |
| 45 | mcloud environments create \ |
| 46 | --organization <org-id> \ |
| 47 | --project <project-id-or-handle> \ |
| 48 | --name "Staging" \ |
| 49 | --branch develop \ |
| 50 | --json |
| 51 | ``` |
| 52 | |
| 53 | **Options:** |
| 54 | - `-o/--organization <id>`, `-p/--project <id-or-handle>` |
| 55 | - `-n/--name <name>` — Environment name (required) |
| 56 | - `-b/--branch <branch>` — Git branch to track (required) |
| 57 | - `--custom-subdomain <subdomain>` — Optional custom subdomain |
| 58 | - `--json` — Output as JSON |
| 59 | |
| 60 | ### environments delete |
| 61 | |
| 62 | Delete an environment. **Cannot delete production environments.** |
| 63 | |
| 64 | ```bash |
| 65 | mcloud environments delete <environment-id-or-handle> \ |
| 66 | --organization <org-id> \ |
| 67 | --project <project-id-or-handle> \ |
| 68 | --yes |
| 69 | ``` |
| 70 | |
| 71 | **Arguments:** |
| 72 | - `environment` — Environment ID or handle (required) |
| 73 | |
| 74 | **Options:** |
| 75 | - `-o/--organization <id>`, `-p/--project <id-or-handle>` |
| 76 | - `-y/--yes` — Skip confirmation prompt (required in non-interactive mode) |
| 77 | - `--json` — Output as JSON |
| 78 | |
| 79 | ### environments redeploy |
| 80 | |
| 81 | Re-run an existing build for the active deployment. Use when the fix is environment-side (variable change, infra issue) — does NOT start a new build. |
| 82 | |
| 83 | ```bash |
| 84 | mcloud environments redeploy <environment-id-or-handle> \ |
| 85 | --organization <org-id> \ |
| 86 | --project <project-id-or-handle> \ |
| 87 | --json |
| 88 | ``` |
| 89 | |
| 90 | **Arguments:** |
| 91 | - `environment` — Environment ID or handle (required) |
| 92 | |
| 93 | **Options:** |
| 94 | - `-o/--organization <id>`, `-p/--project <id-or-handle>`, `--json` |
| 95 | |
| 96 | > Requires the environment to have an active deployment. If it doesn't, use `trigger-build` first. |
| 97 | |
| 98 | ### environments trigger-build |
| 99 | |
| 100 | Start a new build from the tracked branch. Use when the fix is committed code — creates a new deployment. |
| 101 | |
| 102 | ```bash |
| 103 | mcloud environments trigger-build <environment-id-or-handle> \ |
| 104 | --organization <org-id> \ |
| 105 | --project <project-id-or-handle> \ |
| 106 | --json |
| 107 | ``` |
| 108 | |
| 109 | **Arguments:** |
| 110 | - `environment` — Environment ID or handle (required) |
| 111 | |
| 112 | **Options:** |
| 113 | - `-o/--organization <id>`, `-p/--project <id-or-handle>`, `--json` |
| 114 | |
| 115 | ## Redeploy vs Trigger-Build Decision |
| 116 | |
| 117 | | Command | When to use | |
| 118 | |---------|-------------| |
| 119 | | `redeploy` | Fix is environment-side (variable change, infra config) — reruns existing build | |
| 120 | | `trigger-build` | Fix is in source code on the tracked branch — starts a new build | |
| 121 | |
| 122 | ## Examples |
| 123 | |
| 124 | ```bash |
| 125 | # List all environments |
| 126 | mcloud environments list --json |
| 127 | |
| 128 | # Get environment details and check type before deleting |
| 129 | mcloud environments get staging --json | jq '{id, name, type, status}' |
| 130 | |
| 131 | # Create a new environment tracking the develop branch |
| 132 | mcloud environments create --name "Staging" --branch develop --json |
| 133 | |
| 134 | # Delete a non-production environment |
| 135 | mcloud environments delete staging --yes |
| 136 | |
| 137 | # Redeploy after a variable change |
| 138 | mcloud environments redeploy production --json |
| 139 | |
| 140 | # Trigger a fresh build from source |
| 141 | mcloud environments trigger-build production --json |
| 142 | |
| 143 | # Find environment handles by name |
| 144 | mcloud environments list --json \ |
| 145 | | jq -r '.[] | select(.name == "Production") | .handle' |
| 146 | |
| 147 | # Verify new build started |
| 148 | mcloud deployments list --environment production --limit 5 --json \ |
| 149 | | jq '.[] | {id, backend_status, updated_at}' |
| 150 | ``` |