mcloud-local

Ejecuta la compilación local de mcloud para reproducir una compilación de Cloud en la máquina local. Úsalo al depurar una implementación con error de compilación sin enviar cambios a la rama rastreada,…

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

Más skills de medusajs

creating-agents-in-medusa
medusajs
Usar al crear un agente de IA interno orientado a administración en un proyecto de Medusa. Estos agentes son operados por comerciantes y operadores de tienda, no por clientes. Cubre…
reviewing-prs
medusajs
Revisa las solicitudes de extracción de GitHub para el repositorio de Medusa. Verifica el cumplimiento de la plantilla de PR, las directrices de contribución, las convenciones de código, la seguridad, el rendimiento y…
writing-releases
medusajs
Escribe notas de versión de GitHub para los lanzamientos de Medusa siguiendo el estilo establecido. Se utiliza al generar un borrador de descripción de versión a partir de una lista de commits y PR…
writing-tsdocs
medusajs
Añade y actualiza comentarios TypeDoc (TSDoc) en archivos fuente TypeScript en el codebase de Medusa. Cubre tipos HTTP, rutas de API, componentes de UI, modelos de datos, servicio…
mcloud-variables
medusajs
Ejecuta comandos de variables mcloud para listar y obtener variables de entorno de un entorno Cloud. Úsalo al inspeccionar, leer o exportar variables de entorno…
mcloud-deployments
medusajs
Ejecuta comandos de mcloud deployments para listar despliegues, obtener detalles de despliegues y recuperar registros de compilación. Úsalo al listar despliegues, verificar el estado de un despliegue…
writing-docs
medusajs
Escribe y actualiza archivos MDX de documentación de Medusa para los proyectos book, resources, ui, user-guide y cloud. Úsalo al realizar cambios de documentación basados en…
building-storefronts
medusajs
Integración frontend basada en SDK para storefronts de Medusa con patrones de React Query y reglas críticas de llamadas a la API. Siempre usa el SDK de Medusa JS para todas las solicitudes a la API, nunca uses fetch() normal, ya que carece de los encabezados requeridos (clave de API publicable para rutas de tienda, autenticación para rutas de administración). Pasa objetos JavaScript simples a los métodos del SDK; nunca uses JSON.stringify() en los parámetros del cuerpo, ya que el SDK maneja la serialización automáticamente. Usa useQuery para solicitudes GET y useMutation para solicitudes POST/DELETE,...