medusa-development

Extend Medusa v2 backends with custom services, subscribers, workflows, and API routes.

14|3|Updated Mar 22, 2026
One-click install
npx skills add https://github.com/tomtoto757/ecomm-ai-skills-hub --skill medusa-development-tomtoto757
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: medusa-development
Source: https://github.com/tomtoto757/ecomm-ai-skills-hub/tree/main/skills/platform-integrations-infrastructure/finsilabs/headless-modern/medusa-development
Command: npx skills add https://github.com/tomtoto757/ecomm-ai-skills-hub --skill medusa-development-tomtoto757

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enable engineers to extend Medusa.js backends with modular services, event subscribers, workflows, and custom API endpoints so business rules, integrations, and side-effectful processes are implemented reliably and maintainably.

Core Features & Use Cases

  • Custom module and service patterns using MedusaService and model.define for persistent domain logic and CRUD generation.
  • Event subscribers that re-fetch entities and trigger workflows for integration tasks such as notifying 3PLs, awarding loyalty points, or syncing with ERPs.
  • Custom storefront and admin API routes that use req.scope resolution, Zod validation, and clear HTTP method handlers.
  • Workflow design with compensation functions, scheduled jobs, and best practices for migrations, DI container resolution, and admin UI extensions.
  • Use case examples: a loyalty points module with subscribers and workflows, a scheduled job to expire points, and a custom payment provider module handling webhooks.

Quick Start

Create a Medusa v2 project, register a module in medusa-config.ts, add a subscriber that resolves services from the container, and implement a workflow step with a compensation function to handle side effects.

Frequently Asked Questions about medusa-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create custom API routes in Medusa v2?

To create custom API routes in Medusa v2, implement clear HTTP method handlers that utilize req.scope for DI container service resolution and apply Zod validation for request payloads to ensure reliable storefront and admin endpoints.

How do I build a custom module in Medusa v2 with database migrations?

Building a custom Medusa v2 module requires using model.define to establish persistent domain logic and MedusaService for CRUD generation. You must register the module in medusa-config.ts and follow best practices for managing database migrations.

How do I trigger workflows with event subscribers in Medusa?

Event subscribers in Medusa intercept entity events to trigger workflows for integration tasks. Subscribers re-fetch entities from the database and execute workflows for side effects like notifying 3PLs, awarding loyalty points, or syncing with ERPs.

What is the best way to handle side effects in Medusa workflows?

The best way to handle side effects in Medusa workflows is implementing workflow compensation functions. Compensation functions roll back side effects if a step fails, ensuring reliable process execution for scheduled jobs and external integrations.

Can I implement a custom payment provider in Medusa v2?

Yes, you can implement a custom payment provider in Medusa v2. Create a custom module specifically designed to handle payment processing logic and incoming webhook events from the payment gateway.

Does Medusa v2 support scheduled jobs for backend automation?

Yes, Medusa v2 supports scheduled jobs for backend automation. You can configure scheduled jobs to run at specific intervals, such as a scheduled job designed to automatically expire loyalty points over time.