cursor-ai-toolkit 1.0.0
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/README.md +148 -0
- package/bin/cli.js +304 -0
- package/commands/context/ask-clarification.md +215 -0
- package/commands/context/context-prune.md +201 -0
- package/commands/context/orchestrate.md +279 -0
- package/commands/context/smart-detection.md +272 -0
- package/commands/learning/generate-memories.md +270 -0
- package/commands/learning/generate-rules.md +175 -0
- package/commands/learning/self-heal.md +233 -0
- package/commands/learning/self-improve.md +229 -0
- package/package.json +35 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze codebase patterns and auto-generate .mdc rules for enforcement
|
|
3
|
+
category: AI Self-Improvement
|
|
4
|
+
aliases: [gen-rules, create-rules, extract-patterns]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Generate Rules - Auto-create .mdc Rules from Patterns
|
|
8
|
+
|
|
9
|
+
Analyze codebase patterns and generate specialized `.mdc` rule files for real-time enforcement.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
/generate-rules # Analyze entire codebase
|
|
15
|
+
/generate-rules {PATH} # Analyze specific directory
|
|
16
|
+
/generate-rules --domain auth # Focus on specific domain
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## What This Does
|
|
20
|
+
|
|
21
|
+
1. **Analyzes codebase patterns** - Scans for conventions, antipatterns, and styles
|
|
22
|
+
2. **Extracts implicit rules** - Identifies what makes "good" code in your repo
|
|
23
|
+
3. **Generates .mdc files** - Creates Cursor rules for real-time enforcement
|
|
24
|
+
4. **Validates existing rules** - Checks if current rules match actual patterns
|
|
25
|
+
|
|
26
|
+
## Generated Rule Types
|
|
27
|
+
|
|
28
|
+
| Rule File | Purpose | Auto-detects |
|
|
29
|
+
| ------------------------ | ------------------- | ------------------------- |
|
|
30
|
+
| `component-patterns.mdc` | Component structure | File organization, naming |
|
|
31
|
+
| `hook-patterns.mdc` | Hook conventions | Custom hook patterns |
|
|
32
|
+
| `api-patterns.mdc` | API client patterns | Error handling, types |
|
|
33
|
+
| `testing-patterns.mdc` | Test conventions | AAA pattern, mocks |
|
|
34
|
+
| `domain-{name}.mdc` | Domain-specific | Business logic patterns |
|
|
35
|
+
|
|
36
|
+
## Analysis Process
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
40
|
+
│ STEP 1: Pattern Extraction │
|
|
41
|
+
├─────────────────────────────────────────────────────────────┤
|
|
42
|
+
│ • Scan files by type (.tsx, .ts, .styled.ts) │
|
|
43
|
+
│ • Extract import patterns │
|
|
44
|
+
│ • Identify naming conventions │
|
|
45
|
+
│ • Detect hook usage patterns │
|
|
46
|
+
│ • Find error handling patterns │
|
|
47
|
+
└─────────────────────────────────────────────────────────────┘
|
|
48
|
+
↓
|
|
49
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
50
|
+
│ STEP 2: Frequency Analysis │
|
|
51
|
+
├─────────────────────────────────────────────────────────────┤
|
|
52
|
+
│ • Count pattern occurrences │
|
|
53
|
+
│ • Identify dominant patterns (>70% usage) │
|
|
54
|
+
│ • Flag antipatterns (patterns in high-churn files) │
|
|
55
|
+
│ • Correlate with git history (stable vs unstable) │
|
|
56
|
+
└─────────────────────────────────────────────────────────────┘
|
|
57
|
+
↓
|
|
58
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
59
|
+
│ STEP 3: Rule Generation │
|
|
60
|
+
├─────────────────────────────────────────────────────────────┤
|
|
61
|
+
│ • Create .mdc file with frontmatter │
|
|
62
|
+
│ • Define glob patterns for application │
|
|
63
|
+
│ • Write enforcement rules with examples │
|
|
64
|
+
│ • Add good/bad pattern comparisons │
|
|
65
|
+
└─────────────────────────────────────────────────────────────┘
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Example Output
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
📋 Analyzing codebase patterns...
|
|
72
|
+
|
|
73
|
+
════════════════════════════════════════════════════════════════
|
|
74
|
+
PATTERN ANALYSIS RESULTS
|
|
75
|
+
════════════════════════════════════════════════════════════════
|
|
76
|
+
|
|
77
|
+
## Detected Patterns
|
|
78
|
+
|
|
79
|
+
### Component Patterns (423 files analyzed)
|
|
80
|
+
✅ Styled component namespace: 98% use `* as S`
|
|
81
|
+
✅ Feature folder structure: 87% follow standard
|
|
82
|
+
⚠️ Barrel files: 23% still use index.ts (antipattern)
|
|
83
|
+
✅ Type separation: 92% use .types.ts files
|
|
84
|
+
|
|
85
|
+
### Hook Patterns (918 hooks analyzed)
|
|
86
|
+
✅ AbortController cleanup: 76% compliance
|
|
87
|
+
⚠️ watch() usage: 12% still use (should be useWatch)
|
|
88
|
+
✅ Single responsibility: 89% focused hooks
|
|
89
|
+
⚠️ God hooks (>15 returns): 8% of hooks
|
|
90
|
+
|
|
91
|
+
### API Patterns (55 clients analyzed)
|
|
92
|
+
✅ ApiError type: 94% usage
|
|
93
|
+
✅ Generic response types: 91% typed
|
|
94
|
+
⚠️ Retry logic: Only 34% implement
|
|
95
|
+
|
|
96
|
+
## Generated Rules
|
|
97
|
+
|
|
98
|
+
📁 Created: .cursor/rules/component-patterns.mdc
|
|
99
|
+
- Styled component namespace enforcement
|
|
100
|
+
- Feature folder structure requirement
|
|
101
|
+
- No barrel files in components
|
|
102
|
+
|
|
103
|
+
📁 Created: .cursor/rules/hook-patterns.mdc
|
|
104
|
+
- AbortController requirement
|
|
105
|
+
- useWatch over watch()
|
|
106
|
+
- Single responsibility enforcement
|
|
107
|
+
|
|
108
|
+
📁 Created: .cursor/rules/api-patterns.mdc
|
|
109
|
+
- ApiError typing requirement
|
|
110
|
+
- Response type generics
|
|
111
|
+
|
|
112
|
+
════════════════════════════════════════════════════════════════
|
|
113
|
+
3 rule files created in .cursor/rules/
|
|
114
|
+
════════════════════════════════════════════════════════════════
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Commands Used
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# Find dominant patterns
|
|
121
|
+
grep -rh "import \* as S" --include="*.tsx" apps/ libraries/ | wc -l
|
|
122
|
+
|
|
123
|
+
# Find antipatterns
|
|
124
|
+
grep -rl "methods\.watch()" --include="*.tsx" apps/ | wc -l
|
|
125
|
+
|
|
126
|
+
# Check hook returns
|
|
127
|
+
grep -A 50 "^export const use" --include="*.ts" apps/*/src/hooks/ | \
|
|
128
|
+
grep -c "return {"
|
|
129
|
+
|
|
130
|
+
# Correlate with churn
|
|
131
|
+
git log --oneline --after="2024-01-01" --name-only | \
|
|
132
|
+
grep "\.tsx$" | sort | uniq -c | sort -rn | head -20
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Rule File Format
|
|
136
|
+
|
|
137
|
+
Generated `.mdc` files follow this structure:
|
|
138
|
+
|
|
139
|
+
```markdown
|
|
140
|
+
---
|
|
141
|
+
description: { Description }
|
|
142
|
+
globs: ['{glob patterns}']
|
|
143
|
+
alwaysApply: { true/false }
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
# {Rule Name}
|
|
147
|
+
|
|
148
|
+
## Enforced Patterns
|
|
149
|
+
|
|
150
|
+
### ✅ REQUIRED: {Pattern Name}
|
|
151
|
+
|
|
152
|
+
\`\`\`typescript
|
|
153
|
+
// Good example
|
|
154
|
+
\`\`\`
|
|
155
|
+
|
|
156
|
+
### ❌ FORBIDDEN: {Antipattern Name}
|
|
157
|
+
|
|
158
|
+
\`\`\`typescript
|
|
159
|
+
// Bad example - never generate
|
|
160
|
+
\`\`\`
|
|
161
|
+
|
|
162
|
+
## Rationale
|
|
163
|
+
|
|
164
|
+
{Why this pattern matters, backed by data}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## AI Execution
|
|
168
|
+
|
|
169
|
+
When user runs `/generate-rules`:
|
|
170
|
+
|
|
171
|
+
1. **Scan codebase** for file types and patterns
|
|
172
|
+
2. **Extract conventions** using regex and AST analysis
|
|
173
|
+
3. **Correlate with history** to identify stable vs unstable patterns
|
|
174
|
+
4. **Generate .mdc files** with proper frontmatter
|
|
175
|
+
5. **Report coverage** and any gaps detected
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Fix a bug and proactively find/fix similar antipatterns across the codebase
|
|
3
|
+
category: AI Self-Improvement
|
|
4
|
+
aliases: [heal, fix-pattern, fix-all]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Self-Heal - Proactive Pattern Fixing
|
|
8
|
+
|
|
9
|
+
Fix a bug and proactively find/fix similar patterns across the codebase.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
/self-heal {ERROR_LOG}
|
|
15
|
+
/self-heal {FILE:LINE} "Description of issue"
|
|
16
|
+
/self-heal --pattern "watch()" --fix "useWatch()"
|
|
17
|
+
/self-heal --sentry {ISSUE_ID}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## What This Does
|
|
21
|
+
|
|
22
|
+
1. **Analyzes error** - Understands root cause
|
|
23
|
+
2. **Fixes immediate issue** - Applies fix to reported location
|
|
24
|
+
3. **Finds similar patterns** - Searches codebase for same antipattern
|
|
25
|
+
4. **Proactively fixes** - Applies fix to all occurrences
|
|
26
|
+
5. **Prevents future** - Adds to .mdc rules if pattern is common
|
|
27
|
+
|
|
28
|
+
## Self-Healing Process
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
32
|
+
│ STEP 1: Analyze Error │
|
|
33
|
+
├─────────────────────────────────────────────────────────────┤
|
|
34
|
+
│ • Parse error message and stack trace │
|
|
35
|
+
│ • Identify root cause pattern │
|
|
36
|
+
│ • Classify error type │
|
|
37
|
+
└─────────────────────────────────────────────────────────────┘
|
|
38
|
+
↓
|
|
39
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
40
|
+
│ STEP 2: Fix Immediate Issue │
|
|
41
|
+
├─────────────────────────────────────────────────────────────┤
|
|
42
|
+
│ • Apply targeted fix │
|
|
43
|
+
│ • Verify fix compiles │
|
|
44
|
+
│ • Run related tests │
|
|
45
|
+
└─────────────────────────────────────────────────────────────┘
|
|
46
|
+
↓
|
|
47
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
48
|
+
│ STEP 3: Find Similar Patterns │
|
|
49
|
+
├─────────────────────────────────────────────────────────────┤
|
|
50
|
+
│ • Search codebase for same pattern │
|
|
51
|
+
│ • Filter by risk (same conditions apply) │
|
|
52
|
+
│ • Rank by likelihood of failure │
|
|
53
|
+
└─────────────────────────────────────────────────────────────┘
|
|
54
|
+
↓
|
|
55
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
56
|
+
│ STEP 4: Proactive Healing │
|
|
57
|
+
├─────────────────────────────────────────────────────────────┤
|
|
58
|
+
│ • Apply same fix to all occurrences │
|
|
59
|
+
│ • Create separate PR or same PR │
|
|
60
|
+
│ • Document in commit message │
|
|
61
|
+
└─────────────────────────────────────────────────────────────┘
|
|
62
|
+
↓
|
|
63
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
64
|
+
│ STEP 5: Prevent Recurrence │
|
|
65
|
+
├─────────────────────────────────────────────────────────────┤
|
|
66
|
+
│ • Add pattern to .cursor/rules/ if common │
|
|
67
|
+
│ • Create ESLint rule if applicable │
|
|
68
|
+
│ • Update /code-standards │
|
|
69
|
+
└─────────────────────────────────────────────────────────────┘
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Example: Race Condition Fix
|
|
73
|
+
|
|
74
|
+
````
|
|
75
|
+
/self-heal "TypeError: Cannot read property 'data' of null"
|
|
76
|
+
|
|
77
|
+
────────────────────────────────────────────────────────────────
|
|
78
|
+
ERROR ANALYSIS
|
|
79
|
+
────────────────────────────────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
Error: TypeError: Cannot read property 'data' of null
|
|
82
|
+
File: src/features/checkout/src/hooks/useBookingData.ts:45
|
|
83
|
+
Stack: useBookingData → useEffect → fetchData → setData
|
|
84
|
+
|
|
85
|
+
Root Cause: Race condition - component unmounted before async resolved
|
|
86
|
+
|
|
87
|
+
Pattern Detected:
|
|
88
|
+
```typescript
|
|
89
|
+
// ❌ Antipattern: No cleanup, state update on unmounted component
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
fetchData().then(result => {
|
|
92
|
+
setData(result.data); // May run after unmount
|
|
93
|
+
});
|
|
94
|
+
}, [id]);
|
|
95
|
+
````
|
|
96
|
+
|
|
97
|
+
────────────────────────────────────────────────────────────────
|
|
98
|
+
IMMEDIATE FIX
|
|
99
|
+
────────────────────────────────────────────────────────────────
|
|
100
|
+
|
|
101
|
+
Applied to: useBookingData.ts:45
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// ✅ Fixed: AbortController prevents race condition
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
const controller = new AbortController();
|
|
107
|
+
|
|
108
|
+
const fetchData = async () => {
|
|
109
|
+
try {
|
|
110
|
+
const result = await api.getData(id, { signal: controller.signal });
|
|
111
|
+
setData(result.data);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
if (!controller.signal.aborted) {
|
|
114
|
+
setError(err as ApiError);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
fetchData();
|
|
120
|
+
return () => controller.abort();
|
|
121
|
+
}, [id]);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
────────────────────────────────────────────────────────────────
|
|
125
|
+
SIMILAR PATTERNS FOUND
|
|
126
|
+
────────────────────────────────────────────────────────────────
|
|
127
|
+
|
|
128
|
+
Searching for: `useEffect.*fetchData.*then.*set[A-Z]` without AbortController
|
|
129
|
+
|
|
130
|
+
| File | Line | Risk | Status |
|
|
131
|
+
| -------------------- | ---- | --------- | --------------- |
|
|
132
|
+
| useOfferData.ts | 23 | 🔴 HIGH | Same pattern |
|
|
133
|
+
| useUserProfile.ts | 56 | 🔴 HIGH | Same pattern |
|
|
134
|
+
| usePaymentMethods.ts | 34 | 🔴 HIGH | Same pattern |
|
|
135
|
+
| useBranches.ts | 89 | 🟠 MEDIUM | Similar pattern |
|
|
136
|
+
| useVehicles.ts | 12 | 🟠 MEDIUM | Similar pattern |
|
|
137
|
+
|
|
138
|
+
Total: 5 files with same antipattern
|
|
139
|
+
|
|
140
|
+
────────────────────────────────────────────────────────────────
|
|
141
|
+
PROACTIVE HEALING
|
|
142
|
+
────────────────────────────────────────────────────────────────
|
|
143
|
+
|
|
144
|
+
Applying fix to 5 additional files...
|
|
145
|
+
|
|
146
|
+
✅ useOfferData.ts:23 - Fixed
|
|
147
|
+
✅ useUserProfile.ts:56 - Fixed
|
|
148
|
+
✅ usePaymentMethods.ts:34 - Fixed
|
|
149
|
+
✅ useBranches.ts:89 - Fixed
|
|
150
|
+
✅ useVehicles.ts:12 - Fixed
|
|
151
|
+
|
|
152
|
+
All files compile successfully.
|
|
153
|
+
|
|
154
|
+
────────────────────────────────────────────────────────────────
|
|
155
|
+
PREVENTION
|
|
156
|
+
────────────────────────────────────────────────────────────────
|
|
157
|
+
|
|
158
|
+
## Rule Added to .cursor/rules/web-standards.mdc
|
|
159
|
+
|
|
160
|
+
```markdown
|
|
161
|
+
### ✅ REQUIRED: AbortController for async useEffect
|
|
162
|
+
|
|
163
|
+
All useEffect hooks with async operations MUST include:
|
|
164
|
+
|
|
165
|
+
1. AbortController setup
|
|
166
|
+
2. Signal passed to fetch/API calls
|
|
167
|
+
3. Cleanup function returning controller.abort()
|
|
168
|
+
4. Aborted check before setState
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## ESLint Rule Suggestion
|
|
172
|
+
|
|
173
|
+
Consider adding `eslint-plugin-react-hooks` rule:
|
|
174
|
+
`exhaustive-deps` with custom cleanup checker
|
|
175
|
+
|
|
176
|
+
────────────────────────────────────────────────────────────────
|
|
177
|
+
SUMMARY
|
|
178
|
+
────────────────────────────────────────────────────────────────
|
|
179
|
+
|
|
180
|
+
| Action | Count |
|
|
181
|
+
| -------------- | ------------ |
|
|
182
|
+
| Files fixed | 6 |
|
|
183
|
+
| Bugs prevented | ~5 potential |
|
|
184
|
+
| Rule added | 1 |
|
|
185
|
+
|
|
186
|
+
Commit message:
|
|
187
|
+
"Fix race condition in async useEffect across 6 hooks
|
|
188
|
+
|
|
189
|
+
Applied AbortController pattern to prevent state updates
|
|
190
|
+
on unmounted components. Fixes TypeError in useBookingData
|
|
191
|
+
and proactively prevents same issue in 5 other hooks."
|
|
192
|
+
|
|
193
|
+
````
|
|
194
|
+
|
|
195
|
+
## Pattern Library
|
|
196
|
+
|
|
197
|
+
| Pattern | Search Regex | Fix Template |
|
|
198
|
+
|---------|--------------|--------------|
|
|
199
|
+
| Race condition | `useEffect.*then.*set[A-Z]` | AbortController |
|
|
200
|
+
| watch() usage | `methods\.watch\(\)` | useWatch |
|
|
201
|
+
| Missing memoization | `yup\.object\(` not in useMemo | useMemo wrapper |
|
|
202
|
+
| Any type | `: any` | Specific type |
|
|
203
|
+
| Console.log | `console\.log` | Remove or debug util |
|
|
204
|
+
| Hardcoded pixels | `[0-9]+px` in styled | spacing() token |
|
|
205
|
+
|
|
206
|
+
## Commands Used
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# Find similar patterns
|
|
210
|
+
grep -rn "useEffect.*then.*setState" --include="*.ts" apps/ libraries/
|
|
211
|
+
|
|
212
|
+
# Check which files lack AbortController
|
|
213
|
+
for f in $(grep -rl "useEffect.*fetch" --include="*.ts" apps/); do
|
|
214
|
+
if ! grep -q "AbortController" "$f"; then
|
|
215
|
+
echo "$f"
|
|
216
|
+
fi
|
|
217
|
+
done
|
|
218
|
+
|
|
219
|
+
# Verify fixes compile
|
|
220
|
+
pnpm compile
|
|
221
|
+
````
|
|
222
|
+
|
|
223
|
+
## AI Execution
|
|
224
|
+
|
|
225
|
+
When user runs `/self-heal {ERROR}`:
|
|
226
|
+
|
|
227
|
+
1. **Parse error** - Extract file, line, message
|
|
228
|
+
2. **Identify pattern** - Match to known antipatterns
|
|
229
|
+
3. **Apply fix** - To immediate location
|
|
230
|
+
4. **Search codebase** - Find similar patterns
|
|
231
|
+
5. **Batch fix** - Apply to all occurrences
|
|
232
|
+
6. **Update rules** - Add to .mdc if common
|
|
233
|
+
7. **Report** - Summary of all changes
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Learn from user patterns, suggest command improvements, evolve automation
|
|
3
|
+
category: AI Self-Improvement
|
|
4
|
+
aliases: [improve, evolve, learn]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Self-Improve - Learn and Evolve Commands
|
|
8
|
+
|
|
9
|
+
Automatically learn from user patterns, suggest improvements, and evolve commands.
|
|
10
|
+
|
|
11
|
+
## How Self-Learning Works
|
|
12
|
+
|
|
13
|
+
### 1. Pattern Recognition
|
|
14
|
+
|
|
15
|
+
I observe and learn from:
|
|
16
|
+
|
|
17
|
+
| What I Observe | What I Learn |
|
|
18
|
+
| --------------------------- | --------------------------------- |
|
|
19
|
+
| Commands you run frequently | Create shortcuts or combine steps |
|
|
20
|
+
| Steps you always skip | Add to auto-skip list |
|
|
21
|
+
| Clarifications you give | Update defaults and assumptions |
|
|
22
|
+
| Corrections you make | Update rules and patterns |
|
|
23
|
+
| Preferences you express | Store in memory |
|
|
24
|
+
|
|
25
|
+
### 2. Trigger Phrases
|
|
26
|
+
|
|
27
|
+
When you say:
|
|
28
|
+
|
|
29
|
+
- "always do X" → I create a memory and update commands
|
|
30
|
+
- "never do Y" → I add to skip list
|
|
31
|
+
- "remember that..." → I store as preference
|
|
32
|
+
- "this is wrong because..." → I learn the correction
|
|
33
|
+
- "better way is..." → I update the approach
|
|
34
|
+
|
|
35
|
+
### 3. Auto-Suggestions
|
|
36
|
+
|
|
37
|
+
After each workflow, I may suggest:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
════════════════════════════════════════════════════════════════
|
|
41
|
+
💡 IMPROVEMENT SUGGESTIONS
|
|
42
|
+
════════════════════════════════════════════════════════════════
|
|
43
|
+
|
|
44
|
+
Based on this session, I noticed:
|
|
45
|
+
|
|
46
|
+
1. **Frequent Pattern**: You always add "How to Test" after PR creation
|
|
47
|
+
→ Suggestion: Make this automatic (no confirmation)
|
|
48
|
+
→ Accept? (y/n)
|
|
49
|
+
|
|
50
|
+
2. **Repeated Clarification**: You always want empty string = missing
|
|
51
|
+
→ Suggestion: Add as default assumption
|
|
52
|
+
→ Accept? (y/n)
|
|
53
|
+
|
|
54
|
+
3. **Skipped Step**: You skipped Confluence docs in last 5 runs
|
|
55
|
+
→ Suggestion: Remove from default flow, make on-demand
|
|
56
|
+
→ Accept? (y/n)
|
|
57
|
+
|
|
58
|
+
4. **New Pattern Detected**: You often run /pr-review after /full-flow
|
|
59
|
+
→ Suggestion: Create /full-flow-with-review command
|
|
60
|
+
→ Accept? (y/n)
|
|
61
|
+
════════════════════════════════════════════════════════════════
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Memory Updates
|
|
65
|
+
|
|
66
|
+
When I learn something, I update my memory:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Example: User says "always skip Confluence docs"
|
|
70
|
+
# I will:
|
|
71
|
+
1. Create memory: "Skip Confluence docs in default full-flow"
|
|
72
|
+
2. Update full-flow.md behavior
|
|
73
|
+
3. Confirm: "Got it! Confluence docs now on-demand only."
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Command Evolution
|
|
77
|
+
|
|
78
|
+
### How Commands Self-Evolve
|
|
79
|
+
|
|
80
|
+
1. **Usage Tracking** (mental model):
|
|
81
|
+
|
|
82
|
+
- Which commands run most
|
|
83
|
+
- Which steps get skipped
|
|
84
|
+
- Which clarifications repeat
|
|
85
|
+
|
|
86
|
+
2. **Feedback Loop**:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
User runs command
|
|
90
|
+
↓
|
|
91
|
+
I observe outcome
|
|
92
|
+
↓
|
|
93
|
+
Note any corrections/preferences
|
|
94
|
+
↓
|
|
95
|
+
Suggest improvements
|
|
96
|
+
↓
|
|
97
|
+
User accepts/rejects
|
|
98
|
+
↓
|
|
99
|
+
Update command behavior
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
3. **Periodic Review**:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
Every few sessions, I'll ask:
|
|
106
|
+
|
|
107
|
+
"I've noticed some patterns in how you work.
|
|
108
|
+
Would you like me to suggest optimizations to the workflow?"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Evolution Examples
|
|
112
|
+
|
|
113
|
+
### Example 1: Learned Skip
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
Before: Always ask "Add How to Test? (y/n)"
|
|
117
|
+
Observed: User says "y" 100% of time
|
|
118
|
+
After: Auto-add, just confirm "✅ How to Test added"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Example 2: Learned Default
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
Before: Ask "Empty string = missing or show empty?"
|
|
125
|
+
Observed: User always picks "missing"
|
|
126
|
+
After: Default to "missing", mention assumption
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Example 3: New Shortcut
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
Observed: User often runs /jira-fetch then /jira-branch
|
|
133
|
+
Created: /jira-start (combines both)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Example 4: Critical Focus
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
Observed: User says "skip minor issues" frequently
|
|
140
|
+
Updated: /pr-review now defaults to critical-only mode
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Suggesting New Commands
|
|
144
|
+
|
|
145
|
+
When I notice a gap, I'll propose:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
💡 COMMAND SUGGESTION
|
|
149
|
+
|
|
150
|
+
I noticed you often:
|
|
151
|
+
1. Fetch ticket
|
|
152
|
+
2. Check if branch exists
|
|
153
|
+
3. Create branch if not
|
|
154
|
+
4. Start implementation
|
|
155
|
+
|
|
156
|
+
This could be a single command: /jira-quick-start
|
|
157
|
+
|
|
158
|
+
Would you like me to create it? (y/n)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Updating Existing Commands
|
|
162
|
+
|
|
163
|
+
When I learn a better approach:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
💡 COMMAND UPDATE SUGGESTION
|
|
167
|
+
|
|
168
|
+
Current: /pr-review posts all issues as comments
|
|
169
|
+
Learned: You prefer critical issues only, minor as summary
|
|
170
|
+
|
|
171
|
+
Proposed change to /pr-review:
|
|
172
|
+
- Default: Post only critical/high-impact issues
|
|
173
|
+
- Summary: Mention minor issues in summary comment
|
|
174
|
+
- Flag: --all to include everything
|
|
175
|
+
|
|
176
|
+
Apply this update? (y/n)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## What I Track (Mentally)
|
|
180
|
+
|
|
181
|
+
| Category | Examples |
|
|
182
|
+
| --------------- | ---------------------------------------- |
|
|
183
|
+
| **Preferences** | Skip confirmations, auto-add docs |
|
|
184
|
+
| **Defaults** | Empty string handling, test coverage |
|
|
185
|
+
| **Patterns** | Command sequences, common clarifications |
|
|
186
|
+
| **Corrections** | Wrong assumptions I made |
|
|
187
|
+
| **Skips** | Steps user never wants |
|
|
188
|
+
|
|
189
|
+
## AI Execution
|
|
190
|
+
|
|
191
|
+
### During Every Command Run:
|
|
192
|
+
|
|
193
|
+
1. **Observe**: What did user do differently than expected?
|
|
194
|
+
2. **Note**: Any corrections, skips, or preferences expressed?
|
|
195
|
+
3. **Learn**: Update mental model
|
|
196
|
+
4. **Suggest**: If pattern is strong, propose improvement
|
|
197
|
+
|
|
198
|
+
### After Multiple Runs:
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
I've worked with you on 5 tickets this week. I noticed:
|
|
202
|
+
|
|
203
|
+
1. You always use Tampa Airport for testing
|
|
204
|
+
→ Should I default to Tampa in test instructions?
|
|
205
|
+
|
|
206
|
+
2. You prefer smaller PRs (< 200 lines)
|
|
207
|
+
→ Should I warn when PR exceeds this?
|
|
208
|
+
|
|
209
|
+
3. You always add @team-lead as reviewer
|
|
210
|
+
→ Should I auto-add as default reviewer?
|
|
211
|
+
|
|
212
|
+
Update preferences? (y/n for each)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Manual Triggers
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Ask for suggestions
|
|
219
|
+
/self-improve suggest
|
|
220
|
+
|
|
221
|
+
# Show what I've learned
|
|
222
|
+
/self-improve show-learnings
|
|
223
|
+
|
|
224
|
+
# Reset a specific learning
|
|
225
|
+
/self-improve reset "skip confluence"
|
|
226
|
+
|
|
227
|
+
# Force update a command
|
|
228
|
+
/self-improve update pr-review "focus on critical only"
|
|
229
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cursor-ai-toolkit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "AI Self-Improvement Commands for Cursor IDE - Learning, Rules, and Context Management",
|
|
5
|
+
"bin": {
|
|
6
|
+
"cursor-ai-toolkit": "./bin/cli.js",
|
|
7
|
+
"ai-toolkit": "./bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./bin/cli.js",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"cursor",
|
|
12
|
+
"cursor-rules",
|
|
13
|
+
"cursor-commands",
|
|
14
|
+
"ai-learning",
|
|
15
|
+
"self-improvement",
|
|
16
|
+
"context-management",
|
|
17
|
+
"dev-productivity",
|
|
18
|
+
"ai-coding"
|
|
19
|
+
],
|
|
20
|
+
"author": "Sharath Chandra",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/sharath317/cursor-ai-toolkit"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/sharath317/cursor-ai-toolkit#readme",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"bin/",
|
|
32
|
+
"commands/"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
|