Skip to content

Commit cea436b

Browse files
authored
feat: add Medusa cursorrules (PatrickJS#117)
1 parent 6b4287c commit cea436b

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

rules-new/medusa.mdc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
description: Medusa rules and best practices. These rules should be used when building applications with Medusa.
3+
globs: **/*.tsx, **/*.ts, src/**/*.ts, src/**/*.tsx, src/**/*.js, src/**/*.jsx
4+
---
5+
6+
You are an expert senior software engineer specializing in modern web development, with deep expertise in TypeScript, Medusa, React.js, and TailwindCSS.
7+
8+
# Medusa Rules
9+
10+
## General Rules
11+
12+
- Don't use type aliases when importing files.
13+
- When throwing errors, always throw `MedusaError`.
14+
- Always use Query to retrieve data.
15+
16+
## Workflow Rules
17+
18+
- When creating a workflow or step, always use Medusa's Workflow SDK `@medusajs/framework/workflows-sdk` to define it.
19+
- When creating a feature in an API route, scheduled job, or subscriber, always create a workflow for it.
20+
- When creating a workflow, always create a step for it.
21+
- In workflows, use `transform` for any data transformation.
22+
- In workflows, use `when` to define conditions.
23+
- Don't use `await` when calling steps.
24+
- In workflows, don't make the workflow function async.
25+
- Don't add typing to compensation function's input.
26+
- Only use steps in a workflow.
27+
28+
## Data Model Rules
29+
30+
- Use the `model` utility from `@medusajs/framework/utils` to define data models.
31+
- Data model variables should be camelCase. Data model names as passed to `model.define` should be snake case.
32+
- When adding an `id` field to a data model, always make it a primary key with `.primaryKey()`.
33+
- A data model can have one `id` only, other IDs should be `text` instead.
34+
- Data model fields should be snake case.
35+
36+
## Service Rules
37+
38+
- When creating a service, always make methods async.
39+
- If a module has data models, make the service extend `MedusaService`.
40+
41+
## Admin Customization Rules
42+
43+
- When sending requests in admin customizations, always use Medusa's JS SDK.
44+
- Use TailwindCSS for styling.
45+
46+
# Additional Resources
47+
48+
- [Medusa Documentation](https://docs.medusajs.com/llms-full.txt)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
You are an expert senior software engineer specializing in modern web development, with deep expertise in TypeScript, Medusa, React.js, and TailwindCSS.
2+
3+
## Medusa Rules
4+
5+
## General Rules
6+
7+
- Don't use type aliases when importing files.
8+
- When throwing errors, always throw `MedusaError`.
9+
- Always use Query to retrieve data.
10+
11+
## Workflow Rules
12+
13+
- When creating a workflow or step, always use Medusa's Workflow SDK `@medusajs/framework/workflows-sdk` to define it.
14+
- When creating a feature in an API route, scheduled job, or subscriber, always create a workflow for it.
15+
- When creating a workflow, always create a step for it.
16+
- In workflows, use `transform` for any data transformation.
17+
- In workflows, use `when` to define conditions.
18+
- Don't use `await` when calling steps.
19+
- In workflows, don't make the workflow function async.
20+
- Don't add typing to compensation function's input.
21+
- Only use steps in a workflow.
22+
23+
## Data Model Rules
24+
25+
- Use the `model` utility from `@medusajs/framework/utils` to define data models.
26+
- Data model variables should be camelCase. Data model names as passed to `model.define` should be snake case.
27+
- When adding an `id` field to a data model, always make it a primary key with `.primaryKey()`.
28+
- A data model can have one `id` only, other IDs should be `text` instead.
29+
- Data model fields should be snake case.
30+
31+
## Service Rules
32+
33+
- When creating a service, always make methods async.
34+
- If a module has data models, make the service extend `MedusaService`.
35+
36+
## Admin Customization Rules
37+
38+
- When sending requests in admin customizations, always use Medusa's JS SDK.
39+
- Use TailwindCSS for styling.
40+
41+
# Additional Resources
42+
43+
- [Medusa Documentation](https://docs.medusajs.com/llms-full.txt)

0 commit comments

Comments
 (0)