Token导航 LogoToken导航

Agent Skill · 前端设计

medusa-development(美杜莎发育)

medusa-development 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

medusa-development 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描有提醒项,按安装量在前端设计类的 10,216 个 Skill 里排第 6,853。

总安装 447周安装 19GitHub Stars 19下载 157核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:medusa-development(美杜莎发育)
来源仓库:https://github.com/finsilabs/awesome-ecommerce-skills
仓库路径:skills/medusa-development
安装命令:
npx skills add https://github.com/finsilabs/awesome-ecommerce-skills --skill medusa-development
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/finsilabs/awesome-ecommerce-skills --skill medusa-development

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

medusa-development 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合围绕仓库状态进行整理。适用于需要了解项目进展、代码变更或协作事项的场景。可通过仓库路径或 Issue 编号获取相关信息,支持结构化输出。安装前需确认权限范围,注意是否会触发联网或文件读写操作。

适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/medusa-development

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/finsilabs/awesome-ecommerce-skills --skill med…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

medusa-development 怎么安装?

在终端执行 npx skills add https://github.com/finsilabs/awesome-ecommerce-skills --skill medusa-develo…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

medusa-development 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

medusa-development 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

medusa-development 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

medusa-development 用的人多吗?

公开数据是累计安装 447 次,近一周安装 19 次,下载 157 次,GitHub 19 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

medusa-development 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
medusa-development

美杜莎发育 · 本页

44719需要联网未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Medusa.js Development

Overview

Build and extend headless e-commerce backends with Medusa.js using custom services, subscribers (event handlers), API route extensions, custom entities with migrations, and module architecture. This skill covers Medusa v2 project setup, the dependency injection container, custom workflows, admin UI extensions, and integration patterns for connecting Medusa to storefronts, ERPs, and payment providers.

When to Use This Skill

  • When setting up a new headless e-commerce backend with Medusa
  • When building custom business logic as Medusa services and workflows
  • When extending the Medusa API with custom endpoints for storefront or admin use
  • When implementing event-driven automation via subscribers (e.g., send email on order placed)
  • When integrating external systems (ERP, CMS, fulfillment) with Medusa

Prerequisites & Platform Notes

This skill is written for custom/headless storefronts (Node.js, Python, or similar backend). The code examples use TypeScript/Node.js and can be adapted to any stack.

Shopify: Shopify Hydrogen is Shopify's headless framework. MACH/composable patterns apply when using Shopify as the commerce backend with a custom frontend, or when mixing Shopify with other best-of-breed services. WooCommerce: WooCommerce can serve as a headless backend via its REST API and WPGraphQL. These patterns apply when decoupling the frontend from WordPress. Magento: Magento's GraphQL API and PWA Studio support headless architectures. These composable patterns apply to Magento as a backend service in a MACH stack.

You'll need:

  • Node.js 18+ (or adapt to your backend language)
  • PostgreSQL (or your preferred relational database)
  • Redis for caching/queues
  • Stripe account and API keys
  • An email sending service (SendGrid, AWS SES, or Postmark)

Core Instructions

  1. Set up a Medusa project # Create a new Medusa project npx create-medusa-app@latest my-store # Project structure (Medusa v2) # my-store/ # ├── src/ # │ ├── api/ # Custom API routes # │ ├── jobs/ # Scheduled jobs # │ ├── links/ # Module links # │ ├── modules/ # Custom modules # │ ├── subscribers/ # Event subscribers # │ └── workflows/ # Custom workflows # ├── medusa-config.ts # └── package.json # Start the development server npx medusa develop Configure medusa-config.ts: import {defineConfig, loadEnv} from '@medusajs/framework/utils'; loadEnv(process.env.NODE_ENV || 'development', process.cwd()); export default defineConfig({projectConfig: {databaseUrl: process.env.DATABASE_URL, redisUrl: process.env.REDIS_URL, http: {storeCors: process.env.STORE_CORS || 'http://localhost:8000', adminCors: process.env.ADMIN_CORS || 'http://localhost:9000', authCors: process.env.AUTH_CORS || 'http://localhost:8000,http://localhost:9000',},}, modules: [// Register custom modules here],});
  2. Create a custom module with a service ` // src/modules/loyalty/service.ts import {MedusaService} from '@medusajs/framework/utils'; import {LoyaltyPoints} from './models/loyalty-points'; class LoyaltyModuleService extends MedusaService({LoyaltyPoints,}) {async awardPoints(customerId: string, points: number, reason: string) {return await this.createLoyaltyPointss({customer_id: customerId, points, reason, type: 'earned',});} async redeemPoints(customerId: string, points: number) {const balance = await this.getBalance(customerId); if (balance < points) {throw new Error(Insufficient points. Balance: ${balance}, requested: ${points});} return await this.createLoyaltyPointss({customer_id: customerId, points: -points, reason: 'redeemed', type: 'redeemed',});} async getBalance(customerId: string): Promise<number> {const records = await this.listLoyaltyPointss({customer_id: customerId,}); return records.reduce((sum, r) => sum + r.points, 0);}} export default LoyaltyModuleService; Define the data model: // src/modules/loyalty/models/loyalty-points.ts import {model} from '@medusajs/framework/utils'; export const LoyaltyPoints = model.define('loyalty_points', {id: model.id().primaryKey(), customer_id: model.text(), points: model.number(), reason: model.text(), type: model.enum(['earned', 'redeemed', 'adjusted']),}); Register the module: // src/modules/loyalty/index.ts import LoyaltyModuleService from './service'; import {Module} from '@medusajs/framework/utils'; export const LOYALTY_MODULE = 'loyaltyModuleService'; export default Module(LOYALTY_MODULE, {service: LoyaltyModuleService,});`
  3. Create event subscribers ` // src/subscribers/order-placed.ts import type {SubscriberArgs, SubscriberConfig} from '@medusajs/framework'; import {Modules} from '@medusajs/framework/utils'; import {LOYALTY_MODULE} from '../modules/loyalty'; export default async function orderPlacedHandler({event, container,}: SubscriberArgs<{id: string}>) {const orderId = event.data.id; const orderService = container.resolve(Modules.ORDER); const loyaltyService = container.resolve(LOYALTY_MODULE); const logger = container.resolve('logger'); try {const order = await orderService.retrieveOrder(orderId, {relations: ['items'],}); // Award 1 point per dollar spent const pointsToAward = Math.floor(order.total / 100); if (order.customer_id && pointsToAward > 0) {await loyaltyService.awardPoints(order.customer_id, pointsToAward, Order ${order.display_id}); logger.info(Awarded ${pointsToAward} loyalty points for order ${order.display_id});}} catch (error) {logger.error(Failed to award loyalty points for order ${orderId}: ${error.message});}} export const config: SubscriberConfig = {event: 'order.placed',}; `
  4. Add custom API routes // src/api/store/loyalty/route.ts import type {MedusaRequest, MedusaResponse} from '@medusajs/framework/http'; import {LOYALTY_MODULE} from '../../../modules/loyalty'; // GET /store/loyalty — get current customer's loyalty balance export async function GET(req: MedusaRequest, res: MedusaResponse) {const customerId = req.auth_context?.actor_id; if (!customerId) {return res.status(401).json({message: 'Authentication required'});} const loyaltyService = req.scope.resolve(LOYALTY_MODULE); const balance = await loyaltyService.getBalance(customerId); const history = await loyaltyService.listLoyaltyPointss({customer_id: customerId}, {order: {created_at: 'DESC'}, take: 20}); res.json({balance, history});} // POST /store/loyalty/redeem — redeem points for a discount export async function POST(req: MedusaRequest, res: MedusaResponse) {const customerId = req.auth_context?.actor_id; if (!customerId) {return res.status(401).json({message: 'Authentication required'});} const {points} = req.body as {points: number}; if (!points || points <= 0) {return res.status(400).json({message: 'Invalid points amount'});} const loyaltyService = req.scope.resolve(LOYALTY_MODULE); try {const record = await loyaltyService.redeemPoints(customerId, points); const newBalance = await loyaltyService.getBalance(customerId); res.json({redeemed: points, newBalance, record});} catch (error) {res.status(400).json({message: error.message});}}
  5. Build custom workflows // src/workflows/award-loyalty-points.ts import {createWorkflow, createStep, StepResponse,} from '@medusajs/framework/workflows-sdk'; import {LOYALTY_MODULE} from '../modules/loyalty'; const validatePointsStep = createStep('validate-points', async ({customerId, points}: {customerId: string; points: number}) => {if (!customerId) throw new Error('Customer ID required'); if (points <= 0) throw new Error('Points must be positive'); return new StepResponse({customerId, points});}); const awardPointsStep = createStep('award-points', async ({customerId, points, reason}: {customerId: string; points: number; reason: string}, {container}) => {const loyaltyService = container.resolve(LOYALTY_MODULE); const record = await loyaltyService.awardPoints(customerId, points, reason); return new StepResponse(record, {recordId: record.id});}, // Compensation function for rollback async ({recordId}, {container}) => {const loyaltyService = container.resolve(LOYALTY_MODULE); await loyaltyService.deleteLoyaltyPoints(recordId);}); export const awardLoyaltyPointsWorkflow = createWorkflow('award-loyalty-points', (input: {customerId: string; points: number; reason: string}) => {const validated = validatePointsStep(input); const record = awardPointsStep({customerId: validated.customerId, points: validated.points, reason: input.reason,}); return record;});
  6. Create a scheduled job ` // src/jobs/expire-loyalty-points.ts import type {MedusaContainer} from '@medusajs/framework/types'; import {LOYALTY_MODULE} from '../modules/loyalty'; export default async function expireLoyaltyPointsJob(container: MedusaContainer) {const loyaltyService = container.resolve(LOYALTY_MODULE); const logger = container.resolve('logger'); // Find points older than 12 months const expirationDate = new Date(); expirationDate.setFullYear(expirationDate.getFullYear() - 1); const expiredRecords = await loyaltyService.listLoyaltyPointss({type: 'earned', created_at: {$lt: expirationDate},}); let expiredCount = 0; for (const record of expiredRecords) {if (record.points > 0) {await loyaltyService.createLoyaltyPointss({customer_id: record.customer_id, points: -record.points, reason: Expired: original from ${record.created_at}, type: 'adjusted',}); expiredCount++;}} logger.info(Expired ${expiredCount} loyalty point records.);} export const config = {name: 'expire-loyalty-points', schedule: '0 2 * * *', // Daily at 2 AM}; `

Examples

Connecting a Next.js storefront

// storefront/lib/medusa-client.ts
import Medusa from '@medusajs/js-sdk';

const medusa = new Medusa({
  baseUrl: process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL || 'http://localhost:9000',
  auth: {
    type: 'session',
  },
});

// Fetch products for a collection page
export async function getProducts(collectionId?: string) {
  const { products, count } = await medusa.store.product.list({
    collection_id: collectionId ? [collectionId] : undefined,
    limit: 24,
    fields: '+variants.calculated_price',
  });
  return { products, count };
}

// Add item to cart
export async function addToCart(cartId: string, variantId: string, quantity: number) {
  const { cart } = await medusa.store.cart.createLineItem(cartId, {
    variant_id: variantId,
    quantity,
  });
  return cart;
}

// Fetch loyalty balance (custom endpoint)
export async function getLoyaltyBalance() {
  const response = await fetch(
    `${process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL}/store/loyalty`,
    { credentials: 'include' }
  );
  if (!response.ok) throw new Error('Failed to fetch loyalty balance');
  return response.json();
}

Custom payment provider module

// src/modules/custom-payment/service.ts
import {
  AbstractPaymentProvider,
} from '@medusajs/framework/utils';
import type {
  CreatePaymentProviderSession,
  UpdatePaymentProviderSession,
  ProviderWebhookPayload,
  WebhookActionResult,
} from '@medusajs/framework/types';

class CustomPaymentProviderService extends AbstractPaymentProvider<{}> {
  static identifier = 'custom-payment';

  async initiatePayment(
    data: CreatePaymentProviderSession
  ): Promise<Record<string, unknown>> {
    // Call your payment gateway's API to create a payment session
    const response = await fetch('https://api.custompay.com/v1/sessions', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.CUSTOM_PAYMENT_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        amount: data.amount,
        currency: data.currency_code,
        metadata: { medusa_cart_id: data.context.cart_id },
      }),
    });
    const session = await response.json();

    return { session_id: session.id, client_token: session.client_token };
  }

  async authorizePayment(
    paymentSessionData: Record<string, unknown>
  ): Promise<{ status: string; data: Record<string, unknown> }> {
    const sessionId = paymentSessionData.session_id as string;

    const response = await fetch(
      `https://api.custompay.com/v1/sessions/${sessionId}`,
      {
        headers: { 'Authorization': `Bearer ${process.env.CUSTOM_PAYMENT_API_KEY}` },
      }
    );
    const session = await response.json();

    return {
      status: session.status === 'paid' ? 'authorized' : 'pending',
      data: { ...paymentSessionData, gateway_status: session.status },
    };
  }

  async capturePayment(
    paymentSessionData: Record<string, unknown>
  ): Promise<Record<string, unknown>> {
    const sessionId = paymentSessionData.session_id as string;

    await fetch(`https://api.custompay.com/v1/sessions/${sessionId}/capture`, {
      method: 'POST',
      headers: { 'Authorization': `Bearer ${process.env.CUSTOM_PAYMENT_API_KEY}` },
    });

    return { ...paymentSessionData, captured: true };
  }

  async refundPayment(
    paymentSessionData: Record<string, unknown>,
    refundAmount: number
  ): Promise<Record<string, unknown>> {
    const sessionId = paymentSessionData.session_id as string;

    await fetch(`https://api.custompay.com/v1/sessions/${sessionId}/refund`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${process.env.CUSTOM_PAYMENT_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ amount: refundAmount }),
    });

    return { ...paymentSessionData, refunded_amount: refundAmount };
  }

  async cancelPayment(
    paymentSessionData: Record<string, unknown>
  ): Promise<Record<string, unknown>> {
    return { ...paymentSessionData, cancelled: true };
  }

  async deletePayment(
    paymentSessionData: Record<string, unknown>
  ): Promise<Record<string, unknown>> {
    return {};
  }

  async getPaymentStatus(
    paymentSessionData: Record<string, unknown>
  ): Promise<string> {
    return (paymentSessionData.gateway_status as string) || 'pending';
  }

  async getWebhookActionAndData(
    payload: ProviderWebhookPayload
  ): Promise<WebhookActionResult> {
    const event = JSON.parse(payload.rawData as string);

    switch (event.type) {
      case 'payment.captured':
        return { action: 'captured', data: { session_id: event.session_id } };
      case 'payment.failed':
        return { action: 'failed', data: { session_id: event.session_id } };
      default:
        return { action: 'not_supported' };
    }
  }
}

export default CustomPaymentProviderService;

Best Practices

  • Use the module system for encapsulation -- each domain (loyalty, custom fulfillment, analytics) should be its own module with its own service, models, and migrations
  • Always add compensation functions to workflow steps -- if a step can fail, the compensation function rolls back the previous step's side effects for clean error recovery
  • Resolve dependencies from the container, not with imports -- use container.resolve() for services to respect the DI configuration and enable testing
  • Use subscribers for side effects, not core logic -- subscribers should trigger notifications, sync external systems, and log events; keep order processing in workflows
  • Validate API input with Zod -- define Zod schemas for request bodies and use middleware to validate before the handler runs
  • Write migrations for schema changes -- never modify the database manually; use Medusa's migration system so changes are reproducible across environments
  • Use the Medusa Admin SDK for admin extensions -- extend the admin dashboard with custom widgets using the @medusajs/admin-sdk package instead of building separate UIs
  • Pin your Medusa version -- Medusa v2 is evolving rapidly; lock the version in package.json and test before upgrading

Common Pitfalls

ProblemSolution
Custom module not found at runtimeRegister it in medusa-config.ts under the modules array and run npx medusa db:migrate to apply any model changes
Subscriber fires but data is staleSubscribers run asynchronously; re-fetch the entity inside the subscriber handler rather than relying on event payload data
API route returns 404Ensure the file path matches the URL pattern: src/api/store/loyalty/route.ts maps to /store/loyalty; check for missing export on the handler function
Workflow step fails without rollbackEvery step that has side effects needs a compensation function as the second argument to createStep
Database migration conflicts after mergeRun npx medusa db:migrate after pulling changes; if migrations conflict, generate a new migration that resolves the diff
CORS errors from storefrontConfigure storeCors in medusa-config.ts to include your storefront's origin URL including the port

Related Skills

  • @product-data-modeling
  • @stripe-integration
  • @ecommerce-caching
  • @ecommerce-seo
  • @erp-integration

平台分布

Codex

35.46%
按下载量换算56

Claude

29.53%
按下载量换算46

Cursor

19.22%
按下载量换算30

Gemini CLI

8.45%
按下载量换算13

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills