Skip to content

Commit 9131c3a

Browse files
authored
chore: add project-wide development guidelines and rules for IDEs (#2414)
1 parent e222311 commit 9131c3a

24 files changed

+397
-0
lines changed

.cursor/rules/follow-up-questions.mdc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
---
3+
description: When you have questions or need clarification, I'll ask follow-up questions to ensure I understand your requirements before providing a solution. This helps me deliver more accurate and useful code that meets your specific needs.
4+
globs:
5+
alwaysApply: true
6+
---
7+
Do not make any changes, until you have 95% confidence that you know what to build ask me follow up questions until you have that confidence.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
trigger: model_decision
3+
description: Specifies the usage of TODO comments to outline problems or bugs encountered in existing code, regardless of file type.
4+
globs: **/*.*
5+
---
6+
- TODO Comments: If you encounter a bug in existing code, or the instructions lead to suboptimal or buggy code, add comments starting with "TODO:" outlining the problems.

.windsurf/rules/clean-code.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
trigger: model_decision
3+
description: Guidelines for writing clean, maintainable, and human-readable code. Apply these rules when writing or reviewing code to ensure consistency and quality.
4+
globs:
5+
---
6+
# Clean Code Guidelines
7+
8+
## Constants Over Magic Numbers
9+
- Replace hard-coded values with named constants
10+
- Use descriptive constant names that explain the value's purpose
11+
- Keep constants at the top of the file or in a dedicated constants file
12+
13+
## Meaningful Names
14+
- Variables, functions, and classes should reveal their purpose
15+
- Names should explain why something exists and how it's used
16+
- Avoid abbreviations unless they're universally understood
17+
18+
## Smart Comments
19+
- Don't comment on what the code does - make the code self-documenting
20+
- Use comments to explain why something is done a certain way
21+
- Document APIs, complex algorithms, and non-obvious side effects
22+
23+
## Single Responsibility
24+
- Each function should do exactly one thing
25+
- Functions should be small and focused
26+
- If a function needs a comment to explain what it does, it should be split
27+
28+
## DRY (Don't Repeat Yourself)
29+
- Extract repeated code into reusable functions
30+
- Share common logic through proper abstraction
31+
- Maintain single sources of truth
32+
33+
## Clean Structure
34+
- Keep related code together
35+
- Organize code in a logical hierarchy
36+
- Use consistent file and folder naming conventions
37+
38+
## Encapsulation
39+
- Hide implementation details
40+
- Expose clear interfaces
41+
- Move nested conditionals into well-named functions
42+
43+
## Code Quality Maintenance
44+
- Refactor continuously
45+
- Fix technical debt early
46+
- Leave code cleaner than you found it
47+
48+
## Testing
49+
- Write tests before fixing bugs
50+
- Keep tests readable and maintainable
51+
- Test edge cases and error conditions
52+
53+
## Version Control
54+
- Write clear commit messages
55+
- Make small, focused commits
56+
- Use meaningful branch names

.windsurf/rules/codequality.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
trigger: model_decision
3+
description: Code Quality Guidelines
4+
globs:
5+
---
6+
# Code Quality Guidelines
7+
8+
## Verify Information
9+
Always verify information before presenting it. Do not make assumptions or speculate without clear evidence.
10+
11+
## File-by-File Changes
12+
Make changes file by file and give me a chance to spot mistakes.
13+
14+
## No Apologies
15+
Never use apologies.
16+
17+
## No Understanding Feedback
18+
Avoid giving feedback about understanding in comments or documentation.
19+
20+
## No Whitespace Suggestions
21+
Don't suggest whitespace changes.
22+
23+
## No Inventions
24+
Don't invent changes other than what's explicitly requested.
25+
26+
## No Unnecessary Confirmations
27+
Don't ask for confirmation of information already provided in the context.
28+
29+
## Preserve Existing Code
30+
Don't remove unrelated code or functionalities. Pay attention to preserving existing structures.
31+
32+
## Single Chunk Edits
33+
Provide all edits in a single chunk instead of multiple-step instructions or explanations for the same file.
34+
35+
## No Implementation Checks
36+
Don't ask the user to verify implementations that are visible in the provided context.
37+
38+
## No Unnecessary Updates
39+
Don't suggest updates or changes to files when there are no actual modifications needed.
40+
41+
## Provide Real File Links
42+
Always provide links to the real files, not x.md.
43+
44+
## No Current Implementation
45+
Don't show or discuss the current implementation unless specifically requested.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
trigger: model_decision
3+
description: Applies coding guidelines related to using early returns and conditional classes in all files.
4+
globs: **/*.*
5+
---
6+
- Utilize Early Returns: Use early returns to avoid nested conditions and improve readability.
7+
- Conditional Classes: Prefer conditional classes over ternary operators for class attributes.

.windsurf/rules/comment-usage.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
trigger: model_decision
3+
description: This rule dictates how comments should be used within the codebase to enhance understanding and avoid clutter.
4+
globs: **/*.*
5+
---
6+
- Use comments sparingly, and when you do, make them meaningful.
7+
- Don't comment on obvious things. Excessive or unclear comments can clutter the codebase and become outdated.
8+
- Use comments to convey the "why" behind specific actions or explain unusual behavior and potential pitfalls.
9+
- Provide meaningful information about the function's behavior and explain unusual behavior and potential pitfalls.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
trigger: always_on
3+
---
4+
5+
Do not make any changes, until you have 95% confidence that you know what to build ask me follow up questions until you have that confidence.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
trigger: model_decision
3+
description: This rule enforces the single responsibility principle, ensuring functions are short and focused.
4+
globs: **/*.*
5+
---
6+
- Write short functions that only do one thing.
7+
- Follow the single responsibility principle (SRP), which means that a function should have one purpose and perform it effectively.
8+
- If a function becomes too long or complex, consider breaking it into smaller, more manageable functions.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
trigger: model_decision
3+
description: Defines the function ordering conventions, where functions that compose other functions appear earlier in the file, regardless of the file type.
4+
globs: **/*.*
5+
---
6+
- Order functions with those that are composing other functions appearing earlier in the file. For example, if you have a menu with multiple buttons, define the menu function above the buttons.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
trigger: model_decision
3+
description: Ensures helpful comments are added to the code and that old, relevant comments are preserved.
4+
globs: **/*.*
5+
---
6+
- Always add helpful comments to the code explaining what you are doing.
7+
- Never delete old comments, unless they are no longer relevant because the code has been rewritten or deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
trigger: model_decision
3+
description: Applies general coding principles like simplicity, readability, performance, maintainability, testability, and reusability to all files.
4+
globs: **/*.*
5+
---
6+
- Focus on simplicity, readability, performance, maintainability, testability, and reusability.
7+
- Remember less code is better.
8+
- Lines of code = Debt.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
trigger: model_decision
3+
description: Enforces the principle of making minimal code changes to avoid introducing bugs or technical debt in any file.
4+
globs: **/*.*
5+
---
6+
- Only modify sections of the code related to the task at hand.
7+
- Avoid modifying unrelated pieces of code.
8+
- Accomplish goals with minimal code changes.

.windsurf/rules/naming-conventions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
trigger: model_decision
3+
description: This rule focuses on using meaningful and descriptive names for variables, functions, and classes throughout the project.
4+
globs: **/*.*
5+
---
6+
- Choose names for variables, functions, and classes that reflect their purpose and behavior.
7+
- A name should tell you why it exists, what it does, and how it is used. If a name requires a comment, then the name does not reveal its intent.
8+
- Use specific names that provide a clearer understanding of what the variables represent and how they are used.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
trigger: model_decision
3+
description: Applies Next.js App Router specific guidelines to components and pages within the 'app' directory.
4+
globs: app/**/*.tsx
5+
---
6+
- You are an expert in Next.js Pages Router.
7+
- Follow Next.js documentation for best practices in data fetching, rendering, and routing.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
trigger: model_decision
3+
description: Rules specifically for the Next.js configuration file.
4+
globs: /next.config.js
5+
---
6+
- Ensure the Next.js configuration is optimized for performance.
7+
- Review and update the configuration regularly based on project needs.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
trigger: model_decision
3+
description: Key Next.js conventions for state changes, web vitals, and client-side code usage.
4+
globs: **/*.{ts,js,jsx,tsx}
5+
---
6+
- Rely on Next.js Pages Router for state changes.
7+
- Prioritize Web Vitals (LCP, CLS, FID).
8+
- Minimize 'use client' usage:
9+
- Prefer server components and Next.js SSR features.
10+
- Use 'use client' only for Web API access in small components.
11+
- Avoid using 'use client' for data fetching or state management.
12+
- Refer to Next.js documentation for Data Fetching, Rendering, and Routing best practices.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
trigger: model_decision
3+
description: This rule defines the recommended folder structure for Next.js projects.
4+
globs: app/**/*.*
5+
---
6+
- Adhere to the following folder structure:
7+
8+
src/
9+
components/
10+
lib/
11+
pages/
12+
hooks/
13+
utils/
14+
public/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
trigger: model_decision
3+
description: Guidelines for optimizing performance by minimizing client-side operations and using server-side rendering.
4+
globs: **/*.{js,jsx,ts,tsx}
5+
---
6+
- Optimize Web Vitals (LCP, CLS, FID).
7+
- Use dynamic loading for non-critical components using @src/components/dls/Spinner/Spinner.tsx
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
trigger: model_decision
3+
description: Defines the persona as a senior full-stack developer with extensive knowledge applicable to all files.
4+
globs: **/*.*
5+
---
6+
- You are a senior full-stack developer. One of those rare 10x developers that has incredible knowledge.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
trigger: model_decision
3+
description: Enforces the use of functional components with hooks in React components.
4+
globs: src/components/**/*.tsx
5+
---
6+
- Always use React functional components with hooks.
7+
- Use React.FC for functional components with props.

.windsurf/rules/react.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
trigger: model_decision
3+
description: React best practices and patterns for modern web applications
4+
globs: **/*.tsx, **/*.jsx, components/**/*
5+
---
6+
7+
# React Best Practices
8+
9+
## Component Structure
10+
- Use functional components over class components
11+
- Keep components small and focused
12+
- Extract reusable logic into custom hooks
13+
- Use composition over inheritance
14+
- Implement proper prop types with TypeScript
15+
- Split large components into smaller, focused ones
16+
17+
## Hooks
18+
- Follow the Rules of Hooks
19+
- Use custom hooks for reusable logic
20+
- Keep hooks focused and simple
21+
- Use appropriate dependency arrays in useEffect
22+
- Implement cleanup in useEffect when needed
23+
- Avoid nested hooks
24+
25+
## State Management
26+
- Use useState for local component state.
27+
- Implement Redux Toolkit for efficient Redux development for medium-complex state logic.
28+
- Implement slice pattern for organizing Redux code.
29+
- Avoid prop drilling through proper state management.
30+
- Use xstate for complex state logic.
31+
32+
## Performance
33+
- Implement proper memoization (useMemo, useCallback)
34+
- Use React.memo for expensive components
35+
- Avoid unnecessary re-renders
36+
- Implement proper lazy loading
37+
- Use proper key props in lists
38+
- Profile and optimize render performance
39+
40+
## Forms
41+
- Re-use @src/components/FormBuilder/FormBuilder.tsx to build forms.
42+
- Implement proper form validation.
43+
- Handle form submission states properly.
44+
- Show appropriate loading and error states.
45+
- Implement proper accessibility for forms.
46+
47+
## Error Handling
48+
- Handle async errors properly
49+
- Show user-friendly error messages
50+
- Implement proper fallback UI
51+
- Log errors appropriately
52+
- Handle edge cases gracefully
53+
54+
## Testing
55+
- Write unit tests for components
56+
- Implement integration tests for complex flows
57+
- Use React Testing Library
58+
- Test user interactions
59+
- Test error scenarios
60+
- Implement proper mock data
61+
62+
## Accessibility
63+
- Use semantic HTML elements
64+
- Implement proper ARIA attributes
65+
- Ensure keyboard navigation
66+
- Test with screen readers
67+
- Handle focus management
68+
- Provide proper alt text for images
69+
70+
## Code Organization
71+
- Group related components together
72+
- Use proper file naming conventions
73+
- Implement proper directory structure
74+
- Keep styles close to components
75+
- Use proper imports/exports
76+
- Document complex component logic
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
trigger: model_decision
3+
description: Enforces specific folder structure conventions within the Redux store directory.
4+
globs: src/redux/**/*
5+
---
6+
- Follow this folder structure:
7+
src/
8+
redux/
9+
actions/
10+
slices/
11+
RootState.ts
12+
store.ts
13+
migrations.ts
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
trigger: model_decision
3+
description: Applies Redux Toolkit best practices for efficient Redux development.
4+
globs: src/redux/**/*.ts
5+
---
6+
- Use Redux Toolkit for efficient Redux development.
7+
- Implement slice pattern for organizing Redux code.
8+
- Use selectors for accessing state in components.
9+
- Use Redux hooks (useSelector, useDispatch) in components.
10+
- Follow Redux style guide for naming conventions

0 commit comments

Comments
 (0)