@avisek_yorkie/cursor-rules 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.cursorrules CHANGED
@@ -1,16 +1,24 @@
1
- # Cursor Rules - Generic Tech Stack
1
+ # Cursor Rules - TypeScript/JavaScript
2
2
 
3
- This file contains comprehensive coding rules that apply to any technology stack. These rules are designed to ensure code quality, maintainability, and consistency across all projects.
3
+ Comprehensive rules for **TS/JS** projects: **React**, **Angular**, **Node.js**, **React Native**. Code quality, maintainability, consistency, and AI-assisted development workflow.
4
4
 
5
5
  ## How to Use These Rules
6
6
 
7
7
  1. Copy this `.cursorrules` file to your project root
8
- 2. Copy the rule files from the `rules/` folder (code-quality.mdc, documentation.mdc, naming-conventions.mdc) to your project root
8
+ 2. Copy the rule files into `.cursor/rules/` (see Rule Categories below)
9
9
  3. Cursor will automatically apply these rules when assisting with code
10
10
 
11
11
  ## Rule Categories
12
12
 
13
- ### 1. Code Quality (rules/code-quality.mdc)
13
+ Rules in `.cursor/rules/` are applied automatically.
14
+
15
+ ### 1. AI-Assisted Development (.cursor/rules/ai-assisted-development.mdc)
16
+ - Plan before coding; implement in small, reviewable steps
17
+ - Validate structure first for new features (skeleton then logic)
18
+ - Re-plan when something feels off; don’t refactor legacy out of scope
19
+ - Review checklist: layer, naming, i18n, no hardcoded values, types, a11y
20
+
21
+ ### 2. Code Quality (.cursor/rules/code-quality.mdc)
14
22
  - Clean code standards
15
23
  - Error handling
16
24
  - Security best practices
@@ -18,14 +26,14 @@ This file contains comprehensive coding rules that apply to any technology stack
18
26
  - Code complexity management
19
27
  - Testing requirements
20
28
 
21
- ### 2. Documentation (rules/documentation.mdc)
29
+ ### 3. Documentation (.cursor/rules/documentation.mdc)
22
30
  - Code documentation standards
23
31
  - README requirements
24
32
  - API documentation
25
33
  - Architecture documentation
26
34
  - Inline comments guidelines
27
35
 
28
- ### 3. Naming Conventions (rules/naming-conventions.mdc)
36
+ ### 4. Naming Conventions (.cursor/rules/naming-conventions.mdc)
29
37
  - Variable and function naming
30
38
  - Class and type naming
31
39
  - File and directory naming
@@ -104,6 +112,9 @@ Before submitting code, ensure:
104
112
 
105
113
  ## Quick Reference
106
114
 
115
+ ### AI-Assisted Development (one-line takeaway)
116
+ - **Align on a plan first, then implement in small, reviewable steps**—minimizes rework and keeps code clean and maintainable.
117
+
107
118
  ### Function/Method Guidelines
108
119
  - Maximum length: 50 lines (ideally 20-30)
109
120
  - Single responsibility
@@ -133,7 +144,7 @@ Before submitting code, ensure:
133
144
 
134
145
  To use these rules in a specific project:
135
146
 
136
- 1. **Copy the rules**: Copy `.cursorrules` and the `.mdc` files from `rules/` to your project root
147
+ 1. **Copy the rules**: Copy `.cursorrules` to project root and the `.mdc` files into `.cursor/rules/`
137
148
  2. **Customize if needed**: Add project-specific rules while maintaining these core principles
138
149
  3. **Team alignment**: Ensure your team is aware of and follows these rules
139
150
  4. **Code reviews**: Use the checklists during code reviews
@@ -149,5 +160,5 @@ To use these rules in a specific project:
149
160
 
150
161
  ---
151
162
 
152
- **Note**: These rules are designed to be generic and applicable to any technology stack. Customize them for your specific project needs while maintaining the core principles.
163
+ **Note**: These rules target TypeScript/JavaScript (React, Angular, Node.js, React Native). Customize for your project while keeping the core principles.
153
164
 
package/README.md CHANGED
@@ -16,18 +16,38 @@ npm install -D @avisek_yorkie/cursor-rules
16
16
  npx cursor-rules-init
17
17
  ```
18
18
 
19
- This copies `.cursorrules` and the rule files (`code-quality.mdc`, `documentation.mdc`, `naming-conventions.mdc`) into your project root. Cursor will then **use and apply** these rules automatically when you write code, refactor, get completions, or ask for reviews.
19
+ This creates:
20
+
21
+ - **`.cursorrules`** in your project root
22
+ - **`.cursor/rules/`** with `code-quality.mdc`, `documentation.mdc`, and `naming-conventions.mdc`
23
+
24
+ Cursor will **use and apply** these rules automatically when you write code, refactor, get completions, or ask for reviews.
20
25
 
21
26
  **Manual copy (alternative):**
22
27
 
23
28
  ```bash
29
+ mkdir -p .cursor/rules
24
30
  cp node_modules/@avisek_yorkie/cursor-rules/.cursorrules .
25
- cp node_modules/@avisek_yorkie/cursor-rules/rules/*.mdc .
31
+ cp node_modules/@avisek_yorkie/cursor-rules/rules/*.mdc .cursor/rules/
26
32
  ```
27
33
 
28
- **3. Verify:** Ensure `.cursorrules` and the three `.mdc` files are in your project root. Restart Cursor if needed. You’re done.
34
+ **3. Verify:** Ensure `.cursorrules` exists and `.cursor/rules/` contains the three `.mdc` files. Restart Cursor if needed. You’re done.
35
+
36
+ **Resulting structure in your project:**
37
+
38
+ ```
39
+ your-project/
40
+ ├── .cursorrules
41
+ ├── .cursor/
42
+ │ └── rules/
43
+ │ ├── code-quality.mdc
44
+ │ ├── documentation.mdc
45
+ │ └── naming-conventions.mdc
46
+ ├── src/
47
+ └── ...
48
+ ```
29
49
 
30
- ## 📁 Directory Structure
50
+ ## 📁 Directory Structure (this package)
31
51
 
32
52
  ```
33
53
  cursor-rules/
@@ -57,14 +77,16 @@ npx cursor-rules-init
57
77
 
58
78
  **Option B – Manual copy from node_modules:**
59
79
  ```bash
80
+ mkdir -p .cursor/rules
60
81
  cp node_modules/@avisek_yorkie/cursor-rules/.cursorrules .
61
- cp node_modules/@avisek_yorkie/cursor-rules/rules/*.mdc .
82
+ cp node_modules/@avisek_yorkie/cursor-rules/rules/*.mdc .cursor/rules/
62
83
  ```
63
84
 
64
85
  **Option C – From a local clone:**
65
86
  ```bash
87
+ mkdir -p .cursor/rules
66
88
  cp /path/to/cursor-rules/.cursorrules .
67
- cp /path/to/cursor-rules/rules/*.mdc .
89
+ cp /path/to/cursor-rules/rules/*.mdc .cursor/rules/
68
90
  ```
69
91
 
70
92
  ### Step 3: Verify integration
@@ -79,12 +101,77 @@ Cursor will automatically detect and use the `.cursorrules` file in your project
79
101
 
80
102
  You can customize these rules for your specific project by:
81
103
  - Adding project-specific rules to `.cursorrules`
82
- - Modifying the `.mdc` files to include team-specific conventions
83
- - Adding language-specific rules for your tech stack
104
+ - **Adding new `.mdc` files in `.cursor/rules/`** (see below — they are automatically linked and applied)
105
+ - Modifying the existing `.mdc` files to include team-specific conventions
106
+
107
+ ## ➕ Adding Project-Specific Rules (Auto-Applied)
108
+
109
+ **Yes — any `.mdc` file you add inside `.cursor/rules/` is automatically loaded and applied by Cursor.** You don’t need to “link” it anywhere. Cursor scans the `.cursor/rules/` folder and uses every rule file. **You do not need to add the new file to `.cursorrules`**—it is picked up automatically.
110
+
111
+ ### How to add a project-specific rule
112
+
113
+ 1. Create a new file in your project’s `.cursor/rules/` folder, e.g. `project-conventions.mdc` or `react-patterns.mdc`.
114
+ 2. Use the same format as the existing rules: YAML frontmatter + markdown content.
115
+
116
+ **Example: rule that always applies**
117
+
118
+ ```markdown
119
+ ---
120
+ description: Our project's React and API conventions
121
+ alwaysApply: true
122
+ ---
123
+
124
+ # Project Conventions
125
+
126
+ - Use our design system components from `@company/ui`.
127
+ - API base URL from env: `process.env.VITE_API_URL`.
128
+ - All new screens go under `src/screens/`.
129
+ ```
130
+
131
+ **Example: rule that applies only for certain files**
132
+
133
+ ```markdown
134
+ ---
135
+ description: React component patterns for this project
136
+ globs: "**/*.tsx"
137
+ alwaysApply: false
138
+ ---
139
+
140
+ # React Patterns
141
+
142
+ - Functional components only; use hooks for state.
143
+ - Add testID to interactive elements for E2E.
144
+ ```
145
+
146
+ ### Frontmatter options
147
+
148
+ | Field | Meaning |
149
+ |-------|--------|
150
+ | `alwaysApply: true` | Rule is included in every conversation. |
151
+ | `alwaysApply: false` | Rule is included only when relevant (e.g. when matching files are open). |
152
+ | `globs: "**/*.tsx"` | When set, rule is applied when you work with files matching that pattern. |
153
+
154
+ ### Resulting structure (example)
155
+
156
+ ```
157
+ your-project/
158
+ ├── .cursorrules
159
+ ├── .cursor/
160
+ │ └── rules/
161
+ │ ├── ai-assisted-development.mdc # from this package
162
+ │ ├── code-quality.mdc # from this package
163
+ │ ├── documentation.mdc # from this package
164
+ │ ├── naming-conventions.mdc # from this package
165
+ │ └── project-conventions.mdc # your project-specific rule ✅
166
+ ├── src/
167
+ └── ...
168
+ ```
169
+
170
+ Package rules and your own rules work together: Cursor applies all of them. Keep package rules as-is and add project-specific ones in the same folder.
84
171
 
85
172
  ## 📚 Rule Files Overview
86
173
 
87
- ### 1. Code Quality (`rules/code-quality.mdc`)
174
+ ### 1. Code Quality (`.cursor/rules/code-quality.mdc`)
88
175
 
89
176
  Covers:
90
177
  - ✅ Clean code standards
@@ -102,7 +189,7 @@ Covers:
102
189
  - Never hardcode secrets
103
190
  - Keep cyclomatic complexity low
104
191
 
105
- ### 2. Documentation (`rules/documentation.mdc`)
192
+ ### 2. Documentation (`.cursor/rules/documentation.mdc`)
106
193
 
107
194
  Covers:
108
195
  - ✅ Function/method documentation standards
@@ -119,7 +206,7 @@ Covers:
119
206
  - Keep documentation up-to-date
120
207
  - Use appropriate documentation tools
121
208
 
122
- ### 3. Naming Conventions (`rules/naming-conventions.mdc`)
209
+ ### 3. Naming Conventions (`.cursor/rules/naming-conventions.mdc`)
123
210
 
124
211
  Covers:
125
212
  - ✅ Variable and function naming
@@ -137,51 +224,51 @@ Covers:
137
224
  - Avoid abbreviations and generic names
138
225
  - Use appropriate prefixes for booleans
139
226
 
140
- ## 🎯 Usage Examples
227
+ ## 📐 Coding Styles & Principles
141
228
 
142
- ### Example 1: Starting a New Project
229
+ All rule styles referenced in the code-quality and related rules, in one place.
143
230
 
144
- ```bash
145
- # Create new project
146
- mkdir my-new-project
147
- cd my-new-project
231
+ ### Core acronyms
148
232
 
149
- # Copy cursor rules
150
- cp node_modules/@avisek_yorkie/cursor-rules/.cursorrules .
151
- cp node_modules/@avisek_yorkie/cursor-rules/rules/*.mdc .
233
+ | Style | Full name | Meaning |
234
+ |-------|-----------|----------|
235
+ | **SOLID** | **S**ingle Responsibility, **O**pen/Closed, **L**iskov Substitution, **I**nterface Segregation, **D**ependency Inversion | One thing per class/function; extend without modifying; depend on abstractions. |
236
+ | **DRY** | Don't Repeat Yourself | Extract repeated logic; use configuration over duplication; no copy-paste without refactoring. |
237
+ | **KISS** | Keep It Simple, Stupid | Simple solution > clever; readable > clever; avoid over-engineering. |
238
+ | **YAGNI** | You Aren't Gonna Need It | Build what you need now; don't build for hypotheticals; remove unused code. |
239
+ | **Fail Fast** | — | Validate early at boundaries; fail loudly when something is wrong. |
152
240
 
153
- # Initialize your project (npm, pip, etc.)
154
- npm init -y # or your package manager
241
+ ### Golden rules (summary)
155
242
 
156
- # Start coding - Cursor will apply the rules automatically!
157
- ```
243
+ 1. **Readability > Cleverness** Code is read 10× more than written
244
+ 2. **Simple > Complex** — Simplest solution that works
245
+ 3. **Small Functions** — One function, one responsibility (~20–30 lines, max 50)
246
+ 4. **Meaningful Names** — Names should reveal intent
247
+ 5. **Handle Errors** — Never fail silently
248
+ 6. **Delete Code** — Remove dead code; don't just comment it out
249
+ 7. **Test Your Code** — If you can't test it, refactor it
250
+ 8. **Composition over Inheritance** — Compose small pieces; avoid deep hierarchies (especially in React)
251
+ 9. **Immutability** — Prefer `const` and immutable updates; avoid hidden mutation
252
+ 10. **Explicit over Implicit** — Clear types and APIs; no magic; avoid `any`
158
253
 
159
- ### Example 2: Adding Rules to Existing Project
254
+ ### Additional JS/TS principles
160
255
 
161
- ```bash
162
- # Navigate to your project
163
- cd /path/to/your/project
256
+ | Principle | One-line meaning |
257
+ |-----------|-------------------|
258
+ | **Pure functions when possible** | Same inputs → same output; no hidden side effects; isolate I/O at boundaries. |
259
+ | **Single source of truth** | One canonical place per piece of state; avoid syncing duplicate state. |
260
+ | **Declarative over imperative** | Describe *what* you want (e.g. JSX) over step-by-step *how*. |
261
+ | **Principle of least surprise** | APIs and behavior should match what a reasonable developer would expect. |
262
+ | **Colocate / locality** | Keep related code together (component + styles + tests; route + handler + types). |
263
+ | **Encapsulation** | Don't leak implementation details; expose a small, stable API surface. |
264
+ | **Strict TypeScript** | Use `strict: true`; avoid `any`; prefer `unknown` and type guards when needed. |
164
265
 
165
- # Copy rules (backup existing .cursorrules if present)
166
- cp node_modules/@avisek_yorkie/cursor-rules/.cursorrules .
167
- cp node_modules/@avisek_yorkie/cursor-rules/rules/*.mdc .
266
+ ### Documentation & naming (from rule files)
168
267
 
169
- # Review and merge with existing rules if needed
170
- ```
171
-
172
- ### Example 3: Publishing NPM Package
173
-
174
- When publishing an npm package, these rules ensure:
175
- - ✅ Proper documentation in README
176
- - ✅ Consistent naming conventions
177
- - ✅ High code quality
178
- - ✅ Proper error handling
179
- - ✅ Security best practices
180
-
181
- ```bash
182
- # Your package will follow all rules automatically
183
- npm publish
184
- ```
268
+ - **Document WHY, not WHAT** Explain decisions and non-obvious logic.
269
+ - **Names reveal intent** — Descriptive, specific names from the problem domain; avoid `data`, `info`, `handler`, `manager`.
270
+ - **Verbs for functions** — e.g. `get`, `set`, `create`, `validate`, `is`, `has`, `can`.
271
+ - **Boolean prefixes** `is`, `has`, `can` (e.g. `isActive`, `hasPermission`, `canEdit`).
185
272
 
186
273
  ## 🔧 Customization Guide
187
274
 
@@ -207,7 +294,7 @@ Edit `.cursorrules` to add project-specific rules:
207
294
  Edit the appropriate `.mdc` file to add language-specific rules:
208
295
 
209
296
  ```markdown
210
- # In rules/code-quality.mdc
297
+ # In .cursor/rules/code-quality.mdc
211
298
 
212
299
  ### Your Language
213
300
  - Follow your language style guide
@@ -273,7 +360,7 @@ Consider versioning your rules:
273
360
  ### Rules Not Being Applied
274
361
 
275
362
  1. Check that `.cursorrules` is in project root
276
- 2. Verify `.mdc` files are in project root (copied from `rules/`)
363
+ 2. Verify `.cursor/rules/` contains the three `.mdc` files
277
364
  3. Restart Cursor if needed
278
365
  4. Check for syntax errors in rule files
279
366
 
package/SETUP.md CHANGED
@@ -18,27 +18,29 @@ npx cursor-rules-init
18
18
 
19
19
  **Option B – Manual copy:**
20
20
  ```bash
21
+ mkdir -p .cursor/rules
21
22
  cp node_modules/@avisek_yorkie/cursor-rules/.cursorrules .
22
- cp node_modules/@avisek_yorkie/cursor-rules/rules/*.mdc .
23
+ cp node_modules/@avisek_yorkie/cursor-rules/rules/*.mdc .cursor/rules/
23
24
  ```
24
25
 
25
26
  **From a local clone:**
26
27
  ```bash
27
- # Copy main file and all rule files to your project root
28
+ mkdir -p .cursor/rules
28
29
  cp /path/to/cursor-rules/.cursorrules .
29
- cp /path/to/cursor-rules/rules/*.mdc .
30
+ cp /path/to/cursor-rules/rules/*.mdc .cursor/rules/
30
31
  ```
31
32
 
32
33
  ### Step 2: Verify files are in place
33
34
  ```bash
34
- ls -la .cursorrules *.mdc
35
+ ls -la .cursorrules .cursor/rules/
35
36
  ```
36
37
 
37
38
  You should see:
38
- - `.cursorrules`
39
- - `code-quality.mdc`
40
- - `documentation.mdc`
41
- - `naming-conventions.mdc`
39
+ - `.cursorrules` (project root)
40
+ - `.cursor/rules/ai-assisted-development.mdc`
41
+ - `.cursor/rules/code-quality.mdc`
42
+ - `.cursor/rules/documentation.mdc`
43
+ - `.cursor/rules/naming-conventions.mdc`
42
44
 
43
45
  ### Step 3: Restart Cursor (optional)
44
46
  Close and reopen Cursor to ensure rules are loaded.
@@ -46,6 +48,9 @@ Close and reopen Cursor to ensure rules are loaded.
46
48
  ### Step 4: Test the rules
47
49
  Create a test file and ask Cursor to help you write code. The rules will be automatically applied!
48
50
 
51
+ ### Step 5: Add project-specific rules (optional)
52
+ Any `.mdc` file you add in `.cursor/rules/` is **automatically linked and applied** by Cursor. Create e.g. `project-conventions.mdc` in that folder with your team’s rules—no extra config needed. See README section **“Adding Project-Specific Rules (Auto-Applied)”** for format and examples.
53
+
49
54
  ## 📦 For NPM Package Publishing
50
55
 
51
56
  ### Before Publishing Checklist
@@ -102,8 +107,9 @@ If you update the rules (or upgrade the package), sync them to your project:
102
107
 
103
108
  ```bash
104
109
  # From your project root (when using npm package)
110
+ mkdir -p .cursor/rules
105
111
  cp node_modules/@avisek_yorkie/cursor-rules/.cursorrules .
106
- cp node_modules/@avisek_yorkie/cursor-rules/rules/*.mdc .
112
+ cp node_modules/@avisek_yorkie/cursor-rules/rules/*.mdc .cursor/rules/
107
113
  ```
108
114
 
109
115
  ## ✅ Verification
package/bin/init.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Copies .cursorrules and rules/*.mdc from this package to the current working directory.
4
+ * Installs Cursor rules: .cursorrules in project root, .mdc files in .cursor/rules/
5
5
  * Run from your project root: npx cursor-rules-init
6
6
  */
7
7
 
@@ -11,13 +11,20 @@ const path = require('path');
11
11
  const packageRoot = path.join(__dirname, '..');
12
12
  const targetDir = process.cwd();
13
13
 
14
+ const cursorRulesDir = path.join(targetDir, '.cursor', 'rules');
15
+
14
16
  const filesToCopy = [
15
17
  { src: '.cursorrules', dest: '.cursorrules' },
16
- { src: 'rules/code-quality.mdc', dest: 'code-quality.mdc' },
17
- { src: 'rules/documentation.mdc', dest: 'documentation.mdc' },
18
- { src: 'rules/naming-conventions.mdc', dest: 'naming-conventions.mdc' },
18
+ { src: 'rules/ai-assisted-development.mdc', dest: '.cursor/rules/ai-assisted-development.mdc' },
19
+ { src: 'rules/code-quality.mdc', dest: '.cursor/rules/code-quality.mdc' },
20
+ { src: 'rules/documentation.mdc', dest: '.cursor/rules/documentation.mdc' },
21
+ { src: 'rules/naming-conventions.mdc', dest: '.cursor/rules/naming-conventions.mdc' },
19
22
  ];
20
23
 
24
+ if (!fs.existsSync(cursorRulesDir)) {
25
+ fs.mkdirSync(cursorRulesDir, { recursive: true });
26
+ }
27
+
21
28
  let copied = 0;
22
29
  for (const { src, dest } of filesToCopy) {
23
30
  const srcPath = path.join(packageRoot, src);
@@ -30,7 +37,10 @@ for (const { src, dest } of filesToCopy) {
30
37
  }
31
38
 
32
39
  if (copied > 0) {
33
- console.log('\nCursor rules installed. Cursor will apply them automatically.');
40
+ console.log('\nCursor rules installed.');
41
+ console.log(' .cursorrules');
42
+ console.log(' .cursor/rules/ (ai-assisted-development, code-quality, documentation, naming-conventions)');
43
+ console.log('\nCursor will apply them automatically.');
34
44
  } else {
35
45
  console.error('No rule files found. Reinstall @avisek_yorkie/cursor-rules.');
36
46
  process.exit(1);
package/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "@avisek_yorkie/cursor-rules",
3
- "version": "1.0.1",
4
- "description": "Cursor AI rules for code quality, documentation, and naming conventions (JS/TS)",
3
+ "version": "1.0.3",
4
+ "description": "Cursor AI rules for TS/JS (React, Angular, Node, React Native): code quality, docs, naming, AI-assisted development.",
5
5
  "keywords": [
6
6
  "cursor",
7
7
  "cursor-rules",
8
8
  "code-quality",
9
9
  "documentation",
10
10
  "naming-conventions",
11
+ "ai-assisted-development",
11
12
  "javascript",
12
- "typescript"
13
+ "typescript",
14
+ "react",
15
+ "angular",
16
+ "node",
17
+ "react-native"
13
18
  ],
14
19
  "license": "MIT",
15
20
  "repository": {
@@ -0,0 +1,106 @@
1
+ ---
2
+ description: AI-assisted development DOs and DON'Ts; plan-first, small steps, review (React, Angular, Node, React Native)
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # AI-Assisted Development: DOs and DON'Ts
7
+
8
+ This file teaches Cursor **how to think and behave** in your project—not what the code should look like (that’s in code-quality, documentation, naming). So developers can use short, natural prompts and still get high-quality, safe, reviewable code.
9
+
10
+ Applies to **TypeScript/JavaScript** projects: React, Angular, Node.js, React Native. Align on a plan first, then implement in small, reviewable steps.
11
+
12
+ ---
13
+
14
+ ## DOs
15
+
16
+ ### 1. DO Start with a Plan Before Coding
17
+ - Ask for a **step-by-step approach (to-do list)** before implementation.
18
+ - Clarify: problem, expected outcome, and iterate on the plan until confident.
19
+ - **Planning is cheaper to correct than code.**
20
+
21
+ ### 2. DO Implement in Small, Reviewable Steps
22
+ - Execute the approved plan **one step at a time**.
23
+ - Keep each change **small (~20–30 lines** where possible).
24
+ - Small changes are easier to review, validate, and roll back.
25
+
26
+ ### 3. DO Validate Structure First for New Features
27
+ - For new features, start with the **skeleton** (e.g. empty component in the right folder, route, or API stub).
28
+ - Confirm it matches **codebase patterns and architecture** before adding logic.
29
+ - Avoids costly restructuring later.
30
+
31
+ **Where "skeleton" lives by stack:**
32
+
33
+ | Stack | Skeleton / pattern check |
34
+ |-------------|----------------------------------------------------|
35
+ | React | Component in correct folder; hooks vs components |
36
+ | Angular | Module/component in correct module; lazy loading |
37
+ | Node.js | Handler/service in correct layer; route/API shape |
38
+ | React Native| Screen/component + testID; native vs JS structure |
39
+
40
+ ### 4. DO Ask for Code Review After Implementation
41
+ - Once code works end-to-end, ask for review, e.g.:
42
+ - "Is this good practice in [React/TypeScript/Angular/Node]?"
43
+ - "Review this against our coding standards and suggest improvements."
44
+ - "Any performance, accessibility, or maintainability concerns?"
45
+
46
+ ### 5. DO Pause and Re-Plan When Something Feels Off
47
+ - If the output seems wrong or off-track, **stop immediately**.
48
+ - Return to **planning mode**: re-clarify requirements and approach.
49
+ - Do not push forward hoping it will correct itself—early misunderstandings snowball.
50
+
51
+ ---
52
+
53
+ ## DON'Ts
54
+
55
+ ### 1. DON'T Jump Straight into Implementation for Big or Unclear Tasks
56
+ - Skipping planning for complex features or bugs bakes misunderstandings into code.
57
+ - Leads to rework, hard-to-review PRs, and wasted effort.
58
+
59
+ ### 2. DON'T Ask for Massive Changes at Once
60
+ - Large diffs are harder to follow, validate, and debug.
61
+ - Break requests into **smaller, focused tasks**.
62
+ - If you can't easily review what changed, the change is too big.
63
+
64
+ ### 3. DON'T Keep Pushing Forward When Output Seems Wrong
65
+ - If something feels off, do not continue hoping it will self-correct.
66
+ - Each change built on a flawed foundation makes the problem worse.
67
+ - **Stop, assess, and re-plan.**
68
+
69
+ ### 4. DON'T Refactor Legacy Code Just Because AI Suggests It
70
+ - Only fix code **you wrote or made worse**.
71
+ - Do not refactor **working legacy code** to satisfy AI or tool suggestions—you risk breaking stable behavior and scope creep.
72
+
73
+ ### 5. DON'T Blindly Accept AI-Generated Code
74
+ - Always review output for:
75
+ - **Correct architecture layer** (e.g. component vs service vs API)
76
+ - **Naming and file organization** (per naming-conventions.mdc)
77
+ - **i18n** for all user-facing strings (no raw copy in UI)
78
+ - **No hardcoded values**; use config/env/constants
79
+ - **Proper TypeScript types** (no `any` unless justified)
80
+ - **Accessibility**: semantic HTML (web), testID + labels (React Native)
81
+
82
+ ---
83
+
84
+ ## One-Line Takeaway
85
+
86
+ **Align on a plan first, then implement in small, reviewable steps**—minimizes rework and keeps code clean, predictable, and maintainable.
87
+
88
+ ---
89
+
90
+ ## Behavior for the AI (Cursor)
91
+
92
+ When the user request is **large or ambiguous**:
93
+
94
+ 1. **Propose a short plan** (bullet to-do list) and ask for confirmation before writing code.
95
+ 2. **Keep each response small**: one logical step or ~20–30 lines of change where possible; offer to continue with the next step.
96
+ 3. **For new features**: suggest creating the skeleton (file/component/route) first and confirm placement, then add behavior.
97
+ 4. **If the user says something is wrong or off**: suggest re-planning or reverting the last step instead of adding more code on top.
98
+ 5. **Do not suggest refactors of unrelated legacy code** unless the user explicitly asks or the code is in scope of the current task.
99
+
100
+ Before suggesting code, do a quick self-check:
101
+
102
+ - [ ] Right layer (UI / service / API / util)?
103
+ - [ ] Naming and file location match project conventions?
104
+ - [ ] User-facing text ready for i18n (no hardcoded copy)?
105
+ - [ ] No hardcoded config/secrets; types explicit where possible?
106
+ - [ ] Accessibility considered (semantic HTML, testID, labels)?
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Code quality standards, error handling, security, and testing
3
+ alwaysApply: true
4
+ ---
5
+
1
6
  # Code Quality Standards
2
7
 
3
8
  These standards apply to the TypeScript/JavaScript ecosystem. Core principles are universal across languages.
@@ -29,6 +34,21 @@ These standards apply to the TypeScript/JavaScript ecosystem. Core principles ar
29
34
  - ❌ Don't build for hypothetical future requirements
30
35
  - ❌ Remove unused code immediately
31
36
 
37
+ ### Additional JS/TS Ecosystem Principles
38
+
39
+ | Principle | Meaning |
40
+ |-----------|--------|
41
+ | **Composition over inheritance** | Prefer composing small modules/hooks over deep class hierarchies. Especially in React: hooks and components over inheritance. |
42
+ | **Immutability** | Prefer `const`; avoid mutating objects/arrays—use spread, `map`/`filter`/`reduce`, immutable updates. Critical for React state and predictability. |
43
+ | **Explicit over implicit** | No magic: clear types (avoid `any`), explicit params and return types, obvious control flow. APIs should be self-evident. |
44
+ | **Pure functions when possible** | Same inputs → same output; no hidden side effects. Makes code testable and predictable. Isolate I/O at boundaries. |
45
+ | **Single source of truth** | One canonical place for each piece of state (e.g. server state, UI state). Avoid syncing duplicate state. |
46
+ | **Declarative over imperative** | Describe *what* you want (e.g. JSX, declarative UI) rather than step-by-step *how*. Prefer `map` over manual loops when it reads better. |
47
+ | **Principle of least surprise** | APIs and behavior should match what a reasonable developer would expect. Naming and signatures should not surprise. |
48
+ | **Colocate / locality** | Keep related code together: component + styles + tests; route + handler + types. Reduces jumping between files. |
49
+ | **Encapsulation** | Don’t leak implementation details from modules/APIs. Expose a small, stable surface; hide the rest. |
50
+ | **Strict TypeScript** | Use `strict: true`; avoid `any`; prefer `unknown` and type guards when type is uncertain. Types are documentation. |
51
+
32
52
  ---
33
53
 
34
54
  ## Code Structure
@@ -415,3 +435,6 @@ Before submitting code for review, verify:
415
435
  8. **Meaningful Names** - Names should reveal intent
416
436
  9. **Handle Errors** - Never fail silently
417
437
  10. **Delete Code** - Dead code should be removed, not commented out
438
+ 11. **Composition over Inheritance** - Compose small pieces; avoid deep hierarchies (especially in React)
439
+ 12. **Immutability** - Prefer `const` and immutable updates; avoid hidden mutation
440
+ 13. **Explicit over Implicit** - Clear types and APIs; no magic; avoid `any`
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Documentation standards, README, API docs, and inline comments
3
+ alwaysApply: true
4
+ ---
5
+
1
6
  # Documentation Standards - JavaScript/TypeScript
2
7
 
3
8
  Good documentation is as important as good code. These standards apply to JS/TS projects.
@@ -1,3 +1,8 @@
1
+ ---
2
+ description: Naming conventions for variables, types, files, and APIs
3
+ alwaysApply: true
4
+ ---
5
+
1
6
  # Naming Conventions
2
7
 
3
8
  ## General Naming Principles