mcloud-local

Jalankan build lokal mcloud untuk mereproduksi build Cloud di mesin lokal. Gunakan saat men-debug deployment yang gagal build tanpa push ke branch yang dilacak, …

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

Cloud CLI: Local Command

Execute mcloud local build to run a Cloud build on the local machine, mirroring how Cloud builds the project. Use it to debug build-failed deployments without pushing changes and waiting for a full Cloud build.

Constraints

  • No --json flag. local build streams plaintext build output and signals the result through its exit code (0 = success). Do not parse its output as JSON.
  • Requires Docker installed and running, and must run from inside the project's Git repository.
  • Reproduces build-failed (build) failures only — not deployment-failed (runtime) failures. For runtime failures, use mcloud logs --deployment <id>.
  • Available since mcloud CLI v0.1.10.
  • The Docker build cache is disabled by default so variable changes always invalidate the cache; pass --docker-cache to enable it.

Command

local build

Run a Cloud build locally. Infers the root path and build variables from the linked Cloud project and environment. Builds the backend by default; pass --type storefront for the storefront.

mcloud local build \
  --organization <org-id> \
  --project <project-id-or-handle> \
  --environment <environment-handle>

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 whose variables are used (falls back to active context)
  • -t/--type <backend|storefront> — Build type (default: backend)
  • --root-path <path> — Backend root path relative to the repo root (inferred if omitted; . if no Cloud project found)
  • --storefront-path <path> — Storefront path relative to the repo root, for --type storefront (inferred if omitted)
  • --env-file <path> — Use a local .env file instead of the Cloud environment's variables
  • -v/--var <KEY=VALUE> — Override a single build variable; repeatable
  • --docker-cache — Enable the Docker build cache (default: false)

Output:

  • On success (exit 0), the backend image is tagged <repository-name>:cloud-local-build-<commit-hash>; a storefront build writes its output directory and prints the path.
  • On failure (non-zero exit), the command exits with the failing step's error — debug it as you would a Cloud build.

Reproduce a Build Failure

Check out the same commit the failed deployment built so the local build matches, then route on the exit code:

# Identify the failing deployment and the commit it built
DEPLOYMENT_ID=$(
  mcloud deployments list --json \
    | jq -r '[.[] | select(.backend_status == "build-failed")][0].id'
)
COMMIT=$(mcloud deployments get "$DEPLOYMENT_ID" --json | jq -r '.commit_hash')

git checkout "$COMMIT"

if mcloud local build; then
  echo "Build succeeded locally; failure not reproducible from this commit."
else
  echo "Build failed locally; inspect the streamed output for the failing step."
fi

Once the local build exits 0, push the fix to the tracked branch and start a fresh Cloud build with mcloud environments trigger-build <env>.

Examples

# Reproduce the backend build for the active context
mcloud local build

# Reproduce the storefront build
mcloud local build --type storefront --storefront-path apps/storefront

# Test a build-variable fix without editing code
mcloud local build --var NODE_ENV=production

# Build against a local .env file
mcloud local build --env-file .env

# Reuse the Docker cache for a faster rebuild
mcloud local build --docker-cache

Lebih banyak skill dari medusajs

mcloud-variables
medusajs
Jalankan perintah mcloud variables untuk mendaftar dan mendapatkan variabel lingkungan untuk lingkungan Cloud. Gunakan saat memeriksa, membaca, atau mengekspor lingkungan…
official
building-storefronts
medusajs
Integrasi frontend berbasis SDK untuk storefront Medusa dengan pola React Query dan aturan pemanggilan API yang kritis. Selalu gunakan Medusa JS SDK untuk semua permintaan API—jangan pernah menggunakan fetch() biasa, karena tidak memiliki header yang diperlukan (kunci API yang dapat dipublikasikan untuk rute toko, autentikasi untuk rute admin). Berikan objek JavaScript biasa ke metode SDK; jangan pernah menggunakan JSON.stringify() pada parameter body, karena SDK menangani serialisasi secara otomatis. Gunakan useQuery untuk permintaan GET dan useMutation untuk permintaan POST/DELETE,...
official
building-admin-dashboard-customizations
medusajs
Ekstensi UI kustom untuk dasbor Admin Medusa menggunakan Admin SDK dan komponen UI Medusa. Muat skill ini TERLEBIH DAHULU untuk pekerjaan UI admin apa pun (perencanaan, implementasi, eksplorasi); server MCP hanya menyediakan referensi API, bukan pola desain atau strategi pemuatan data KRITIS: Selalu gunakan Medusa JS SDK untuk semua permintaan API (jangan pernah menggunakan fetch biasa); pisahkan kueri tampilan dari kueri modal dan invalidasi data tampilan setelah mutasi Implementasikan widget pada halaman yang ada atau buat rute UI kustom;...
official
learning-medusa
medusajs
Bootcamp pengembangan Medusa interaktif langkah demi langkah di mana Anda membangun fitur merek sambil mempelajari pola arsitektur. Tiga pelajaran progresif (total 2–3 jam) mencakup modul, alur kerja, rute API, tautan modul, kait alur kerja, dan kustomisasi antarmuka admin. Verifikasi titik pemeriksaan setelah setiap komponen utama menguji pemahaman konseptual, kualitas kode, dan fungsionalitas sebelum melanjutkan. Memperlakukan kesalahan sebagai peluang mengajar; melakukan debugging bersama dengan pertanyaan diagnostik dan akar penyebab...
official
db-migrate
medusajs
Jalankan migrasi database Medusa yang tertunda dan laporkan hasilnya. Menjalankan npx medusa db:migrate melalui Bash untuk menerapkan semua migrasi yang tertunda ke database Medusa Anda. Melaporkan hasil migrasi termasuk jumlah migrasi yang diterapkan, kesalahan yang ditemui, dan konfirmasi keberhasilan. Dirancang untuk proyek Medusa dengan pengaturan npm/npx standar.
official
mcloud-environments
medusajs
Jalankan perintah mcloud environments untuk mendaftar, mendapatkan, membuat, menghapus, menyebarkan ulang, atau memicu build untuk lingkungan Cloud. Gunakan saat mengelola siklus hidup lingkungan,…
official
db-generate
medusajs
Hasilkan migrasi database untuk modul Medusa dengan satu perintah. Membungkus perintah CLI npx medusa db:generate untuk membuat file migrasi bagi modul Medusa yang ditentukan. Menerima nama modul sebagai argumen dan melaporkan lokasi file migrasi, kesalahan, serta langkah selanjutnya. Secara otomatis menyarankan menjalankan npx medusa db:migrate setelah pembuatan untuk menerapkan migrasi.
official
mcloud-deployments
medusajs
Jalankan perintah mcloud deployments untuk menampilkan daftar deployment, mengambil detail deployment, dan mengambil log build. Gunakan saat menampilkan daftar deployment, memeriksa deployment…
official