mcloud-variables

作者: medusajs

執行 mcloud variables 指令,列出並取得雲端環境的環境變數。用於檢查、讀取或匯出環境…

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

Cloud CLI: Variables Commands

Execute mcloud variables commands to inspect and manage environment variables for Cloud environments.

Constraints

  • Never pass --reveal unless the user explicitly asks. Secret values appear in terminal scrollback, log aggregators, and process listings.
  • Variable changes need a deploy to apply. set/delete don't rebuild or redeploy. Run mcloud environments redeploy <env> for a runtime variable, or mcloud environments trigger-build <env> for a build variable (a redeploy reuses the existing image and won't pick up build-variable changes).
  • System variables can't be deleted, and delete requires --yes in non-interactive mode.
  • Looking up or creating a variable by key requires --project and --environment (or the equivalent in active context). Referencing by ID (var_...) works without project/environment context.
  • set and delete require mcloud CLI v0.1.10+.

Commands

variables list

List all environment variables for a Cloud environment.

mcloud variables list \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --environment <environment-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)
  • -e/--environment <handle> — Environment handle (falls back to active context)
  • -t/--type <backend|storefront> — Which variable set to list (default: backend)
  • --scope <build|runtime> — Filter by scope; repeatable (default: both scopes)
  • --include-system — Include system variables Medusa auto-injects (default: false)
  • --reveal — Print secret values in plaintext instead of masking (use only when explicitly asked)
  • --dotenv — Output .env-formatted KEY=VALUE lines instead of a table
  • --json — Output as JSON

variables get

Retrieve a single variable by its ID (var_...) or key.

# By key (requires project + environment context)
mcloud variables get ADMIN_CORS \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --environment <environment-handle> \
  --json

# By ID (works without project/environment context)
mcloud variables get var_01XYZ --json

Arguments:

  • variable — Variable ID (var_...) or key (required)

Options:

  • -o/--organization <id>, -p/--project <id-or-handle>, -e/--environment <handle>
  • -t/--type <backend|storefront> — Which variable set to read (default: backend)
  • --reveal — Print secret value in plaintext (use only when explicitly asked)
  • --json — Output as JSON

variables set

Create or update one or more variables. The CLI updates when you reference an existing key or a var_... ID, and creates otherwise.

# Single variable
mcloud variables set API_KEY pk_123 \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --environment <environment-handle>

# Multiple at once
mcloud variables set -v API_KEY=pk_123 -v CLIENT_ID=my_app

# From a .env file
mcloud variables set --env-file .env

Arguments:

  • variable — Variable ID (var_...) or key to set (omit when using --var/--env-file)
  • value — Value to set (required when a variable argument is passed)

Options:

  • -o/--organization <id>, -p/--project <id-or-handle>, -e/--environment <handle>
  • -t/--type <backend|storefront> — Which variable set to write (default: backend)
  • -v/--var <KEY=VALUE|ID=VALUE> — A variable to set; repeatable
  • --env-file <path> — Set all variables from a .env file
  • --secret, --no-secret — Mark as secret (default: false for new variables)
  • --build, --no-build — Available at build time (default: false for new variables)
  • --runtime, --no-runtime — Available at runtime (default: true for new variables)
  • --json — Output as JSON

Redeploy (runtime) or trigger-build (build) afterward — see Constraints.

variables delete

Delete a variable by its ID (var_...) or key. Irreversible; system variables can't be deleted.

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

Arguments:

  • variable — Variable ID (var_...) or key to delete (required)

Options:

  • -o/--organization <id>, -p/--project <id-or-handle>, -e/--environment <handle>
  • -t/--type <backend|storefront> — Which variable set to delete from (default: backend)
  • -y/--yes — Skip confirmation prompt (required in non-interactive mode)
  • --json — Output as JSON

Variable Fields (JSON)

FieldDescription
idVariable ID (var_...)
keyVariable name (e.g. ADMIN_CORS)
valueVariable value (masked if is_secret and --reveal not passed)
is_secretWhether the variable is treated as a secret
is_buildAvailable at build time
is_runtimeAvailable at runtime
environment_idThe environment ID this variable belongs to
sourceuser for user-set variables, system for auto-injected ones

Examples

# List all variables for the active environment
mcloud variables list --json

# List only runtime variables, including system ones
mcloud variables list --scope runtime --include-system --json

# List storefront variables
mcloud variables list --type storefront --json

# Get a variable by key (with active context)
mcloud variables get DATABASE_URL --json

# Get a variable by ID (no env context needed)
mcloud variables get var_01XYZ --json

# Set a single variable, then redeploy to apply (runtime)
mcloud variables set REDIS_URL redis://cache:6379
mcloud environments redeploy production

# Set a secret build-only variable, then trigger a build to apply
mcloud variables set STRIPE_SECRET_KEY sk_live_123 --secret --build --no-runtime
mcloud environments trigger-build production

# Set multiple variables from a .env file
mcloud variables set --env-file .env

# Delete a variable (irreversible — confirm before running)
mcloud variables delete OLD_FLAG --yes

# Only reveal secrets when user explicitly asks
mcloud variables get STRIPE_SECRET_KEY --reveal --json | jq -r '.value'

# Export all variables to a .env file (user must explicitly request --reveal)
mcloud variables list --reveal --dotenv > .env

# Check if a specific variable exists
mcloud variables list --json | jq '.[] | select(.key == "REDIS_URL")'

來自 medusajs 的更多技能

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
building-with-medusa
medusajs
Medusa後端架構、工作流程及關鍵實作規則的全面指南。涵蓋六大規則類別(架構、型別安全、商業邏輯放置、匯入、資料存取、檔案組織),包含具體的反模式與強制檢查。嚴格執行分層分離:模組 → 工作流程 → API路由 → 前端,所有變更操作必須透過工作流程,且僅允許GET/POST/DELETE HTTP方法。包含關鍵資料處理規則:價格按原樣儲存...
official