cursor-kit-cli 1.1.1 → 1.2.0-beta.2

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.
Files changed (94) hide show
  1. package/README.md +36 -0
  2. package/bin/cursor-new-instance +74 -0
  3. package/bin/cursor-remove-instance +69 -0
  4. package/dist/cli.cjs +601 -62
  5. package/dist/cli.cjs.map +1 -1
  6. package/dist/cli.js +601 -62
  7. package/dist/cli.js.map +1 -1
  8. package/dist/index.cjs +39 -1
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +9 -1
  11. package/dist/index.d.ts +9 -1
  12. package/dist/index.js +33 -2
  13. package/dist/index.js.map +1 -1
  14. package/package.json +3 -2
  15. package/templates/commands/docs.md +5 -3
  16. package/templates/commands/explain.md +5 -3
  17. package/templates/commands/fix.md +5 -3
  18. package/templates/commands/implement.md +5 -3
  19. package/templates/commands/refactor.md +5 -3
  20. package/templates/commands/review.md +5 -3
  21. package/templates/commands/test.md +5 -3
  22. package/templates/manifest.json +11 -8
  23. package/templates/rules/git.mdc +0 -2
  24. package/templates/rules/toc.mdc +17 -9
  25. package/templates/skills/aesthetic/SKILL.md +121 -0
  26. package/templates/skills/aesthetic/assets/design-guideline-template.md +163 -0
  27. package/templates/skills/aesthetic/assets/design-story-template.md +135 -0
  28. package/templates/skills/aesthetic/references/design-principles.md +62 -0
  29. package/templates/skills/aesthetic/references/design-resources.md +75 -0
  30. package/templates/skills/aesthetic/references/micro-interactions.md +53 -0
  31. package/templates/skills/aesthetic/references/storytelling-design.md +50 -0
  32. package/templates/skills/backend-development/SKILL.mdc +95 -0
  33. package/templates/skills/backend-development/references/backend-api-design.md +495 -0
  34. package/templates/skills/backend-development/references/backend-architecture.md +454 -0
  35. package/templates/skills/backend-development/references/backend-authentication.md +338 -0
  36. package/templates/skills/backend-development/references/backend-code-quality.md +659 -0
  37. package/templates/skills/backend-development/references/backend-debugging.md +904 -0
  38. package/templates/skills/backend-development/references/backend-devops.md +494 -0
  39. package/templates/skills/backend-development/references/backend-mindset.md +387 -0
  40. package/templates/skills/backend-development/references/backend-performance.md +397 -0
  41. package/templates/skills/backend-development/references/backend-security.md +290 -0
  42. package/templates/skills/backend-development/references/backend-technologies.md +256 -0
  43. package/templates/skills/backend-development/references/backend-testing.md +429 -0
  44. package/templates/skills/frontend-design/SKILL.mdc +41 -0
  45. package/templates/skills/frontend-design/references/animejs.md +396 -0
  46. package/templates/skills/frontend-development/SKILL.mdc +399 -0
  47. package/templates/skills/frontend-development/resources/common-patterns.md +331 -0
  48. package/templates/skills/frontend-development/resources/complete-examples.md +872 -0
  49. package/templates/skills/frontend-development/resources/component-patterns.md +502 -0
  50. package/templates/skills/frontend-development/resources/data-fetching.md +767 -0
  51. package/templates/skills/frontend-development/resources/file-organization.md +502 -0
  52. package/templates/skills/frontend-development/resources/loading-and-error-states.md +501 -0
  53. package/templates/skills/frontend-development/resources/performance.md +406 -0
  54. package/templates/skills/frontend-development/resources/routing-guide.md +364 -0
  55. package/templates/skills/frontend-development/resources/styling-guide.md +428 -0
  56. package/templates/skills/frontend-development/resources/typescript-standards.md +418 -0
  57. package/templates/skills/problem-solving/SKILL.mdc +96 -0
  58. package/templates/skills/problem-solving/references/attribution.md +69 -0
  59. package/templates/skills/problem-solving/references/collision-zone-thinking.md +79 -0
  60. package/templates/skills/problem-solving/references/inversion-exercise.md +91 -0
  61. package/templates/skills/problem-solving/references/meta-pattern-recognition.md +87 -0
  62. package/templates/skills/problem-solving/references/scale-game.md +95 -0
  63. package/templates/skills/problem-solving/references/simplification-cascades.md +80 -0
  64. package/templates/skills/problem-solving/references/when-stuck.md +72 -0
  65. package/templates/skills/research/SKILL.mdc +168 -0
  66. package/templates/skills/sequential-thinking/.env.example +8 -0
  67. package/templates/skills/sequential-thinking/README.md +183 -0
  68. package/templates/skills/sequential-thinking/SKILL.mdc +94 -0
  69. package/templates/skills/sequential-thinking/package.json +31 -0
  70. package/templates/skills/sequential-thinking/references/advanced-strategies.md +79 -0
  71. package/templates/skills/sequential-thinking/references/advanced-techniques.md +76 -0
  72. package/templates/skills/sequential-thinking/references/core-patterns.md +95 -0
  73. package/templates/skills/sequential-thinking/references/examples-api.md +88 -0
  74. package/templates/skills/sequential-thinking/references/examples-architecture.md +94 -0
  75. package/templates/skills/sequential-thinking/references/examples-debug.md +90 -0
  76. package/templates/skills/sequential-thinking/scripts/format-thought.js +159 -0
  77. package/templates/skills/sequential-thinking/scripts/process-thought.js +236 -0
  78. package/templates/skills/sequential-thinking/tests/format-thought.test.js +133 -0
  79. package/templates/skills/sequential-thinking/tests/process-thought.test.js +215 -0
  80. package/templates/skills/ui-styling/LICENSE.txt +202 -0
  81. package/templates/skills/ui-styling/SKILL.mdc +321 -0
  82. package/templates/skills/ui-styling/references/canvas-design-system.md +320 -0
  83. package/templates/skills/ui-styling/references/shadcn-accessibility.md +471 -0
  84. package/templates/skills/ui-styling/references/shadcn-components.md +424 -0
  85. package/templates/skills/ui-styling/references/shadcn-theming.md +373 -0
  86. package/templates/skills/ui-styling/references/tailwind-customization.md +483 -0
  87. package/templates/skills/ui-styling/references/tailwind-responsive.md +382 -0
  88. package/templates/skills/ui-styling/references/tailwind-utilities.md +455 -0
  89. package/templates/rules/frontend-design.mdc +0 -48
  90. package/templates/rules/performance.mdc +0 -54
  91. package/templates/rules/react.mdc +0 -58
  92. package/templates/rules/security.mdc +0 -50
  93. package/templates/rules/testing.mdc +0 -54
  94. package/templates/rules/typescript.mdc +0 -36
@@ -0,0 +1,338 @@
1
+ # Backend Authentication & Authorization
2
+
3
+ Modern authentication patterns including OAuth 2.1, JWT, RBAC, and MFA (2025 standards).
4
+
5
+ ## OAuth 2.1 (2025 Standard)
6
+
7
+ ### Key Changes from OAuth 2.0
8
+
9
+ **Mandatory:**
10
+ - PKCE (Proof Key for Code Exchange) for all clients
11
+ - Exact redirect URI matching
12
+ - State parameter for CSRF protection
13
+
14
+ **Deprecated:**
15
+ - Implicit grant flow (security risk)
16
+ - Resource owner password credentials grant
17
+ - Bearer token in query strings
18
+
19
+ ### Authorization Code Flow with PKCE
20
+
21
+ ```typescript
22
+ // Step 1: Generate code verifier and challenge
23
+ import crypto from 'crypto';
24
+
25
+ const codeVerifier = crypto.randomBytes(32).toString('base64url');
26
+ const codeChallenge = crypto
27
+ .createHash('sha256')
28
+ .update(codeVerifier)
29
+ .digest('base64url');
30
+
31
+ // Step 2: Redirect to authorization endpoint
32
+ const authUrl = new URL('https://auth.example.com/authorize');
33
+ authUrl.searchParams.set('client_id', 'your-client-id');
34
+ authUrl.searchParams.set('redirect_uri', 'https://app.example.com/callback');
35
+ authUrl.searchParams.set('response_type', 'code');
36
+ authUrl.searchParams.set('scope', 'openid profile email');
37
+ authUrl.searchParams.set('state', crypto.randomBytes(16).toString('hex'));
38
+ authUrl.searchParams.set('code_challenge', codeChallenge);
39
+ authUrl.searchParams.set('code_challenge_method', 'S256');
40
+
41
+ // Step 3: Exchange code for token (with code_verifier)
42
+ const tokenResponse = await fetch('https://auth.example.com/token', {
43
+ method: 'POST',
44
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
45
+ body: new URLSearchParams({
46
+ grant_type: 'authorization_code',
47
+ code: authCode,
48
+ redirect_uri: redirectUri,
49
+ client_id: clientId,
50
+ code_verifier: codeVerifier,
51
+ }),
52
+ });
53
+ ```
54
+
55
+ ## JWT (JSON Web Tokens)
56
+
57
+ ### Structure
58
+
59
+ ```
60
+ Header.Payload.Signature
61
+ eyJhbGciOi... . eyJzdWIiOi... . SflKxwRJ...
62
+ ```
63
+
64
+ ### Best Practices (2025)
65
+
66
+ 1. **Short expiration** - Access tokens: 15 minutes, Refresh tokens: 7 days
67
+ 2. **Use RS256** - Asymmetric signing (not HS256 for public APIs)
68
+ 3. **Validate everything** - Signature, issuer, audience, expiration
69
+ 4. **Include minimal claims** - Don't include sensitive data
70
+ 5. **Refresh token rotation** - Issue new refresh token on each use
71
+
72
+ ### Implementation
73
+
74
+ ```typescript
75
+ import jwt from 'jsonwebtoken';
76
+
77
+ // Generate JWT
78
+ const accessToken = jwt.sign(
79
+ {
80
+ sub: user.id,
81
+ email: user.email,
82
+ roles: user.roles,
83
+ },
84
+ process.env.JWT_PRIVATE_KEY,
85
+ {
86
+ algorithm: 'RS256',
87
+ expiresIn: '15m',
88
+ issuer: 'https://api.example.com',
89
+ audience: 'https://app.example.com',
90
+ }
91
+ );
92
+
93
+ // Verify JWT
94
+ const decoded = jwt.verify(token, process.env.JWT_PUBLIC_KEY, {
95
+ algorithms: ['RS256'],
96
+ issuer: 'https://api.example.com',
97
+ audience: 'https://app.example.com',
98
+ });
99
+ ```
100
+
101
+ ## Role-Based Access Control (RBAC)
102
+
103
+ ### RBAC Model
104
+
105
+ ```
106
+ Users → Roles → Permissions → Resources
107
+ ```
108
+
109
+ ### Implementation (NestJS Example)
110
+
111
+ ```typescript
112
+ // Define roles
113
+ export enum Role {
114
+ ADMIN = 'admin',
115
+ EDITOR = 'editor',
116
+ VIEWER = 'viewer',
117
+ }
118
+
119
+ // Role decorator
120
+ export const Roles = (...roles: Role[]) => SetMetadata('roles', roles);
121
+
122
+ // Guard implementation
123
+ @Injectable()
124
+ export class RolesGuard implements CanActivate {
125
+ constructor(private reflector: Reflector) {}
126
+
127
+ canActivate(context: ExecutionContext): boolean {
128
+ const requiredRoles = this.reflector.get<Role[]>('roles', context.getHandler());
129
+ if (!requiredRoles) return true;
130
+
131
+ const request = context.switchToHttp().getRequest();
132
+ const user = request.user;
133
+
134
+ return requiredRoles.some((role) => user.roles?.includes(role));
135
+ }
136
+ }
137
+
138
+ // Usage
139
+ @Post()
140
+ @UseGuards(JwtAuthGuard, RolesGuard)
141
+ @Roles(Role.ADMIN, Role.EDITOR)
142
+ async createPost(@Body() createPostDto: CreatePostDto) {
143
+ return this.postsService.create(createPostDto);
144
+ }
145
+ ```
146
+
147
+ ### RBAC Best Practices
148
+
149
+ 1. **Deny by default** - Explicitly grant permissions
150
+ 2. **Least privilege** - Minimum permissions needed
151
+ 3. **Role hierarchy** - Admin inherits Editor inherits Viewer
152
+ 4. **Separate roles and permissions** - Flexible permission assignment
153
+ 5. **Audit trail** - Log role changes and access
154
+
155
+ ## Multi-Factor Authentication (MFA)
156
+
157
+ ### TOTP (Time-Based One-Time Password)
158
+
159
+ ```typescript
160
+ import speakeasy from 'speakeasy';
161
+ import QRCode from 'qrcode';
162
+
163
+ // Generate secret
164
+ const secret = speakeasy.generateSecret({
165
+ name: 'MyApp',
166
+ issuer: 'MyCompany',
167
+ });
168
+
169
+ // Generate QR code for user
170
+ const qrCode = await QRCode.toDataURL(secret.otpauth_url);
171
+
172
+ // Verify TOTP token
173
+ const verified = speakeasy.totp.verify({
174
+ secret: secret.base32,
175
+ encoding: 'base32',
176
+ token: userToken,
177
+ window: 2, // Allow 2 time steps drift
178
+ });
179
+ ```
180
+
181
+ ### FIDO2/WebAuthn (Passwordless - 2025 Standard)
182
+
183
+ **Benefits:**
184
+ - Phishing-resistant
185
+ - No shared secrets
186
+ - Hardware-backed security
187
+ - Better UX (biometrics, security keys)
188
+
189
+ **Implementation:**
190
+ ```typescript
191
+ // Registration
192
+ const publicKeyCredentialCreationOptions = {
193
+ challenge: crypto.randomBytes(32),
194
+ rp: { name: 'MyApp', id: 'example.com' },
195
+ user: {
196
+ id: Buffer.from(user.id),
197
+ name: user.email,
198
+ displayName: user.name,
199
+ },
200
+ pubKeyCredParams: [{ alg: -7, type: 'public-key' }], // ES256
201
+ authenticatorSelection: {
202
+ authenticatorAttachment: 'platform', // 'platform' or 'cross-platform'
203
+ userVerification: 'required',
204
+ },
205
+ timeout: 60000,
206
+ attestation: 'direct',
207
+ };
208
+
209
+ // Use @simplewebauthn/server library
210
+ import { verifyRegistrationResponse, verifyAuthenticationResponse } from '@simplewebauthn/server';
211
+ ```
212
+
213
+ ## Session Management
214
+
215
+ ### Best Practices
216
+
217
+ 1. **Secure cookies** - HttpOnly, Secure, SameSite=Strict
218
+ 2. **Session timeout** - Idle: 15 minutes, Absolute: 8 hours
219
+ 3. **Regenerate session ID** - After login, privilege elevation
220
+ 4. **Server-side storage** - Redis for distributed systems
221
+ 5. **CSRF protection** - SameSite cookies + CSRF tokens
222
+
223
+ ### Implementation
224
+
225
+ ```typescript
226
+ import session from 'express-session';
227
+ import RedisStore from 'connect-redis';
228
+ import { createClient } from 'redis';
229
+
230
+ const redisClient = createClient();
231
+ await redisClient.connect();
232
+
233
+ app.use(
234
+ session({
235
+ store: new RedisStore({ client: redisClient }),
236
+ secret: process.env.SESSION_SECRET,
237
+ resave: false,
238
+ saveUninitialized: false,
239
+ cookie: {
240
+ secure: true, // HTTPS only
241
+ httpOnly: true, // No JavaScript access
242
+ sameSite: 'strict', // CSRF protection
243
+ maxAge: 1000 * 60 * 15, // 15 minutes
244
+ },
245
+ })
246
+ );
247
+ ```
248
+
249
+ ## Password Security
250
+
251
+ ### Argon2id (2025 Standard - Replaces bcrypt)
252
+
253
+ **Why Argon2id:**
254
+ - Winner of Password Hashing Competition (2015)
255
+ - Memory-hard (resistant to GPU/ASIC attacks)
256
+ - Configurable CPU and memory cost
257
+ - Combines Argon2i (data-independent) + Argon2d (data-dependent)
258
+
259
+ ```typescript
260
+ import argon2 from 'argon2';
261
+
262
+ // Hash password
263
+ const hash = await argon2.hash('password123', {
264
+ type: argon2.argon2id,
265
+ memoryCost: 65536, // 64 MB
266
+ timeCost: 3, // 3 iterations
267
+ parallelism: 4, // 4 threads
268
+ });
269
+
270
+ // Verify password
271
+ const valid = await argon2.verify(hash, 'password123');
272
+ ```
273
+
274
+ ### Password Policy (2025 NIST Guidelines)
275
+
276
+ - **Minimum length:** 12 characters (not 8)
277
+ - **No composition rules** - Allow passphrases
278
+ - **Check against breach databases** - HaveIBeenPwned API
279
+ - **No periodic rotation** - Only on compromise
280
+ - **Allow all printable characters** - Including spaces, emojis
281
+
282
+ ## API Key Authentication
283
+
284
+ ### Best Practices
285
+
286
+ 1. **Prefix keys** - `sk_live_`, `pk_test_` (identify type/environment)
287
+ 2. **Hash stored keys** - Store SHA-256 hash, not plaintext
288
+ 3. **Key rotation** - Allow users to rotate keys
289
+ 4. **Scope limiting** - Separate keys for read/write operations
290
+ 5. **Rate limiting** - Per API key limits
291
+
292
+ ```typescript
293
+ // Generate API key
294
+ const apiKey = `sk_${env}_${crypto.randomBytes(24).toString('base64url')}`;
295
+
296
+ // Store hashed version
297
+ const hashedKey = crypto.createHash('sha256').update(apiKey).digest('hex');
298
+ await db.apiKeys.create({ userId, hashedKey, scopes: ['read'] });
299
+
300
+ // Validate API key
301
+ const providedHash = crypto.createHash('sha256').update(providedKey).digest('hex');
302
+ const keyRecord = await db.apiKeys.findOne({ hashedKey: providedHash });
303
+ ```
304
+
305
+ ## Authentication Decision Matrix
306
+
307
+ | Use Case | Recommended Approach |
308
+ |----------|---------------------|
309
+ | Web application | OAuth 2.1 + JWT |
310
+ | Mobile app | OAuth 2.1 + PKCE |
311
+ | SPA (Single Page App) | OAuth 2.1 Authorization Code + PKCE |
312
+ | Server-to-server | Client credentials grant + mTLS |
313
+ | Third-party API access | API keys with scopes |
314
+ | High-security | WebAuthn/FIDO2 + MFA |
315
+ | Internal admin | JWT + RBAC + MFA |
316
+ | Microservices | Service mesh (mTLS) + JWT |
317
+
318
+ ## Security Checklist
319
+
320
+ - [ ] OAuth 2.1 with PKCE implemented
321
+ - [ ] JWT tokens expire in 15 minutes
322
+ - [ ] Refresh token rotation enabled
323
+ - [ ] RBAC with deny-by-default
324
+ - [ ] MFA required for admin accounts
325
+ - [ ] Passwords hashed with Argon2id
326
+ - [ ] Session cookies: HttpOnly, Secure, SameSite
327
+ - [ ] Rate limiting on auth endpoints (10 attempts/15 min)
328
+ - [ ] Account lockout after failed attempts
329
+ - [ ] Password policy: 12+ chars, breach check
330
+ - [ ] Audit logging for authentication events
331
+
332
+ ## Resources
333
+
334
+ - **OAuth 2.1:** https://oauth.net/2.1/
335
+ - **JWT Best Practices:** https://datatracker.ietf.org/doc/html/rfc8725
336
+ - **WebAuthn:** https://webauthn.guide/
337
+ - **NIST Password Guidelines:** https://pages.nist.gov/800-63-3/
338
+ - **OWASP Auth Cheat Sheet:** https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html