-
Notifications
You must be signed in to change notification settings - Fork 212
@W-18737391 Add development guidelines and page creation rules for generated project #2786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yhsieh1
merged 15 commits into
feature/generated-project-cursor-rules
from
feature/W-18737391/updateCursorRules
Jul 14, 2025
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2124053
@W-18737391 Add developemnt guidelines and page creation rules
yhsieh1 9b336fb
remove from .cursor/rules folder
yhsieh1 2ab0829
update rule
yhsieh1 3fd3078
condense guideliens
yhsieh1 6e6f9b1
Merge branch 'develop' of https://github.com/SalesforceCommerceCloud/…
yhsieh1 086381f
update changelog
yhsieh1 3bf0c83
update rule to help pattern match
yhsieh1 cce224d
added cursor rules
yhsieh1 57c29ec
move cursor rules to root
yhsieh1 90faabc
move cursor rules to root
yhsieh1 3e0d98a
revert change log
yhsieh1 88b6f9b
nested cursor rules
yhsieh1 61fe5c4
Merge branch 'feature/generated-project-cursor-rules' of https://gith…
yhsieh1 d4c545f
move to nested rules location
yhsieh1 ae0fe8d
revert create mobify app js
yhsieh1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/pwa-kit-create-app/assets/cursor-rules/development-guidelines.mdc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| --- | ||
| description: Salesforce Commerce Composable Storefront Development Guidelines | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Commerce Composable Storefront Development Guidelines | ||
|
|
||
| ## Overview | ||
| Guidelines for Salesforce Commerce Composable Storefront development using PWA Kit, Retail React App, and Chakra UI. | ||
|
|
||
| ## Core Principles | ||
| - Analyze requirements and existing codebase thoroughly | ||
| - Use existing components and hooks when possible | ||
| - Plan before implementing | ||
| - Test comprehensively with Jest | ||
|
|
||
| ## PWA Kit Essentials | ||
|
|
||
| ### Architecture | ||
| - Server-side rendering (SSR) for initial loads | ||
| - Client-side rendering (CSR) for interactions | ||
| - Isomorphic code (works on server and client) | ||
| - Proxy requests via `/mobify/proxy/<PROXY_PATH>` | ||
|
|
||
| ### Special Components | ||
| - Components starting with `_` are special PWA Kit components | ||
| - `_app-config`: Top-level app configuration | ||
| - `_app`: Persistent layout (header, footer, sidebar) | ||
| - `_error`: 404 and error pages | ||
|
|
||
| ## Development Rules | ||
| - Use kebab-case for file names (except special components with `_`) | ||
| - Use Chakra UI and existing components | ||
| - Create modular, reusable components | ||
| - Use React Hooks for state management | ||
| - Access data via commerce-sdk-react hooks | ||
| - Ensure mobile-friendly and accessible components | ||
| - Maintain consistent code formatting using project standards | ||
| - Write comprehensive test coverage |
16 changes: 16 additions & 0 deletions
16
packages/pwa-kit-create-app/assets/cursor-rules/page-creation.mdc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| description: Page Creation Rule - automatically apply when user asks to create new page, add page, make page, build page, generate page | ||
yhsieh1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| globs: | ||
yhsieh1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| alwaysApply: false | ||
| --- | ||
| USE WHEN create a new page, add a new page, make a new page, build a new page, generate a new page, create page, add page, make page, build page, generate page | ||
|
|
||
| **Mandatory** | ||
| - DO ask user to clarify page name and page route before proceed | ||
| - ONLY Create a bare minimum page component | ||
| - Do NOT include other project components or hooks unless specifically requested | ||
| - Do NOT add extra styling, layout, or features unless explicitly asked | ||
|
|
||
| ## Implementation Steps | ||
| 1. Create simple component in `app/pages/[page-name]/index.jsx` | ||
| 2. Add route to `app/routes.jsx` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/template-retail-react-app/.cursor/rules/accessibility-rule.mdc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| description: Check and verify accessibility on local project | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
| To check accessibility of a project, use the accessibility rules defined in PROJECT_ROOT/.cursor/rules/cursor-accessibility-mdc/ directory. | ||
| Run an automated scan for the entire codebase within the project and check for any violations. | ||
| Show the scanned results in summary and detailed violations if any. |
26 changes: 26 additions & 0 deletions
26
...ate-retail-react-app/.cursor/rules/cursor-accessibility-mdc/accessibility-button-name.mdc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| description: When accessibility is checked. Check if Buttons must have a discernible name using text or aria attributes | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Rule: accessibility-button-name | ||
|
|
||
| Buttons must have a discernible name using text or aria attributes | ||
|
|
||
| ## 🔍 Pattern | ||
|
|
||
| ```regex | ||
| <button(?![^>]*\b(aria-label|aria-labelledby|title|name)=) | ||
| ``` | ||
|
|
||
| ## 📍 Examples | ||
|
|
||
| ```tsx | ||
| // ❌ Bad | ||
| <button></button> | ||
| // ✅ Good | ||
| <button>Submit</button> | ||
| // ✅ Good | ||
| <button aria-label="Close dialog"><XIcon /></button> | ||
| ``` |
26 changes: 26 additions & 0 deletions
26
...e-retail-react-app/.cursor/rules/cursor-accessibility-mdc/accessibility-heading-order.mdc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| description: When accessibility is checked. Check if heading levels should increase sequentially for semantic structure | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Rule: accessibility-heading-order | ||
|
|
||
| Heading levels should increase sequentially for semantic structure | ||
|
|
||
| ## 🔍 Pattern | ||
|
|
||
| ```regex | ||
| <h([3-6])> | ||
| ``` | ||
|
|
||
| ## 📍 Examples | ||
|
|
||
| ```tsx | ||
| // ❌ Bad | ||
| <h1>Main Title</h1> | ||
| <h4>Subsection</h4> | ||
| // ✅ Good | ||
| <h1>Main Title</h1> | ||
| <h2>Subsection</h2> | ||
| ``` |
24 changes: 24 additions & 0 deletions
24
...plate-retail-react-app/.cursor/rules/cursor-accessibility-mdc/accessibility-image-alt.mdc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| description: When accessibility is checked. Ensure all <img> tags include descriptive alt attributes | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Rule: accessibility-image-alt | ||
|
|
||
| Ensure all <img> tags include descriptive alt attributes | ||
|
|
||
| ## 🔍 Pattern | ||
|
|
||
| ```regex | ||
| <img(?![^>]*\balt=) | ||
| ``` | ||
|
|
||
| ## 📍 Examples | ||
|
|
||
| ```tsx | ||
| // ❌ Bad | ||
| <img src="photo.jpg" /> | ||
| // ✅ Good | ||
| <img src="photo.jpg" alt="Company logo" /> | ||
| ``` |
27 changes: 27 additions & 0 deletions
27
...ate-retail-react-app/.cursor/rules/cursor-accessibility-mdc/accessibility-input-label.mdc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| description: When accessibility is checked. Check if Input fields must have a label or aria-label for screen readers | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Rule: accessibility-input-label | ||
|
|
||
| Input fields must have a label or aria-label for screen readers | ||
|
|
||
| ## 🔍 Pattern | ||
|
|
||
| ```regex | ||
| <input(?![^>]*(aria-label|aria-labelledby|id=)) | ||
| ``` | ||
|
|
||
| ## 📍 Examples | ||
|
|
||
| ```tsx | ||
| // ❌ Bad | ||
| <input type="text" /> | ||
| // ✅ Good | ||
| <input aria-label="Search" /> | ||
| // ✅ Good with label | ||
| <label htmlFor="email">Email</label> | ||
| <input id="email" type="text" /> | ||
| ``` |
26 changes: 26 additions & 0 deletions
26
...plate-retail-react-app/.cursor/rules/cursor-accessibility-mdc/accessibility-link-name.mdc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| description: When accessibility is checked. Check if Anchor tags must have accessible names | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Rule: accessibility-link-name | ||
|
|
||
| Anchor tags must have accessible names | ||
|
|
||
| ## 🔍 Pattern | ||
|
|
||
| ```regex | ||
| <a(?![^>]*\b(aria-label|aria-labelledby|title)=)(?![^>]*>\s*\w+\s*</a>) | ||
| ``` | ||
|
|
||
| ## 📍 Examples | ||
|
|
||
| ```tsx | ||
| // ❌ Bad | ||
| <a href="/profile"></a> | ||
| // ✅ Good | ||
| <a href="/profile">Your Profile</a> | ||
| // ✅ Good | ||
| <a href="/profile" aria-label="Profile page"><UserIcon /></a> | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this model-definition configuration file get discovered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor only fetch this guidelines rule if it think it needs it. On top of that, Cursor will not look into nodes_module even rules say so. We need other mechanism to expose model-definition files. By the way, I do not know where it is as well. Could you share more information about it?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover mdc files are a cursor's convention in determining rules
https://docs.cursor.com/context/rules#project-rules
This is more like a metadata content file used by cursor internally when agent is requested to perform tasks