Follow these steps to build the tutorial's feature in the example project before writing any documentation.
Ask the user the following before doing anything else:
- Tutorial topic — What feature or integration is being built? (e.g., "product reviews", "PayPal integration")
- Tutorial type — How-to tutorial or integration guide?
- Example project path — Where is the target Medusa example project? (e.g.,
~/projects/my-medusa-app) - Third-party services — Are any external services involved? (e.g., PayPal, Segment, Stripe)
- Scope — Should the tutorial include Admin UI customizations? Storefront customizations?
Do NOT proceed until all required information is collected.
Before writing any code:
- Load
medusa-dev:building-with-medusa— required for all backend work- Also load
medusa-dev:building-admin-dashboard-customizationsif admin UI is in scope - Also load
medusa-dev:building-storefrontsif storefront is in scope
- Also load
- Use
mcp__medusa__ask_medusa_questionfor questions about Medusa APIs, modules, and patterns - For integrations with third-party services: use
context7MCP or skills to retrieve their documentation
Write a plan covering:
- Data models to create (custom module if needed)
- Workflows and their steps
- API routes (store and/or admin)
- Admin UI widgets/pages (if applicable)
- Storefront components/changes (if applicable)
- Seed data or configuration needed
CRITICAL: Keep it simple. Tutorial code is for learning, not production. Avoid unnecessary abstractions, overly generic utilities, or complex patterns. One clear approach beats multiple flexible ones.
Present the plan to the user and get explicit approval before writing any code.
Follow the approved plan. Always follow the architecture layer order:
Custom Module (data models + CRUD)
↓
Workflow (business logic, mutations)
↓
API Route (HTTP interface)
↓
Admin UI / Storefront
Useful commands:
- Generate migration:
/medusa-dev:db-generate <module-name> - Run migrations:
/medusa-dev:db-migrate - Create admin user:
/medusa-dev:new-user <email> <password>
Load reference files from medusa-dev:building-with-medusa for each component as you build it.
Write tests to validate the implementation:
- Workflow steps — Unit tests for each step's main logic
- API routes — Integration tests covering success and error cases
- Custom module service methods — Unit tests for any non-trivial service logic
Place tests in:
integration-tests/for API/integration testssrc/**/__tests__/for unit tests
Keep tests simple and focused on verifying the feature works as expected. These tests also serve as examples for tutorial readers.
Before finishing up, make sure that:
- Build passes:
yarn build - Integration and unit tests pass
Fix all issues before wrapping up.
- Tell the user to test the feature manually:
- Start the Medusa app and test relevant API routes
- Verify in the Admin UI (if applicable)
- Verify in the Storefront (if applicable)
- Ask the user: "Does everything look good? Let me know when you're ready to write the tutorial documentation."
- Once the user confirms, instruct them: "Reload
/writing-tutorialsand I'll help you write the documentation."
IMPORTANT: Do not start writing documentation until the user explicitly confirms the build is complete and working.