Skip to content

Commit aefd09e

Browse files
authored
chore: add writing tutorials skill (#15078)
1 parent 6f0465f commit aefd09e

File tree

5 files changed

+957
-0
lines changed

5 files changed

+957
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: writing-tutorials
3+
description: Creates Medusa documentation tutorials in two phases: first builds the tutorial feature in an example project (with planning, coding, and tests), then writes the MDX documentation. Use when creating a new how-to tutorial or integration guide for the Medusa docs. Handles both feature implementation and documentation writing, but only one phase at a time.
4+
---
5+
6+
# Writing Medusa Tutorials
7+
8+
Guides an agent through creating a complete Medusa tutorial: building the feature in an example project, then writing the documentation.
9+
10+
## Two-Phase Approach
11+
12+
**Phase 1 — Build:** Gather requirements → plan with user → implement feature → add tests → confirm with user
13+
**Phase 2 — Write:** Create step diagram → write per-step MD files → combine into final MDX → update sidebar → clean up
14+
15+
> **CRITICAL:** Never do both phases in one session. Complete Phase 1, get user confirmation, then reload this skill for Phase 2.
16+
17+
## Load Reference Files When Needed
18+
19+
> **Load at least one reference file before proceeding.**
20+
21+
| Task | Load |
22+
|------|------|
23+
| Starting Phase 1 (building) | `reference/building-phase.md` |
24+
| Starting Phase 2 (writing) | `reference/writing-phase.md` + `reference/tutorial-conventions.md` + `reference/concept-definitions.md` |
25+
| MDX patterns and components | `reference/tutorial-conventions.md` |
26+
| Concept definitions (module, workflow, etc.) | `reference/concept-definitions.md` |
27+
28+
## Quick Reference
29+
30+
### File Locations
31+
32+
| Type | Content Path | Sidebar File |
33+
|------|-------------|--------------|
34+
| How-to tutorial | `www/apps/resources/app/how-to-tutorials/tutorials/{name}/page.mdx` | `www/apps/resources/sidebars/how-to-tutorials.mjs` |
35+
| Integration guide | `www/apps/resources/app/integrations/guides/{name}/page.mdx` | `www/apps/resources/sidebars/integrations.mjs` |
36+
37+
### Development Skills to Load During Build
38+
39+
- Backend features → `medusa-dev:building-with-medusa`
40+
- Admin UI → `medusa-dev:building-admin-dashboard-customizations`
41+
- Storefront → `medusa-dev:building-storefronts`
42+
- Third-party services → `context7` MCP or skills
43+
- Medusa API questions → `mcp__medusa__ask_medusa_question`
44+
45+
## Common Mistakes
46+
47+
- [ ] Jumping straight to writing documentation without building the feature first
48+
- [ ] Writing both phases in one session without user confirmation between them
49+
- [ ] Writing Step 1 (Medusa installation) from scratch — use the pre-written template in `tutorial-conventions.md`
50+
- [ ] Forgetting to update the sidebar after writing the tutorial MDX
51+
- [ ] Leaving `_step-*.md` temp files after combining into final MDX
52+
- [ ] Making tutorial code overly complex — tutorials are educational, keep it simple
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Phase 1: Building the Tutorial Feature
2+
3+
Follow these steps to build the tutorial's feature in the example project before writing any documentation.
4+
5+
## Step 1 — Gather Requirements
6+
7+
Ask the user the following before doing anything else:
8+
9+
1. **Tutorial topic** — What feature or integration is being built? (e.g., "product reviews", "PayPal integration")
10+
2. **Tutorial type** — How-to tutorial or integration guide?
11+
3. **Example project path** — Where is the target Medusa example project? (e.g., `~/projects/my-medusa-app`)
12+
4. **Third-party services** — Are any external services involved? (e.g., PayPal, Segment, Stripe)
13+
5. **Scope** — Should the tutorial include Admin UI customizations? Storefront customizations?
14+
15+
Do NOT proceed until all required information is collected.
16+
17+
## Step 2 — Research & Plan
18+
19+
Before writing any code:
20+
21+
1. Load `medusa-dev:building-with-medusa` — required for all backend work
22+
- Also load `medusa-dev:building-admin-dashboard-customizations` if admin UI is in scope
23+
- Also load `medusa-dev:building-storefronts` if storefront is in scope
24+
2. Use `mcp__medusa__ask_medusa_question` for questions about Medusa APIs, modules, and patterns
25+
3. For integrations with third-party services: use `context7` MCP or skills to retrieve their documentation
26+
27+
**Write a plan covering:**
28+
- Data models to create (custom module if needed)
29+
- Workflows and their steps
30+
- API routes (store and/or admin)
31+
- Admin UI widgets/pages (if applicable)
32+
- Storefront components/changes (if applicable)
33+
- Seed data or configuration needed
34+
35+
> **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.
36+
37+
**Present the plan to the user and get explicit approval before writing any code.**
38+
39+
## Step 3 — Build the Feature
40+
41+
Follow the approved plan. Always follow the architecture layer order:
42+
43+
```
44+
Custom Module (data models + CRUD)
45+
46+
Workflow (business logic, mutations)
47+
48+
API Route (HTTP interface)
49+
50+
Admin UI / Storefront
51+
```
52+
53+
**Useful commands:**
54+
- Generate migration: `/medusa-dev:db-generate <module-name>`
55+
- Run migrations: `/medusa-dev:db-migrate`
56+
- Create admin user: `/medusa-dev:new-user <email> <password>`
57+
58+
Load reference files from `medusa-dev:building-with-medusa` for each component as you build it.
59+
60+
## Step 4 — Add Tests
61+
62+
Write tests to validate the implementation:
63+
64+
- **Workflow steps** — Unit tests for each step's main logic
65+
- **API routes** — Integration tests covering success and error cases
66+
- **Custom module service methods** — Unit tests for any non-trivial service logic
67+
68+
Place tests in:
69+
- `integration-tests/` for API/integration tests
70+
- `src/**/__tests__/` for unit tests
71+
72+
Keep tests simple and focused on verifying the feature works as expected. These tests also serve as examples for tutorial readers.
73+
74+
## Step 5 - Validate Implementation
75+
76+
Before finishing up, make sure that:
77+
78+
1. Build passes: `yarn build`
79+
2. Integration and unit tests pass
80+
81+
Fix all issues before wrapping up.
82+
83+
## Step 6 — Wrap Up
84+
85+
1. Tell the user to test the feature manually:
86+
- Start the Medusa app and test relevant API routes
87+
- Verify in the Admin UI (if applicable)
88+
- Verify in the Storefront (if applicable)
89+
2. Ask the user: **"Does everything look good? Let me know when you're ready to write the tutorial documentation."**
90+
3. Once the user confirms, instruct them: **"Reload `/writing-tutorials` and I'll help you write the documentation."**
91+
92+
> **IMPORTANT:** Do not start writing documentation until the user explicitly confirms the build is complete and working.

0 commit comments

Comments
 (0)