mcloud-environments

作者: medusajs

執行 mcloud environments 指令以列出、取得、建立、刪除、重新部署或觸發 Cloud 環境的建置。在管理環境生命週期時使用,…

npx skills add https://github.com/medusajs/medusa-agent-skills --skill mcloud-environments

Cloud CLI: Environments Commands

Execute mcloud environments commands to manage environment lifecycle and deployments.

Constraints

  • Production environments cannot be deleted. Always check type via environments get --json before attempting delete in automation.
  • Use --yes for destructive operations (delete) in non-interactive contexts.
  • redeploy vs trigger-build are not interchangeable — choose the right one based on where the fix is.

Commands

environments list

List all environments in a project.

mcloud environments list --organization <org-id> --project <project-id-or-handle> --json

Options:

  • -o/--organization <id> — Organization ID (falls back to active context)
  • -p/--project <id-or-handle> — Project ID or handle (falls back to active context)
  • --json — Output as JSON

environments get

Retrieve a single environment by its ID or handle.

mcloud environments get <environment-id-or-handle> --organization <org-id> --project <project-id-or-handle> --json

Arguments:

  • environment — Environment ID or handle (required)

Options:

  • -o/--organization <id>, -p/--project <id-or-handle>, --json

environments create

Create a new long-lived environment.

mcloud environments create \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --name "Staging" \
  --branch develop \
  --json

Options:

  • -o/--organization <id>, -p/--project <id-or-handle>
  • -n/--name <name> — Environment name (required)
  • -b/--branch <branch> — Git branch to track (required)
  • --custom-subdomain <subdomain> — Optional custom subdomain
  • --json — Output as JSON

environments delete

Delete an environment. Cannot delete production environments.

mcloud environments delete <environment-id-or-handle> \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --yes

Arguments:

  • environment — Environment ID or handle (required)

Options:

  • -o/--organization <id>, -p/--project <id-or-handle>
  • -y/--yes — Skip confirmation prompt (required in non-interactive mode)
  • --json — Output as JSON

environments redeploy

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.

mcloud environments redeploy <environment-id-or-handle> \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --json

Arguments:

  • environment — Environment ID or handle (required)

Options:

  • -o/--organization <id>, -p/--project <id-or-handle>, --json

Requires the environment to have an active deployment. If it doesn't, use trigger-build first.

environments trigger-build

Start a new build from the tracked branch. Use when the fix is committed code — creates a new deployment.

mcloud environments trigger-build <environment-id-or-handle> \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --json

Arguments:

  • environment — Environment ID or handle (required)

Options:

  • -o/--organization <id>, -p/--project <id-or-handle>, --json

Redeploy vs Trigger-Build Decision

CommandWhen to use
redeployFix is environment-side (variable change, infra config) — reruns existing build
trigger-buildFix is in source code on the tracked branch — starts a new build

Examples

# List all environments
mcloud environments list --json

# Get environment details and check type before deleting
mcloud environments get staging --json | jq '{id, name, type, status}'

# Create a new environment tracking the develop branch
mcloud environments create --name "Staging" --branch develop --json

# Delete a non-production environment
mcloud environments delete staging --yes

# Redeploy after a variable change
mcloud environments redeploy production --json

# Trigger a fresh build from source
mcloud environments trigger-build production --json

# Find environment handles by name
mcloud environments list --json \
  | jq -r '.[] | select(.name == "Production") | .handle'

# Verify new build started
mcloud deployments list --environment production --limit 5 --json \
  | jq '.[] | {id, backend_status, updated_at}'

來自 medusajs 的更多技能

mcloud-variables
medusajs
執行 mcloud variables 指令,列出並取得雲端環境的環境變數。用於檢查、讀取或匯出環境…
official
building-storefronts
medusajs
以SDK為優先的前端整合方式,適用於Medusa商店前端,採用React Query模式並遵循關鍵API呼叫規則。所有API請求必須使用Medusa JS SDK,絕不能使用一般的fetch(),因為它缺少必要的標頭(商店路由需要可發布的API金鑰,管理路由需要驗證資訊)。傳遞純JavaScript物件給SDK方法,切勿對主體參數使用JSON.stringify(),因為SDK會自動處理序列化。使用useQuery處理GET請求,使用useMutation處理POST/DELETE請求...
official
building-admin-dashboard-customizations
medusajs
使用管理員SDK和Medusa UI元件為Medusa管理後台自訂UI擴充功能。進行任何管理員UI工作(規劃、實作、探索)時,請優先載入此技能;MCP伺服器僅提供API參考,不包含設計模式或資料載入策略。關鍵:所有API請求務必使用Medusa JS SDK(絕不使用一般fetch);將顯示查詢與模態查詢分離,並在變更後使顯示資料失效。在現有頁面上實作小工具或建立自訂UI路由;...
official
learning-medusa
medusajs
互動式逐步Medusa開發訓練營,在建立品牌功能的同時學習架構模式。三個漸進式課程(總計2-3小時),涵蓋模組、工作流程、API路由、模組連結、工作流程鉤子及管理後台UI自訂。每個主要元件完成後設有檢查點驗證,測試概念理解、程式碼品質與功能正確性後才繼續進行。將錯誤視為教學機會,透過診斷問題與根本原因分析共同除錯...
official
db-migrate
medusajs
執行待處理的 Medusa 資料庫遷移並回報結果。透過 Bash 執行 npx medusa db:migrate 以將所有待處理的遷移套用至 Medusa 資料庫。回報遷移結果,包括已套用的遷移數量、遇到的任何錯誤以及成功確認。專為使用標準 npm/npx 設定的 Medusa 專案設計。
official
mcloud-environments
medusajs
執行 mcloud environments 指令,以列出、取得、建立、刪除、重新部署或觸發雲端環境的建置。適用於管理環境生命週期等情境。
official
db-generate
medusajs
以單一指令為 Medusa 模組生成資料庫遷移檔案。封裝 npx medusa db:generate CLI 指令,為指定的 Medusa 模組建立遷移檔案。接受模組名稱作為參數,並回報遷移檔案位置、錯誤及後續步驟。自動建議在生成後執行 npx medusa db:migrate 以套用遷移。
official
mcloud-deployments
medusajs
執行 mcloud deployments 指令以列出部署、取得部署詳細資訊,並擷取建置日誌。用於列出部署、檢查部署…
official