mcloud-local

Execute mcloud local build to reproduce a Cloud build on the local machine. Use when debugging a build-failed deployment without pushing to the tracked branch,…

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

Mehr Skills von medusajs

mcloud-variables
medusajs
Führen Sie mcloud-Variablen-Befehle aus, um Umgebungsvariablen für eine Cloud-Umgebung aufzulisten und abzurufen. Verwenden Sie dies beim Überprüfen, Lesen oder Exportieren von Umgebungsvariablen…
official
building-storefronts
medusajs
SDK-first Frontend-Integration für Medusa-Storefronts mit React-Query-Mustern und kritischen API-Aufrufregeln. Verwenden Sie immer das Medusa JS SDK für alle API-Anfragen – niemals reguläres fetch(), da ihm die erforderlichen Header fehlen (publishable API-Key für Store-Routen, Auth für Admin-Routen). Übergeben Sie einfache JavaScript-Objekte an SDK-Methoden; verwenden Sie niemals JSON.stringify() für Body-Parameter, da das SDK die Serialisierung automatisch übernimmt. Verwenden Sie useQuery für GET-Anfragen und useMutation für POST/DELETE-Anfragen,...
official
building-admin-dashboard-customizations
medusajs
Benutzerdefinierte UI-Erweiterungen für das Medusa Admin Dashboard unter Verwendung des Admin SDK und der Medusa UI-Komponenten. Laden Sie diese Fähigkeit ZUERST für jegliche Admin-UI-Arbeit (Planung, Implementierung, Erkundung); MCP-Server dienen nur als API-Referenz, nicht als Designmuster oder Datenladestrategien. KRITISCH: Verwenden Sie immer das Medusa JS SDK für alle API-Anfragen (niemals reguläres fetch); trennen Sie Anzeigeabfragen von Modalabfragen und invalidieren Sie Anzeigedaten nach Mutationen. Implementieren Sie Widgets auf bestehenden Seiten oder erstellen Sie benutzerdefinierte UI-Routen;...
official
learning-medusa
medusajs
Interaktives Schritt-für-Schritt-Medusa-Entwicklungs-Bootcamp, bei dem du eine Markenfunktion aufbaust und gleichzeitig Architekturmuster lernst. Drei progressive Lektionen (insgesamt 2–3 Stunden) zu Modulen, Workflows, API-Routen, Modulverknüpfungen, Workflow-Hooks und Admin-UI-Anpassung. Checkpoint-Verifikation nach jeder Hauptkomponente testet konzeptionelles Verständnis, Codequalität und Funktionalität, bevor es weitergeht. Behandelt Fehler als Lernmöglichkeiten; debuggt gemeinsam mit diagnostischen Fragen und Ursachenanalyse...
official
db-migrate
medusajs
Führe ausstehende Medusa-Datenbankmigrationen aus und melde Ergebnisse. Führt npx medusa db:migrate über Bash aus, um alle ausstehenden Migrationen auf deine Medusa-Datenbank anzuwenden. Meldet Migrationsergebnisse einschließlich Anzahl der angewendeten Migrationen, aufgetretene Fehler und Erfolgsbestätigung. Entwickelt für Medusa-Projekte mit standardmäßiger npm/npx-Einrichtung.
official
mcloud-environments
medusajs
Führe mcloud environments-Befehle aus, um Cloud-Umgebungen aufzulisten, abzurufen, zu erstellen, zu löschen, neu bereitzustellen oder Builds auszulösen. Verwende dies bei der Verwaltung des Lebenszyklus von Umgebungen,…
official
db-generate
medusajs
Generieren Sie Datenbankmigrationen für Medusa-Module mit einem einzigen Befehl. Umschließt den npx medusa db:generate CLI-Befehl, um Migrationsdateien für angegebene Medusa-Module zu erstellen. Akzeptiert den Modulnamen als Argument und meldet den Speicherort der Migrationsdatei, Fehler und nächste Schritte. Schlägt automatisch vor, nach der Generierung npx medusa db:migrate auszuführen, um Migrationen anzuwenden.
official
mcloud-deployments
medusajs
Führen Sie mcloud deployments-Befehle aus, um Bereitstellungen aufzulisten, Bereitstellungsdetails abzurufen und Build-Logs abzurufen. Verwenden Sie dies beim Auflisten von Bereitstellungen, beim Überprüfen von Bereitstellungen…
official