dist/codex/magento2-commerce/skills/magento-plugins-interceptors/SKILL.md
Implement Magento 2 plugins (interceptors) — before, after, and around methods for modifying class behavior without inheritance. Use when extending core or third-party module functionality.
npx skillsauth add orcaqubits/agentic-commerce-claude-plugins magento-plugins-interceptorsInstall 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: Fetch https://developer.adobe.com/commerce/php/development/components/plugins/ for the official plugins guide with exact method signatures and limitations.
Plugins intercept public method calls on any non-final class, allowing you to modify arguments, return values, or wrap entire method execution — without modifying the original class or using inheritance.
| Type | Method Prefix | Purpose | Receives |
|------|-------------|---------|----------|
| Before | before<MethodName> | Modify input arguments | Subject + original args |
| After | after<MethodName> | Modify return value | Subject + result (+ original args) |
| Around | around<MethodName> | Wrap entire execution | Subject + $proceed callable + original args |
beforeOriginalMethod($subject, $arg1, $arg2, ...)null to keep originalsafterOriginalMethod($subject, $result, ...$args)$resultaroundOriginalMethod($subject, callable $proceed, $arg1, $arg2, ...)$proceed($arg1, $arg2) to invoke the original (or skip it)Plugins are declared as children of a <type> element:
name — unique plugin identifiertype — fully qualified plugin class namesortOrder — execution priority (lower runs first)disabled — true to disable$proceed code$proceed)$proceed codefinal classes or final methods__construct() (constructor)static methodsprotected, private)Place plugin classes in the Plugin/ directory of your module:
VendorName/ModuleName/Plugin/SomePlugin.php
$proceed in around plugins unless intentionally skippingFetch the plugins documentation for exact method signatures, the latest limitations list, and any changes in recent Magento versions 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.