Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Medusa Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-medusa-knowledge-patch)
---
name: medusa-knowledge-patch
description: Medusa
version: null
license: MIT
metadata:
author: Nevaberry
---
# Medusa compatibility guide
Load this skill when upgrading Medusa or changing its APIs, authentication,
commerce workflows, modules, Admin extensions, or runtime configuration.
Use the quick reference for migration-sensitive contracts and the topic files
for complete guidance, examples, and version-specific behavior.
## Reference index
| Reference | Topics |
| --- | --- |
| [Upgrades, runtime, and CLI](references/upgrades-runtime-and-cli.md) | Dependencies, Zod, migrations, scaffolding, configuration, logging, Cloud |
| [API, authentication, and SDK](references/api-auth-and-sdk.md) | OAuth, passwords, identities, middleware, HTTP types, refetch helpers, MCP |
| [Carts, orders, and workflows](references/carts-orders-and-workflows.md) | Checkout, retries, retention, order changes, draft orders, returns |
| [Payments, pricing, and promotions](references/payments-pricing-and-promotions.md) | Provider contracts, payment recovery, pricing hooks, discounts, budgets, Loyalty |
| [Fulfillment, inventory, shipping, and tax](references/fulfillment-inventory-shipping-and-tax.md) | Stock locations, reservations, kits, shipping profiles and options, tax providers |
| [Modules, modeling, and Query](references/modules-modeling-and-query.md) | Service types, links, catalog, CSV, experimental Index, Search, preview caching, Translations |
| [Events, notifications, and files](references/events-notifications-and-files.md) | Subscribers, priorities, compensation, notification channels, uploads |
| [Admin, plugins, and UI](references/admin-plugins-and-ui.md) | Plugin builds, routes, views, roles, UI dependencies, locales |
## Breaking changes and deprecations
### Dependency and validator upgrades
- From 2.11.0, remove direct dependencies on `@mikro-orm/core`,
`@mikro-orm/knex`, `@mikro-orm/migrations`, `@mikro-orm/postgresql`,
`@mikro-orm/cli`, `awilix`, and `pg`, then reinstall. The runtime supplies
these through `@medusajs/deps`.
- Update imports and `require` calls to `@medusajs/framework/mikro-orm/<subpath>`,
`@medusajs/framework/awilix`, and `@medusajs/framework/pg`. Use framework
OpenTelemetry exports for `instrumentation-pg`, `resources`, `sdk-node`,
and `sdk-trace-node`; see the upgrades reference for the export path.
- Use `@medusajs/framework/zod` to share the framework's Zod version and resolve
it under pnpm dependency isolation. The CLI can rewrite imports:
```sh
npx medusa codemod replace-zod-imports
```
- With the Zod v4 upgrade in 2.14.0, backends declaring `zod` directly should
install `4.2.0`. Use the unified `error` option, an explicit key schema for
`z.record`, and `z.treeifyError(err)` for nested errors.
- If you install `@medusajs/icons` directly and use an earlier React version,
upgrade to React 19 or pin Icons to an earlier release.
- If declared directly, update `react-router-dom` to `6.30.3` when upgrading.
Node.js 25 is incompatible with Next.js storefronts; use a supported Node.js version.
- Upgrade from 2.22.5 to 2.22.6 for security hardening with complete package
files, including the missing Yarn-packed Draft Order and Loyalty build output.
### Renamed fields and request contracts
- Replace `remoteLink` with `link`, `remoteQueryConfig` with `queryConfig`, and
`remote-query-entry-points.d.ts` with `query-entry-points.d.ts`.
- For `POST /admin/inventory-items/:id/location-levels/batch`, replace `creates`
and `deletes` with `create` and `delete`; `update` changes existing levels.
- Remove `region_id` references on Payment Collection and `cart_id`, `order_id`,
and `customer_id` references on Payment.
- Payment provider methods take a single typed input object. Throw provider
errors so the Payment Module can handle them; the payments reference lists
the affected required and optional methods.
- Replace `customer.account_holder` with `customer.account_holders`; select
the entry whose `provider_id` matches the payment provider in use.
- Remove `context` from the body of `POST /store/payment-collections/:id/payment-sessions`.
Provider context is restricted to known fields.
- Omit the body when marking a fulfillment delivered, including the body
argument to SDK `markAsDelivered` calls. Fulfillment creation through the Admin API or a workflow requires at least one item.
- Remove `fulfillment_status` and `payment_status` from order list requests and
typed filters. From 2.22.6, the order-list workflow includes line items only
when the caller explicitly requests `items`.
- `refetchEntity` and `refetchEntities` take an object with `entity`,
`idOrFilter`, `scope`, and `fields`. Both accept `options`; the plural helper
also accepts `pagination` and `withDeleted`.
- The SDK user-creation method was removed. Some request types also drop unused
`order_id`; remove it where rejected. See the API reference for all HTTP type changes.
### Authentication and ownership
- Send password-reset tokens in the `Authorization` header, removing the
`token` query parameter. Read `actor_type` in reset-password events; `actorType` was dropped.
```http
POST /auth/user/emailpass/update
Authorization: Bearer <reset-token>
```
- Send `callback_url` in the initial Google or GitHub authentication body to
select the actor's callback page. Forward every provider query parameter to
callback validation, including `code`, `state`, and `error` when present.
- When overriding `@medusajs/medusa/auth`, include `Modules.CACHE` in its
dependencies so it can temporarily store OAuth state.
- The `emailpass` provider requires the original password to re-register a
previously registered identity with no actor attached.
- Use the owning customer's identity for a customer-owned cart. Customer
account email must match the authenticated identity's email; account creation
skips that comparison when the identity has no email. Custom validation uses
`createCustomerAccountWorkflow.hooks.validate`.
- Route query `allowed` settings and `http.restrictedFields` strip disallowed
fields even when the RBAC feature flag is disabled. Admin roles with granular
permissions use the dedicated RBAC module and require an Enterprise license.
## Checkout and workflow quick reference
- From 2.23.1, cart completion requires a shipping method for every line item
whose variant is linked to a shipping profile. Custom checkouts must collect these methods.
- Assign a shipping profile when creating a product. The upgrade data migration
assigns all products to the default profile if a profile name contains `default`, ignoring case.
- `addToCartWorkflow` accepts variants only from published products. Carts
accept `unit_price: 0` for free custom items and explicit custom prices for unpriced variants.
- Checkout can finish without payment when the remaining balance is zero,
and it accepts payment sessions with status `captured`.
- Every cart workflow exposes a `validate` hook before its operation; throw to reject it:
```ts
import { completeCartWorkflow } from "@medusajs/medusa/core-flows"
completeCartWorkflow.hooks.validate(({ cart }) => {
if (!cart.metadata?.approved_at) {
throw new Error("Cannot complete unapproved cart")
}
})
```
- From 2.10.0, all cart workflows enable idempotency to prevent concurrent
mutations. With `idempotent: true`, executions are deduplicated while in progress;
completed executions are retained only with an explicit `retentionTime`.
- Specify `retentionTime` in seconds. An hourly job deletes executions exceeding it.
If a millisecond value causes a PostgreSQL integer-cast error during migration,
run the migration manually with the corrected value.
- Use `retryIntervalAwaiting` and `maxAwaitingRetries` for the retry interval and
limit of an asynchronous step awaiting completion. Core Flows sub-workflows skip locking by default.
- Order cancellation rejects completed orders. Cancellation immediately cancels
uncaptured payments and attempts to refund captured payments for the captured amount.
- A return cannot include more than an item's returnable quantity. Creating or completing
a return persists its `refund_amount`.
## Modules, queries, and extensibility
- Register custom modules in `medusa-config.ts` and start development mode to
generate `.medusa/types/module-bindings.d.ts` and typed container resolution.
- Inferred service input properties are all optional in TypeScript; callers
still need database-required fields. Generated `MedusaService` create/update methods return one record
for one input and arrays for array inputs; `{ selector, data }` updates always return arrays.
- `link.create` enforces `defineLink` cardinality. Default one-to-one links reject
reused records; `isList: true` on the related model permits several related
records per product, and on both sides permits many-to-many links.
- Experimental Index queries use `@medusajs/index`, `MEDUSA_FF_INDEX_ENGINE=true`,
and migrations before server ingestion. `query.index` uses the `query.graph`
shape and supports linked filters, `$and`, `$or`, `$nin`, and `$not`.
Its PostgreSQL-estimated result count can be inaccurate for small result sets.
- Use `defineSearchIndex` for products or any other data model and enable
storefront access for `/store/search`. From 2.21.2, this route returns only
indexed fields; add needed fields to the index or fetch them separately.
- Preview caching uses `featureFlags.caching` and a registered Redis provider.
Graph queries with `options.cache.enable` generate cache keys and invalidation
tags automatically; module service mutations invalidate matching entries.
The preview deprecates `@medusajs/cache`, `@medusajs/cache-redis`, and `@medusajs/cache-inmemory`.
- For experimental Translations, replace custom `entities` registration with
`.translatable()` on eligible model text fields, then select the fields in Admin.
- Middleware stacks with built-in validation. Core-route overrides are slated
for removal; application error handlers can handle errors from core routes.
## Payments, pricing, and promotions
- `hooks.setPricingContext` supplies custom pricing-rule attributes for variant
or shipping-option pricing. Core Flows preserve existing customer and region
context when merging the hook result.
- A `sale` price list preserves an already available lower price. Variant updates
through Core Flows preserve existing prices when prices are omitted.
- Promotions support `active`, `inactive`, and `draft`: upgrades set existing
promotions to `active`; new ones default to `draft` unless a different `status` is supplied.
- Invalid promotion codes return HTTP `400`. A `USE_BY_ATTRIBUTE` campaign budget
applies its `limit` separately per `attribute` value; individual promotions can
independently cap total redemptions. `spend_by_attribute` budgets are tracked and enforced.
- Allocation `once` with `max_quantity` covers up to that many eligible units
across the cart, starting with the lowest-priced eligible units.
- Install and register `@medusajs/loyalty-plugin`, then run migrations, for gift
cards and account credits in self-hosted applications. Store-credit payment
is disabled for guests and when the outstanding amount is zero.
- Use Medusa 2.23.0 or later for Medusa Payments setup.
## Events, files, Admin, and operations
- The event bus emits or queues an event only with a registered subscriber.
Sub-workflow events stay pending while the parent runs; compensation clears
queued events through `emitEventsStep`. For events on rollback, use a custom emit step without compensation.
- Lower numbers mean higher event priority: order placement uses `10`, ordinary
events default to `100`, and internal system events run at the lowest priority.
- Admin drawer notifications must use `channel=feed` and the expected content
format. Pass `no_notification: true` to `markOrderFulfillmentAsDeliveredWorkflow`
to suppress delivery notifications.
- `/admin/uploads` passes base64 content; decode it in custom providers and
retain binary handling if they also receive binary uploads. Admin limits uploads to 1 MB per file.
- Request S3 presigned upload URLs with the actual file size and upload exactly
that many bytes; S3 rejects a different content length.
- Plugin builds include Admin extensions and server assets. Publish a `./admin`
export for compiled extensions; see the Admin reference for ESM and CommonJS entry points.
- `create-medusa-app` and `medusa new` scaffold `dtc-starter` with separate backend
and storefront packages. The standalone `medusa-starter-default` and
`nextjs-starter-medusa` templates are deprecated.
- `medusa db:migrate` discovers default-exported functions under
`src/migration-scripts` in the project, plugins, and core; each runs only once successfully.
Order line-item adjustment upgrades require migrations with data scripts enabled.
- `medusa start` defaults an unset `NODE_ENV` to production; the loader always
loads `.env` alongside the environment-specific file. Redeploy Cloud after restoring or importing its database.