spree-workflows
Installation
SKILL.md
Contains Shell Commands
This skill contains shell command directives (!`command`) that may execute system commands. Review carefully before installing.
Spree Workflows & Hooks
Commands use the Spree CLI (
spree …). On a classic Rails app without the CLI, usebin/rails …/bundle exec rake …from the app root. Paths below assume the Rails app lives inserver/.
Spree's business logic lives in two kinds of plain Ruby classes, called the same way and returning the same Spree::ServiceModule::Result:
| Tier | Lives in | Use for |
|---|---|---|
| Service | app/services/ |
Plain create/update/delete, one sequential call body. Most of Spree. |
Workflow (Spree::Workflow) |
app/workflows/ |
Flows that need extension points, external calls (gateways, carriers), or compensation (undo when a later step fails): cart add/complete, order cancel, payment capture, fulfillment, returns, product status changes, imports… |
result = Spree.cart_add_item_workflow.call(cart: cart, variant: variant, quantity: 2)
result.success? # never raise on expected failures — check this
result.value # the line item
result.error.to_s # message on failure; result.error.value is ActiveModel::Errors for rejections
There are no state machines in Spree. Records carry a plain status string (Spree::HasStatus), and every transition is a workflow with its own hooks.