using-medusa-cloud

โดย medusajs

จัดการทรัพยากร Medusa Cloud ผ่าน Cloud CLI (mcloud) ใช้เมื่อปรับใช้ แก้ไขข้อบกพร่องการปรับใช้ จัดการสภาพแวดล้อม ตัวแปรสภาพแวดล้อม หรืออื่นๆ…

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

Skills เพิ่มเติมจาก medusajs

mcloud-variables
medusajs
ดำเนินการคำสั่ง mcloud variables เพื่อแสดงรายการและรับตัวแปรสภาพแวดล้อมสำหรับสภาพแวดล้อมคลาวด์ ใช้เมื่อตรวจสอบ อ่าน หรือส่งออกสภาพแวดล้อม…
official
building-storefronts
medusajs
การผสานรวมฟรอนต์เอนด์แบบ SDK-first สำหรับร้านค้า Medusa ด้วยรูปแบบ React Query และกฎการเรียก API ที่สำคัญ ใช้ Medusa JS SDK สำหรับคำขอ API ทั้งหมดเสมอ—ห้ามใช้ fetch() ปกติเด็ดขาด เนื่องจากขาดส่วนหัวที่จำเป็น (publishable API key สำหรับเส้นทางร้านค้า, auth สำหรับเส้นทางผู้ดูแลระบบ) ส่งออบเจกต์ JavaScript ธรรมดาไปยังเมธอดของ SDK ห้ามใช้ JSON.stringify() กับพารามิเตอร์ body เพราะ SDK จัดการการทำให้เป็นอนุกรมโดยอัตโนมัติ ใช้ useQuery สำหรับคำขอ GET และ useMutation สำหรับคำขอ POST/DELETE,...
official
building-admin-dashboard-customizations
medusajs
ส่วนขยาย UI แบบกำหนดเองสำหรับแดชบอร์ด Medusa Admin โดยใช้ Admin SDK และคอมโพเนนต์ Medusa UI โหลดสกิลนี้ก่อนสำหรับงาน UI ของแอดมิน (การวางแผน การนำไปใช้ การสำรวจ); เซิร์ฟเวอร์ MCP ให้เฉพาะการอ้างอิง API เท่านั้น ไม่ใช่รูปแบบการออกแบบหรือกลยุทธ์การโหลดข้อมูล สำคัญ: ใช้ Medusa JS SDK สำหรับคำขอ API ทั้งหมดเสมอ (ห้ามใช้ fetch ปกติ); แยกคิวรีการแสดงผลออกจากคิวรีโมดอล และล้างข้อมูลการแสดงผลหลังจากการกลายพันธุ์ นำวิดเจ็ตไปใช้บนหน้าที่มีอยู่หรือสร้างเส้นทาง UI แบบกำหนดเอง;...
official
learning-medusa
medusajs
ค่ายฝึกพัฒนา Medusa แบบโต้ตอบทีละขั้นตอน ที่คุณจะสร้างฟีเจอร์แบรนด์ไปพร้อมกับเรียนรู้รูปแบบสถาปัตยกรรม ประกอบด้วยสามบทเรียนแบบต่อเนื่อง (รวม 2–3 ชั่วโมง) ครอบคลุมโมดูล เวิร์กโฟลว์ เส้นทาง API การเชื่อมโยงโมดูล ฮุคของเวิร์กโฟลว์ และการปรับแต่ง UI ของแอดมิน มีการตรวจสอบจุดเช็คพอยต์หลังจากแต่ละองค์ประกอบหลัก เพื่อทดสอบความเข้าใจเชิงแนวคิด คุณภาพโค้ด และฟังก์ชันการทำงานก่อนดำเนินการต่อ ปฏิบัติต่อข้อผิดพลาดเป็นโอกาสในการสอน แก้ไขข้อบกพร่องร่วมกันด้วยคำถามวินิจฉัยและการวิเคราะห์สาเหตุที่แท้จริง...
official
db-migrate
medusajs
ดำเนินการย้ายฐานข้อมูล Medusa ที่รออยู่และรายงานผลลัพธ์ รัน npx medusa db:migrate ผ่าน Bash เพื่อใช้การย้ายข้อมูลที่รออยู่ทั้งหมดไปยังฐานข้อมูล Medusa ของคุณ รายงานผลลัพธ์การย้ายข้อมูล รวมถึงจำนวนการย้ายข้อมูลที่ถูกนำไปใช้ ข้อผิดพลาดที่พบ และการยืนยันความสำเร็จ ออกแบบมาสำหรับโปรเจกต์ Medusa ที่มีการตั้งค่า npm/npx มาตรฐาน
official
mcloud-environments
medusajs
ดำเนินการคำสั่ง mcloud environments เพื่อแสดงรายการ รับข้อมูล สร้าง ลบ ปรับใช้ใหม่ หรือเรียกใช้บิลด์สำหรับสภาพแวดล้อม Cloud ใช้เมื่อจัดการวงจรชีวิตของสภาพแวดล้อม...
official
db-generate
medusajs
สร้างการย้ายฐานข้อมูลสำหรับโมดูล Medusa ด้วยคำสั่งเดียว ครอบคลุมคำสั่ง CLI npx medusa db:generate เพื่อสร้างไฟล์การย้ายสำหรับโมดูล Medusa ที่ระบุ รับชื่อโมดูลเป็นอาร์กิวเมนต์และรายงานตำแหน่งไฟล์การย้าย ข้อผิดพลาด และขั้นตอนถัดไป แนะนำให้รัน npx medusa db:migrate หลังจากสร้างเพื่อใช้การย้ายโดยอัตโนมัติ
official
mcloud-deployments
medusajs
Execute คำสั่ง mcloud deployments เพื่อแสดงรายการ deployments ดึงรายละเอียด deployment และดึง build logs ใช้เมื่อต้องการแสดงรายการ deployments ตรวจสอบ deployment…
official