dist/cursor/medusa-commerce/skills/medusa-cart-checkout/SKILL.md
Implement Medusa v2 cart and checkout — cart lifecycle, line items, shipping and payment selection, sales channels, and checkout completion flow. Use when building cart and checkout features.
npx skillsauth add orcaqubits/agentic-commerce-claude-plugins medusa-cart-checkoutInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Fetch live docs:
site:docs.medusajs.com cart module for cart data model and service methodssite:docs.medusajs.com checkout flow for the end-to-end checkout processsite:docs.medusajs.com sales channel for sales channel scopinghttps://docs.medusajs.com/resources/references/cart and review the ICartModuleService interfacemedusajs v2 cart workflow 2026 for latest cart-related workflow stepsCreate Cart ──> Add Line Items ──> Set Address
──> Select Shipping ──> Init Payment ──> Complete
| State | Description | |-------|-------------| | Active | Cart is open, items can be added/removed | | Completing | Checkout in progress, payment being processed | | Completed | Cart converted to order, no further modifications |
| Entity | Key Fields | |--------|------------| | Cart | region_id, customer_id, sales_channel_id, email | | LineItems[] | variant_id, quantity, unit_price, Adjustments[] | | ShippingMethods[] | shipping_option_id, amount, data | | Addresses | shipping_address, billing_address | | PaymentCollection | PaymentSessions[] |
| Link Target | Purpose | |-------------|---------| | Product Module | Variant resolution | | Region Module | Currency, tax rules | | Sales Channel Module | Storefront scoping | | Promotion Module | Discount application | | Payment Module | Payment sessions | | Fulfillment Module | Shipping methods |
Fetch live docs for cross-module link definitions and
remoteQueryusage for cart enrichment.
// Skeleton: create cart in storefront
// Fetch live docs for createCartWorkflow input
const cart = await createCartWorkflow(container)
.run({ input: { region_id, sales_channel_id } })
// Fetch live docs for required vs optional fields
| Workflow | Purpose |
|----------|---------|
| addToCartWorkflow | Add variant + quantity to cart |
| updateLineItemInCartWorkflow | Update quantity of existing item |
| deleteLineItemsWorkflow | Remove items from cart |
| Field | Required | Notes |
|-------|----------|-------|
| first_name / last_name | Yes | |
| address_1 | Yes | Street address |
| city | Yes | |
| country_code | Yes | ISO 2-letter code |
| postal_code | Conditional | Required by region |
| province | Conditional | State/province |
Available options determined by cart region, shipping address, and shipping profiles.
| Workflow | Purpose |
|----------|---------|
| listShippingOptionsForCartWorkflow | Fetch available options |
| addShippingMethodToCartWorkflow | Apply selected shipping option |
| Workflow | Purpose |
|----------|---------|
| createPaymentCollectionForCartWorkflow | Create payment collection |
| initializePaymentSessionWorkflow | Start provider-specific session |
| Workflow | Purpose |
|----------|---------|
| completeCartWorkflow | Convert cart to order |
Completion validates: all items in stock, shipping selected, payment authorized, email set.
Fetch live docs for the exact validation checks performed during cart completion.
| Concept | Description | |---------|-------------| | Sales Channel | Named storefront scope (e.g., "Web", "Mobile App", "B2B") | | Publishable API Key | Associates Store API requests with a sales channel | | Product-Channel Link | Products published to specific channels |
x-publishable-api-key headerFetch live docs for publishable API key configuration and sales channel management.
| Route Pattern | Method | Purpose |
|---------------|--------|---------|
| /store/carts | POST | Create cart |
| /store/carts/:id | GET | Retrieve cart |
| /store/carts/:id | POST | Update cart (email, address) |
| /store/carts/:id/line-items | POST | Add line item |
| /store/carts/:id/line-items/:item_id | POST/DELETE | Update/remove line item |
| /store/carts/:id/shipping-methods | POST | Add shipping method |
| /store/carts/:id/payment-collections | POST | Create payment collection |
| /store/carts/:id/complete | POST | Complete checkout |
Fetch live docs for request body shapes and response formats on each route.
region_id -- it determines currency, tax rules, and shippingsales_channel_id to scope product availability per storefrontmetadata (e.g., gift messages, notes)remoteQuery to enrich cart data (product details, images) in a single queryFetch the Medusa v2 cart module documentation and checkout workflow references for exact service method signatures, workflow inputs, and validation rules before implementing.
development
Build with Spree's headless Next.js storefront — the official `spree/storefront` repo (Next.js 16 App Router with Server Actions and Turbopack, React 19 Server Components, Tailwind CSS 4, TypeScript 5, `@spree/sdk`, Sentry), server-only auth (httpOnly JWT cookies + publishable key), MeiliSearch faceted catalog, one-page checkout with Apple/Google Pay/Klarna/Affirm/SEPA, multi-region market routing, GA4 + JSON-LD SEO, and Vercel/Docker deployment. Use when forking or customizing the storefront, or evaluating headless adoption.
tools
Build Spree extensions as Rails engines — gem scaffolding, `bin/rails g spree:extension`, mounting routes/migrations/assets, the modern `prepend` decorator pattern (`*_decorator.rb` with `self.prepended(base)`), generators (`spree:model_decorator`, `spree:controller_decorator`), the four customization surfaces in preference order (Events > Webhooks > Dependencies > Decorators), Spree::Dependencies for swapping service objects, gem release/versioning, and the deprecated Deface engine. Use when building a reusable Spree extension or adding non-trivial customization to an app.
development
Build with Spree's event bus and Webhooks 2.0 — `Spree::Events` publication, `Spree::Subscriber` DSL with `subscribes_to` and `on`, wildcard matching, lifecycle events (`{model}.created/.updated/.deleted` via `publishes_lifecycle_events`), the canonical event catalog (order.*, payment.*, shipment.*, product.*), Webhooks 2.0 endpoints, HMAC-SHA256 signing (`X-Spree-Webhook-Signature`), exponential-backoff retries, and Sidekiq job orchestration. Use when wiring event-driven business logic, building webhook consumers, or replacing ActiveSupport callback chains.
tools
Cross-cutting Spree development patterns — the customization preference hierarchy (Events > Webhooks > Dependencies > Decorators), `Spree::Dependencies` service-object swapping, the `_decorator.rb` + `prepend` + `self.prepended` idiom, idempotent subscribers and webhook receivers, multi-store scoping discipline, prefixed IDs, calculator polymorphism (shipping/promotion/tax share the base), service-object composition with `dry-monads` or simple results, why to avoid `class_eval` reopening and Deface, and Spree-on-Rails idioms (Hotwire/Turbo Stimulus, ActiveStorage, Action Cable, Sidekiq). Use when designing the architecture of a Spree extension or solving cross-cutting concerns.