cursor-kit-cli 1.2.0-beta → 1.2.0-beta.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/bin/cursor-reinstall-instance.sh +102 -0
- package/dist/cli.cjs +366 -69
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +367 -70
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +39 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +33 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/commands/docs.md +5 -3
- package/templates/commands/explain.md +5 -3
- package/templates/commands/fix.md +5 -3
- package/templates/commands/implement.md +5 -3
- package/templates/commands/refactor.md +5 -3
- package/templates/commands/review.md +5 -3
- package/templates/commands/test.md +5 -3
- package/templates/manifest.json +11 -8
- package/templates/rules/git.mdc +0 -2
- package/templates/rules/toc.mdc +17 -9
- package/templates/skills/aesthetic/SKILL.md +121 -0
- package/templates/skills/aesthetic/assets/design-guideline-template.md +163 -0
- package/templates/skills/aesthetic/assets/design-story-template.md +135 -0
- package/templates/skills/aesthetic/references/design-principles.md +62 -0
- package/templates/skills/aesthetic/references/design-resources.md +75 -0
- package/templates/skills/aesthetic/references/micro-interactions.md +53 -0
- package/templates/skills/aesthetic/references/storytelling-design.md +50 -0
- package/templates/skills/backend-development/SKILL.mdc +95 -0
- package/templates/skills/backend-development/references/backend-api-design.md +495 -0
- package/templates/skills/backend-development/references/backend-architecture.md +454 -0
- package/templates/skills/backend-development/references/backend-authentication.md +338 -0
- package/templates/skills/backend-development/references/backend-code-quality.md +659 -0
- package/templates/skills/backend-development/references/backend-debugging.md +904 -0
- package/templates/skills/backend-development/references/backend-devops.md +494 -0
- package/templates/skills/backend-development/references/backend-mindset.md +387 -0
- package/templates/skills/backend-development/references/backend-performance.md +397 -0
- package/templates/skills/backend-development/references/backend-security.md +290 -0
- package/templates/skills/backend-development/references/backend-technologies.md +256 -0
- package/templates/skills/backend-development/references/backend-testing.md +429 -0
- package/templates/skills/frontend-design/SKILL.mdc +41 -0
- package/templates/skills/frontend-design/references/animejs.md +396 -0
- package/templates/skills/frontend-development/SKILL.mdc +399 -0
- package/templates/skills/frontend-development/resources/common-patterns.md +331 -0
- package/templates/skills/frontend-development/resources/complete-examples.md +872 -0
- package/templates/skills/frontend-development/resources/component-patterns.md +502 -0
- package/templates/skills/frontend-development/resources/data-fetching.md +767 -0
- package/templates/skills/frontend-development/resources/file-organization.md +502 -0
- package/templates/skills/frontend-development/resources/loading-and-error-states.md +501 -0
- package/templates/skills/frontend-development/resources/performance.md +406 -0
- package/templates/skills/frontend-development/resources/routing-guide.md +364 -0
- package/templates/skills/frontend-development/resources/styling-guide.md +428 -0
- package/templates/skills/frontend-development/resources/typescript-standards.md +418 -0
- package/templates/skills/problem-solving/SKILL.mdc +96 -0
- package/templates/skills/problem-solving/references/attribution.md +69 -0
- package/templates/skills/problem-solving/references/collision-zone-thinking.md +79 -0
- package/templates/skills/problem-solving/references/inversion-exercise.md +91 -0
- package/templates/skills/problem-solving/references/meta-pattern-recognition.md +87 -0
- package/templates/skills/problem-solving/references/scale-game.md +95 -0
- package/templates/skills/problem-solving/references/simplification-cascades.md +80 -0
- package/templates/skills/problem-solving/references/when-stuck.md +72 -0
- package/templates/skills/research/SKILL.mdc +168 -0
- package/templates/skills/sequential-thinking/.env.example +8 -0
- package/templates/skills/sequential-thinking/README.md +183 -0
- package/templates/skills/sequential-thinking/SKILL.mdc +94 -0
- package/templates/skills/sequential-thinking/package.json +31 -0
- package/templates/skills/sequential-thinking/references/advanced-strategies.md +79 -0
- package/templates/skills/sequential-thinking/references/advanced-techniques.md +76 -0
- package/templates/skills/sequential-thinking/references/core-patterns.md +95 -0
- package/templates/skills/sequential-thinking/references/examples-api.md +88 -0
- package/templates/skills/sequential-thinking/references/examples-architecture.md +94 -0
- package/templates/skills/sequential-thinking/references/examples-debug.md +90 -0
- package/templates/skills/sequential-thinking/scripts/format-thought.js +159 -0
- package/templates/skills/sequential-thinking/scripts/process-thought.js +236 -0
- package/templates/skills/sequential-thinking/tests/format-thought.test.js +133 -0
- package/templates/skills/sequential-thinking/tests/process-thought.test.js +215 -0
- package/templates/skills/ui-styling/LICENSE.txt +202 -0
- package/templates/skills/ui-styling/SKILL.mdc +321 -0
- package/templates/skills/ui-styling/references/canvas-design-system.md +320 -0
- package/templates/skills/ui-styling/references/shadcn-accessibility.md +471 -0
- package/templates/skills/ui-styling/references/shadcn-components.md +424 -0
- package/templates/skills/ui-styling/references/shadcn-theming.md +373 -0
- package/templates/skills/ui-styling/references/tailwind-customization.md +483 -0
- package/templates/skills/ui-styling/references/tailwind-responsive.md +382 -0
- package/templates/skills/ui-styling/references/tailwind-utilities.md +455 -0
- package/templates/rules/frontend-design.mdc +0 -48
- package/templates/rules/performance.mdc +0 -54
- package/templates/rules/react.mdc +0 -58
- package/templates/rules/security.mdc +0 -50
- package/templates/rules/testing.mdc +0 -54
- package/templates/rules/typescript.mdc +0 -36
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
# Common Patterns
|
|
2
|
+
|
|
3
|
+
Frequently used patterns for forms, authentication, DataGrid, dialogs, and other common UI elements.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Authentication with useAuth
|
|
8
|
+
|
|
9
|
+
### Getting Current User
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { useAuth } from '@/hooks/useAuth';
|
|
13
|
+
|
|
14
|
+
export const MyComponent: React.FC = () => {
|
|
15
|
+
const { user } = useAuth();
|
|
16
|
+
|
|
17
|
+
// Available properties:
|
|
18
|
+
// - user.id: string
|
|
19
|
+
// - user.email: string
|
|
20
|
+
// - user.username: string
|
|
21
|
+
// - user.roles: string[]
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div>
|
|
25
|
+
<p>Logged in as: {user.email}</p>
|
|
26
|
+
<p>Username: {user.username}</p>
|
|
27
|
+
<p>Roles: {user.roles.join(', ')}</p>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**NEVER make direct API calls for auth** - always use `useAuth` hook.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Forms with React Hook Form
|
|
38
|
+
|
|
39
|
+
### Basic Form
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { useForm } from 'react-hook-form';
|
|
43
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
44
|
+
import { z } from 'zod';
|
|
45
|
+
import { TextField, Button } from '@mui/material';
|
|
46
|
+
import { useMuiSnackbar } from '@/hooks/useMuiSnackbar';
|
|
47
|
+
|
|
48
|
+
// Zod schema for validation
|
|
49
|
+
const formSchema = z.object({
|
|
50
|
+
username: z.string().min(3, 'Username must be at least 3 characters'),
|
|
51
|
+
email: z.string().email('Invalid email address'),
|
|
52
|
+
age: z.number().min(18, 'Must be 18 or older'),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
type FormData = z.infer<typeof formSchema>;
|
|
56
|
+
|
|
57
|
+
export const MyForm: React.FC = () => {
|
|
58
|
+
const { showSuccess, showError } = useMuiSnackbar();
|
|
59
|
+
|
|
60
|
+
const { register, handleSubmit, formState: { errors } } = useForm<FormData>({
|
|
61
|
+
resolver: zodResolver(formSchema),
|
|
62
|
+
defaultValues: {
|
|
63
|
+
username: '',
|
|
64
|
+
email: '',
|
|
65
|
+
age: 18,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const onSubmit = async (data: FormData) => {
|
|
70
|
+
try {
|
|
71
|
+
await api.submitForm(data);
|
|
72
|
+
showSuccess('Form submitted successfully');
|
|
73
|
+
} catch (error) {
|
|
74
|
+
showError('Failed to submit form');
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
80
|
+
<TextField
|
|
81
|
+
{...register('username')}
|
|
82
|
+
label='Username'
|
|
83
|
+
error={!!errors.username}
|
|
84
|
+
helperText={errors.username?.message}
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<TextField
|
|
88
|
+
{...register('email')}
|
|
89
|
+
label='Email'
|
|
90
|
+
error={!!errors.email}
|
|
91
|
+
helperText={errors.email?.message}
|
|
92
|
+
type='email'
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
<TextField
|
|
96
|
+
{...register('age', { valueAsNumber: true })}
|
|
97
|
+
label='Age'
|
|
98
|
+
error={!!errors.age}
|
|
99
|
+
helperText={errors.age?.message}
|
|
100
|
+
type='number'
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
<Button type='submit' variant='contained'>
|
|
104
|
+
Submit
|
|
105
|
+
</Button>
|
|
106
|
+
</form>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Dialog Component Pattern
|
|
114
|
+
|
|
115
|
+
### Standard Dialog Structure
|
|
116
|
+
|
|
117
|
+
From BEST_PRACTICES.md - All dialogs should have:
|
|
118
|
+
- Icon in title
|
|
119
|
+
- Close button (X)
|
|
120
|
+
- Action buttons at bottom
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { Dialog, DialogTitle, DialogContent, DialogActions, Button, IconButton } from '@mui/material';
|
|
124
|
+
import { Close, Info } from '@mui/icons-material';
|
|
125
|
+
|
|
126
|
+
interface MyDialogProps {
|
|
127
|
+
open: boolean;
|
|
128
|
+
onClose: () => void;
|
|
129
|
+
onConfirm: () => void;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const MyDialog: React.FC<MyDialogProps> = ({ open, onClose, onConfirm }) => {
|
|
133
|
+
return (
|
|
134
|
+
<Dialog open={open} onClose={onClose} maxWidth='sm' fullWidth>
|
|
135
|
+
<DialogTitle>
|
|
136
|
+
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
|
137
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
138
|
+
<Info color='primary' />
|
|
139
|
+
Dialog Title
|
|
140
|
+
</Box>
|
|
141
|
+
<IconButton onClick={onClose} size='small'>
|
|
142
|
+
<Close />
|
|
143
|
+
</IconButton>
|
|
144
|
+
</Box>
|
|
145
|
+
</DialogTitle>
|
|
146
|
+
|
|
147
|
+
<DialogContent>
|
|
148
|
+
{/* Content here */}
|
|
149
|
+
</DialogContent>
|
|
150
|
+
|
|
151
|
+
<DialogActions>
|
|
152
|
+
<Button onClick={onClose}>Cancel</Button>
|
|
153
|
+
<Button onClick={onConfirm} variant='contained'>
|
|
154
|
+
Confirm
|
|
155
|
+
</Button>
|
|
156
|
+
</DialogActions>
|
|
157
|
+
</Dialog>
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## DataGrid Wrapper Pattern
|
|
165
|
+
|
|
166
|
+
### Wrapper Component Contract
|
|
167
|
+
|
|
168
|
+
From BEST_PRACTICES.md - DataGrid wrappers should accept:
|
|
169
|
+
|
|
170
|
+
**Required Props:**
|
|
171
|
+
- `rows`: Data array
|
|
172
|
+
- `columns`: Column definitions
|
|
173
|
+
- Loading/error states
|
|
174
|
+
|
|
175
|
+
**Optional Props:**
|
|
176
|
+
- Toolbar components
|
|
177
|
+
- Custom actions
|
|
178
|
+
- Initial state
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { DataGridPro } from '@mui/x-data-grid-pro';
|
|
182
|
+
import type { GridColDef } from '@mui/x-data-grid-pro';
|
|
183
|
+
|
|
184
|
+
interface DataGridWrapperProps {
|
|
185
|
+
rows: any[];
|
|
186
|
+
columns: GridColDef[];
|
|
187
|
+
loading?: boolean;
|
|
188
|
+
toolbar?: React.ReactNode;
|
|
189
|
+
onRowClick?: (row: any) => void;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export const DataGridWrapper: React.FC<DataGridWrapperProps> = ({
|
|
193
|
+
rows,
|
|
194
|
+
columns,
|
|
195
|
+
loading = false,
|
|
196
|
+
toolbar,
|
|
197
|
+
onRowClick,
|
|
198
|
+
}) => {
|
|
199
|
+
return (
|
|
200
|
+
<DataGridPro
|
|
201
|
+
rows={rows}
|
|
202
|
+
columns={columns}
|
|
203
|
+
loading={loading}
|
|
204
|
+
slots={{ toolbar: toolbar ? () => toolbar : undefined }}
|
|
205
|
+
onRowClick={(params) => onRowClick?.(params.row)}
|
|
206
|
+
// Standard configuration
|
|
207
|
+
pagination
|
|
208
|
+
pageSizeOptions={[25, 50, 100]}
|
|
209
|
+
initialState={{
|
|
210
|
+
pagination: { paginationModel: { pageSize: 25 } },
|
|
211
|
+
}}
|
|
212
|
+
/>
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Mutation Patterns
|
|
220
|
+
|
|
221
|
+
### Update with Cache Invalidation
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
225
|
+
import { useMuiSnackbar } from '@/hooks/useMuiSnackbar';
|
|
226
|
+
|
|
227
|
+
export const useUpdateEntity = () => {
|
|
228
|
+
const queryClient = useQueryClient();
|
|
229
|
+
const { showSuccess, showError } = useMuiSnackbar();
|
|
230
|
+
|
|
231
|
+
return useMutation({
|
|
232
|
+
mutationFn: ({ id, data }: { id: number; data: any }) =>
|
|
233
|
+
api.updateEntity(id, data),
|
|
234
|
+
|
|
235
|
+
onSuccess: (result, variables) => {
|
|
236
|
+
// Invalidate affected queries
|
|
237
|
+
queryClient.invalidateQueries({ queryKey: ['entity', variables.id] });
|
|
238
|
+
queryClient.invalidateQueries({ queryKey: ['entities'] });
|
|
239
|
+
|
|
240
|
+
showSuccess('Entity updated');
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
onError: () => {
|
|
244
|
+
showError('Failed to update entity');
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// Usage
|
|
250
|
+
const updateEntity = useUpdateEntity();
|
|
251
|
+
|
|
252
|
+
const handleSave = () => {
|
|
253
|
+
updateEntity.mutate({ id: 123, data: { name: 'New Name' } });
|
|
254
|
+
};
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## State Management Patterns
|
|
260
|
+
|
|
261
|
+
### TanStack Query for Server State (PRIMARY)
|
|
262
|
+
|
|
263
|
+
Use TanStack Query for **all server data**:
|
|
264
|
+
- Fetching: useSuspenseQuery
|
|
265
|
+
- Mutations: useMutation
|
|
266
|
+
- Caching: Automatic
|
|
267
|
+
- Synchronization: Built-in
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
// ✅ CORRECT - TanStack Query for server data
|
|
271
|
+
const { data: users } = useSuspenseQuery({
|
|
272
|
+
queryKey: ['users'],
|
|
273
|
+
queryFn: () => userApi.getUsers(),
|
|
274
|
+
});
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### useState for UI State
|
|
278
|
+
|
|
279
|
+
Use `useState` for **local UI state only**:
|
|
280
|
+
- Form inputs (uncontrolled)
|
|
281
|
+
- Modal open/closed
|
|
282
|
+
- Selected tab
|
|
283
|
+
- Temporary UI flags
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
// ✅ CORRECT - useState for UI state
|
|
287
|
+
const [modalOpen, setModalOpen] = useState(false);
|
|
288
|
+
const [selectedTab, setSelectedTab] = useState(0);
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Zustand for Global Client State (Minimal)
|
|
292
|
+
|
|
293
|
+
Use Zustand only for **global client state**:
|
|
294
|
+
- Theme preference
|
|
295
|
+
- Sidebar collapsed state
|
|
296
|
+
- User preferences (not from server)
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
import { create } from 'zustand';
|
|
300
|
+
|
|
301
|
+
interface AppState {
|
|
302
|
+
sidebarOpen: boolean;
|
|
303
|
+
toggleSidebar: () => void;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export const useAppState = create<AppState>((set) => ({
|
|
307
|
+
sidebarOpen: true,
|
|
308
|
+
toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),
|
|
309
|
+
}));
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Avoid prop drilling** - use context or Zustand instead.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Summary
|
|
317
|
+
|
|
318
|
+
**Common Patterns:**
|
|
319
|
+
- ✅ useAuth hook for current user (id, email, roles, username)
|
|
320
|
+
- ✅ React Hook Form + Zod for forms
|
|
321
|
+
- ✅ Dialog with icon + close button
|
|
322
|
+
- ✅ DataGrid wrapper contracts
|
|
323
|
+
- ✅ Mutations with cache invalidation
|
|
324
|
+
- ✅ TanStack Query for server state
|
|
325
|
+
- ✅ useState for UI state
|
|
326
|
+
- ✅ Zustand for global client state (minimal)
|
|
327
|
+
|
|
328
|
+
**See Also:**
|
|
329
|
+
- [data-fetching.md](data-fetching.md) - TanStack Query patterns
|
|
330
|
+
- [component-patterns.md](component-patterns.md) - Component structure
|
|
331
|
+
- [loading-and-error-states.md](loading-and-error-states.md) - Error handling
|