using-medusa-cloud

作者: medusajs

通過 Cloud CLI (mcloud) 管理 Medusa Cloud 資源。在部署、調試部署、管理環境、環境變數或任何…時使用。

npx skills add https://github.com/medusajs/medusa-agent-skills --skill using-medusa-cloud

Managing Medusa Cloud Resources

Operational guide for AI agents managing Medusa Cloud infrastructure through the mcloud CLI. Covers setup, deployments, debugging, environments, and variables.

Constraints

  • Always pass --json when parsing CLI output. Plaintext output is for humans and may change without warning.
  • Confirm context before mutating. Run mcloud whoami --json before any state change.
  • Read before you write. Run a get or list before any delete, redeploy, or trigger-build.
  • Use --yes for destructive operations. delete commands (including variables delete) require --yes in non-interactive mode.
  • Variable changes need a deploy to apply. variables set/delete don't rebuild or redeploy: redeploy for runtime changes, trigger-build for build changes.
  • Production environments cannot be deleted. mcloud environments delete errors on production by design.
  • Never pass --reveal unless the user explicitly asks. Secret values appear in terminal scrollback and logs.
  • --json and --follow are incompatible. Use bounded time windows (--from/--to) with --json for programmatic log ingestion.

CRITICAL: Load Reference Files When Needed

Load these references based on what you're doing:

  • Setting up the CLI? → MUST load setup.md first
  • Debugging a failed deployment? → MUST load debugging-deployments.md first
  • Managing environments or variables? → MUST load environments-and-variables.md first

Minimum requirement: Load at least one reference file before executing multi-step workflows.

Quick Reference

Authentication Check

Always verify auth and scope before mutating state:

mcloud whoami --json | jq -e '.auth.kind != "none" and .organization.id != null'

Exit code 0 = authenticated and scoped. Non-zero = stop and ask the user.

Set Context Once

mcloud use \
  --organization org_123 \
  --project proj_123 \
  --environment production

CRITICAL: mcloud use without flags is interactive and fails in CI/Docker/piped input. Always pass flags.

Deployment Status Routing

Route on backend_status (or storefront_status):

StatusMeaningLogs to check
build-failedBuild step failedmcloud deployments build-logs <id>
deployment-failedRuntime crashed after buildmcloud logs --deployment <id>
timed-outExceeded time budgetBoth: build-logs first, then runtime logs

Redeployment Decision

CommandWhen to use
mcloud environments redeploy <env>Fix is environment-side (variable change, infra) — reruns existing build
mcloud environments trigger-build <env>Fix is in source code on the tracked branch — starts new build

Common Pitfalls

  • TTY-only commands. mcloud login, mcloud use (without flags), and delete without --yes require a TTY. They fail in CI, Docker, or piped input.
  • MCLOUD_TOKEN precedence. When set, file-based credentials are ignored and mcloud login is rejected. Unset it to switch accounts.
  • Personal vs org access keys. Personal keys require --organization; org keys are pre-scoped.
  • organizations list requires personal auth. Org access keys return 401 on this command.
  • Build IDs vs deployment IDs. depl_* = deployment ID; anything else = build ID (resolved to latest deployment). mcloud logs --deployment accepts both; other commands take build IDs only.
  • mcloud local build has no --json. It streams plaintext and reports success via its exit code (0 = success). Requires Docker and must run inside the project's Git repo. Use it to reproduce build-failed failures locally — see debugging-deployments.md.

Reference Files

setup.md                       - CLI installation, authentication, context setup
debugging-deployments.md       - Build/deployment failure recipes and log analysis
environments-and-variables.md  - Environment lifecycle and variable management

來自 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