@lenne.tech/cli 1.0.0 → 1.0.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 (37) hide show
  1. package/build/commands/claude/install-commands.js +337 -0
  2. package/build/commands/claude/install-mcps.js +256 -0
  3. package/build/commands/claude/install-skills.js +91 -20
  4. package/build/commands/server/add-property.js +22 -41
  5. package/build/extensions/server.js +142 -46
  6. package/build/lib/mcp-registry.js +71 -0
  7. package/build/templates/claude-commands/code-cleanup.md +82 -0
  8. package/build/templates/claude-commands/commit-message.md +21 -0
  9. package/build/templates/claude-commands/mr-description-clipboard.md +48 -0
  10. package/build/templates/claude-commands/mr-description.md +33 -0
  11. package/build/templates/claude-commands/sec-review.md +62 -0
  12. package/build/templates/claude-commands/skill-optimize.md +481 -0
  13. package/build/templates/claude-commands/test-generate.md +45 -0
  14. package/build/templates/claude-skills/building-stories-with-tdd/SKILL.md +265 -0
  15. package/build/templates/claude-skills/building-stories-with-tdd/code-quality.md +276 -0
  16. package/build/templates/claude-skills/building-stories-with-tdd/database-indexes.md +182 -0
  17. package/build/templates/claude-skills/building-stories-with-tdd/examples.md +1383 -0
  18. package/build/templates/claude-skills/building-stories-with-tdd/handling-existing-tests.md +197 -0
  19. package/build/templates/claude-skills/building-stories-with-tdd/reference.md +1427 -0
  20. package/build/templates/claude-skills/building-stories-with-tdd/security-review.md +307 -0
  21. package/build/templates/claude-skills/building-stories-with-tdd/workflow.md +1004 -0
  22. package/build/templates/claude-skills/generating-nest-servers/SKILL.md +303 -0
  23. package/build/templates/claude-skills/generating-nest-servers/configuration.md +285 -0
  24. package/build/templates/claude-skills/generating-nest-servers/declare-keyword-warning.md +133 -0
  25. package/build/templates/claude-skills/generating-nest-servers/description-management.md +226 -0
  26. package/build/templates/claude-skills/{nest-server-generator → generating-nest-servers}/examples.md +138 -5
  27. package/build/templates/claude-skills/generating-nest-servers/framework-guide.md +259 -0
  28. package/build/templates/claude-skills/generating-nest-servers/quality-review.md +864 -0
  29. package/build/templates/claude-skills/{nest-server-generator → generating-nest-servers}/reference.md +83 -13
  30. package/build/templates/claude-skills/generating-nest-servers/security-rules.md +371 -0
  31. package/build/templates/claude-skills/generating-nest-servers/verification-checklist.md +262 -0
  32. package/build/templates/claude-skills/generating-nest-servers/workflow-process.md +1061 -0
  33. package/build/templates/claude-skills/{lt-cli → using-lt-cli}/SKILL.md +22 -10
  34. package/build/templates/claude-skills/{lt-cli → using-lt-cli}/examples.md +7 -3
  35. package/build/templates/claude-skills/{lt-cli → using-lt-cli}/reference.md +10 -3
  36. package/package.json +2 -2
  37. package/build/templates/claude-skills/nest-server-generator/SKILL.md +0 -2833
@@ -1,11 +1,27 @@
1
1
  ---
2
2
  name: nest-server-generator-reference
3
- version: 1.0.0
3
+ version: 1.0.1
4
4
  description: Quick reference for ALL NestJS server development - from simple single commands to complex structure generation
5
5
  ---
6
6
 
7
7
  # NestJS Server Development Quick Reference
8
8
 
9
+ ## Table of Contents
10
+ - [Scope](#scope)
11
+ - [Specification Syntax](#specification-syntax)
12
+ - [Execution Workflow](#execution-workflow)
13
+ - [Command Quick Reference](#command-quick-reference)
14
+ - [Description Format](#description-format)
15
+ - [Inheritance Handling](#inheritance-handling)
16
+ - [Enum File Template](#enum-file-template)
17
+ - [API Test Template](#api-test-template)
18
+ - [Common Patterns](#common-patterns)
19
+ - [Troubleshooting](#troubleshooting)
20
+ - [Verification Checklist](#verification-checklist)
21
+ - [File Structure](#file-structure)
22
+ - [Best Practices Summary](#best-practices-summary)
23
+ - [Quick Start](#quick-start)
24
+
9
25
  ## Scope
10
26
 
11
27
  **This skill handles ALL NestJS server development tasks:**
@@ -63,7 +79,13 @@ Use this skill for **ANY** NestJS/nest-server work, no matter how simple or comp
63
79
  ☐ 4. Create all Objects
64
80
  ☐ 5. Create all Modules (dependency order)
65
81
  ☐ 6. Handle inheritance (manual edits)
66
- ☐ 7. Update all descriptions (ENGLISH (DEUTSCH))
82
+ ☐ 7. Update ALL descriptions EVERYWHERE (CRITICAL!)
83
+ ☐ 7.1. Extract ALL user comments (after //) from specification
84
+ ☐ 7.2. Format descriptions: ENGLISH (DEUTSCH)
85
+ ☐ 7.3. Apply to ALL Module files (Model, CreateInput, UpdateInput)
86
+ ☐ 7.4. Apply to ALL SubObject files (Object, CreateInput, UpdateInput)
87
+ ☐ 7.5. Add to ALL class decorators (@ObjectType, @InputType)
88
+ ☐ 7.6. Verify consistency (same property = same description)
67
89
  ☐ 8. Alphabetize all properties
68
90
  ☐ 9. Create enum files
69
91
  ☐ 10. Create API tests
@@ -140,20 +162,57 @@ lt server addProp --type Module --element <Name> \
140
162
 
141
163
  ## Description Format
142
164
 
165
+ **⚠️ CRITICAL:** Always extract descriptions from user comments (after `//`) and apply EVERYWHERE!
166
+
143
167
  **Rule**: `"ENGLISH_DESCRIPTION (DEUTSCHE_BESCHREIBUNG)"`
144
168
 
145
169
  ### Processing
146
170
 
147
- | Input Comment | Output Description |
148
- |---------------|-------------------|
149
- | `// Street name` | `'Street name'` |
150
- | `// Straße` | `'Street (Straße)'` |
151
- | (no comment) | Create meaningful English description |
152
-
153
- ### Apply To
154
- - Model property `@UnifiedField({ description: '...' })`
155
- - Input property `@UnifiedField({ description: '...' })`
156
- - Output property `@UnifiedField({ description: '...' })`
171
+ | Input Comment | Language | Output Description |
172
+ |---------------|----------|-------------------|
173
+ | `// Product name` | English | `'Product name'` |
174
+ | `// Produktname` | German | `'Product name (Produktname)'` |
175
+ | `// Street name` | English | `'Street name'` |
176
+ | `// Straße` | German | `'Street (Straße)'` |
177
+ | `// Postleizahl` (typo) | German | `'Postal code (Postleitzahl)'` (corrected) |
178
+ | (no comment) | - | Create meaningful English description |
179
+
180
+ **⚠️ Preserve Original Wording:**
181
+ - ✅ Fix typos: `Postleizahl` → `Postleitzahl`, `Starße` → `Straße`
182
+ - ❌ DON'T rephrase: `Straße` → `Straßenname` (NO!)
183
+ - ❌ DON'T expand: `Produkt` → `Produktbezeichnung` (NO!)
184
+ - **Reason:** User comments may be predefined terms referenced by external systems
185
+
186
+ ### Apply To ALL Files
187
+
188
+ **For EVERY Module property** (3 files):
189
+ 1. `<module>.model.ts` → Property `@UnifiedField({ description: '...' })`
190
+ 2. `inputs/<module>-create.input.ts` → Property `@UnifiedField({ description: '...' })`
191
+ 3. `inputs/<module>.input.ts` → Property `@UnifiedField({ description: '...' })`
192
+
193
+ **For EVERY SubObject property** (3 files):
194
+ 1. `objects/<object>/<object>.object.ts` → Property `@UnifiedField({ description: '...' })`
195
+ 2. `objects/<object>/<object>-create.input.ts` → Property `@UnifiedField({ description: '...' })`
196
+ 3. `objects/<object>/<object>.input.ts` → Property `@UnifiedField({ description: '...' })`
197
+
198
+ **For class decorators**:
199
+ - `@ObjectType({ description: '...' })` on Models and Objects
200
+ - `@InputType({ description: '...' })` on all Input classes
201
+
202
+ ### Common Mistakes
203
+
204
+ ❌ **WRONG:** Descriptions only in Model, missing in Inputs
205
+ ❌ **WRONG:** German-only descriptions without English translation
206
+ ❌ **WRONG:** Inconsistent descriptions (different in Model vs Input)
207
+ ❌ **WRONG:** Ignoring user-provided comments from specification
208
+ ❌ **WRONG:** Changing wording: `Straße` → `Straßenname` (rephrased!)
209
+ ❌ **WRONG:** Expanding terms: `Produkt` → `Produktbezeichnung` (added word!)
210
+
211
+ ✅ **CORRECT:** Same description in ALL 3 files (Model, CreateInput, UpdateInput)
212
+ ✅ **CORRECT:** Format `ENGLISH (DEUTSCH)` for German comments
213
+ ✅ **CORRECT:** All user comments extracted and applied
214
+ ✅ **CORRECT:** Fix typos only, preserve original wording: `Postleizahl` → `Postleitzahl`
215
+ ✅ **CORRECT:** Keep exact terms: `Straße` → `Street (Straße)` (not "Street name"!)
157
216
 
158
217
  ## Inheritance Handling
159
218
 
@@ -326,7 +385,18 @@ Final checks before completing:
326
385
  ☐ All Objects created
327
386
  ☐ All Modules created
328
387
  ☐ Properties in alphabetical order
329
- Descriptions: "ENGLISH (DEUTSCH)" format
388
+ DESCRIPTIONS - CRITICAL (check ALL):
389
+ ☐ User comments extracted from specification
390
+ ☐ German descriptions → ENGLISH (DEUTSCH) format
391
+ ☐ English descriptions → kept as-is
392
+ ☐ Module Models have descriptions
393
+ ☐ Module CreateInputs have SAME descriptions
394
+ ☐ Module UpdateInputs have SAME descriptions
395
+ ☐ SubObjects have descriptions
396
+ ☐ SubObject CreateInputs have SAME descriptions
397
+ ☐ SubObject UpdateInputs have SAME descriptions
398
+ ☐ @ObjectType/@InputType decorators have descriptions
399
+ ☐ NO inconsistencies between files
330
400
  ☐ Inheritance correctly implemented
331
401
  ☐ CreateInputs have all required fields (parent + model)
332
402
  ☐ Enum files created in src/server/common/enums/
@@ -0,0 +1,371 @@
1
+ ---
2
+ name: nest-server-generator-security-rules
3
+ version: 1.0.0
4
+ description: Critical security and test coverage rules for NestJS development
5
+ ---
6
+
7
+ # 🚨 CRITICAL SECURITY RULES
8
+
9
+ ## Table of Contents
10
+ - [NEVER Do This](#-never-do-this)
11
+ - [ALWAYS Do This](#-always-do-this)
12
+ - [Permission Hierarchy (Specific Overrides General)](#-permission-hierarchy-specific-overrides-general)
13
+ - [Rule 1: NEVER Weaken Security for Test Convenience](#rule-1-never-weaken-security-for-test-convenience)
14
+ - [Rule 2: Understanding Permission Hierarchy](#rule-2-understanding-permission-hierarchy)
15
+ - [Rule 3: Adapt Tests to Security, Not Vice Versa](#rule-3-adapt-tests-to-security-not-vice-versa)
16
+ - [Rule 4: Test with Least Privileged User](#rule-4-test-with-least-privileged-user)
17
+ - [Rule 5: Create Appropriate Test Users](#rule-5-create-appropriate-test-users)
18
+ - [Rule 6: Comprehensive Test Coverage](#rule-6-comprehensive-test-coverage)
19
+ - [Quick Security Checklist](#quick-security-checklist)
20
+ - [Security Decision Protocol](#security-decision-protocol)
21
+
22
+ **Before you start ANY work, understand these NON-NEGOTIABLE rules.**
23
+
24
+ ---
25
+
26
+ ## ⛔ NEVER Do This
27
+
28
+ 1. **NEVER remove or weaken `@Restricted()` decorators** to make tests pass
29
+ 2. **NEVER change `@Roles()` decorators** to more permissive roles for test convenience
30
+ 3. **NEVER modify `securityCheck()` logic** to bypass security in tests
31
+ 4. **NEVER remove class-level `@Restricted(RoleEnum.ADMIN)`** - it's a security fallback
32
+
33
+ ---
34
+
35
+ ## ✅ ALWAYS Do This
36
+
37
+ 1. **ALWAYS analyze permissions BEFORE writing tests** (Controller, Model, Service layers)
38
+ 2. **ALWAYS test with the LEAST privileged user** who is authorized
39
+ 3. **ALWAYS create appropriate test users** for each permission level
40
+ 4. **ALWAYS adapt tests to security requirements**, never the other way around
41
+ 5. **ALWAYS ask developer for approval** before changing ANY security decorator
42
+ 6. **ALWAYS aim for maximum test coverage** (80-100% depending on criticality)
43
+
44
+ ---
45
+
46
+ ## 🔑 Permission Hierarchy (Specific Overrides General)
47
+
48
+ ```typescript
49
+ @Restricted(RoleEnum.ADMIN) // ← FALLBACK: DO NOT REMOVE
50
+ export class ProductController {
51
+ @Roles(RoleEnum.S_USER) // ← SPECIFIC: This method is more open
52
+ async createProduct() { } // ← S_USER can access (specific wins)
53
+
54
+ async secretMethod() { } // ← ADMIN only (fallback applies)
55
+ }
56
+ ```
57
+
58
+ **Why class-level `@Restricted(ADMIN)` MUST stay:**
59
+ - If someone forgets `@Roles()` on a new method → it's secure by default
60
+ - Shows the class is security-sensitive
61
+ - Fail-safe protection
62
+
63
+ ---
64
+
65
+ ## Rule 1: NEVER Weaken Security for Test Convenience
66
+
67
+ ### ❌ ABSOLUTELY FORBIDDEN
68
+
69
+ ```typescript
70
+ // BEFORE (secure):
71
+ @Restricted(RoleEnum.ADMIN)
72
+ export class ProductController {
73
+ @Roles(RoleEnum.S_USER)
74
+ async createProduct() { ... }
75
+ }
76
+
77
+ // AFTER (FORBIDDEN - security weakened!):
78
+ // @Restricted(RoleEnum.ADMIN) ← NEVER remove this!
79
+ export class ProductController {
80
+ @Roles(RoleEnum.S_USER)
81
+ async createProduct() { ... }
82
+ }
83
+ ```
84
+
85
+ ### 🚨 CRITICAL RULE
86
+
87
+ - **NEVER remove or weaken `@Restricted()` decorators** on Controllers, Resolvers, Models, or Objects
88
+ - **NEVER change `@Roles()` decorators** to more permissive roles just to make tests pass
89
+ - **NEVER modify `securityCheck()` logic** to bypass security for testing
90
+
91
+ ### If tests fail due to permissions
92
+
93
+ 1. ✅ **CORRECT**: Adjust the test to use the appropriate user/token
94
+ 2. ✅ **CORRECT**: Create test users with the required roles
95
+ 3. ❌ **WRONG**: Weaken security to make tests pass
96
+
97
+ ### Any security changes MUST
98
+
99
+ - Be discussed with the developer FIRST
100
+ - Have a solid business justification
101
+ - Be explicitly approved by the developer
102
+ - Be documented with the reason
103
+
104
+ ---
105
+
106
+ ## Rule 2: Understanding Permission Hierarchy
107
+
108
+ ### ⭐ Key Concept: Specific Overrides General
109
+
110
+ The `@Restricted()` decorator on a class acts as a **security fallback** - if a method/property doesn't specify permissions, it inherits the class-level restriction. This is a **security-by-default** pattern.
111
+
112
+ ### Example - Controller/Resolver
113
+
114
+ ```typescript
115
+ @Restricted(RoleEnum.ADMIN) // ← FALLBACK: Protects everything by default
116
+ export class ProductController {
117
+
118
+ @Roles(RoleEnum.S_EVERYONE) // ← SPECIFIC: This method is MORE open
119
+ async getPublicProducts() {
120
+ // Anyone can access this (specific @Roles wins)
121
+ }
122
+
123
+ @Roles(RoleEnum.S_USER) // ← SPECIFIC: Logged-in users
124
+ async createProduct() {
125
+ // S_USER can access (specific wins over fallback)
126
+ }
127
+
128
+ async deleteProduct() {
129
+ // ADMIN ONLY (no specific decorator, fallback applies)
130
+ }
131
+ }
132
+ ```
133
+
134
+ ### Example - Model
135
+
136
+ ```typescript
137
+ @Restricted(RoleEnum.ADMIN) // ← FALLBACK
138
+ export class Product {
139
+
140
+ @Roles(RoleEnum.S_EVERYONE) // ← SPECIFIC
141
+ @UnifiedField({ description: 'Product name' })
142
+ name: string; // Everyone can read this
143
+
144
+ @UnifiedField({ description: 'Internal cost' })
145
+ cost: number; // ADMIN ONLY (fallback applies)
146
+ }
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Rule 3: Adapt Tests to Security, Not Vice Versa
152
+
153
+ ### ❌ WRONG Approach
154
+
155
+ ```typescript
156
+ // Test fails because user isn't admin
157
+ it('should create product', async () => {
158
+ const result = await request(app)
159
+ .post('/products')
160
+ .set('Authorization', regularUserToken) // Not an admin!
161
+ .send(productData);
162
+
163
+ expect(result.status).toBe(201); // Fails with 403
164
+ });
165
+
166
+ // ❌ WRONG FIX: Removing @Restricted from controller
167
+ // @Restricted(RoleEnum.ADMIN) ← NEVER DO THIS!
168
+ ```
169
+
170
+ ### ✅ CORRECT Approach
171
+
172
+ ```typescript
173
+ // Analyze first: Who is allowed to create products?
174
+ // Answer: ADMIN only (based on @Restricted on controller)
175
+
176
+ // Create admin test user
177
+ let adminToken: string;
178
+
179
+ beforeAll(async () => {
180
+ const admin = await createTestUser({ roles: [RoleEnum.ADMIN] });
181
+ adminToken = admin.token;
182
+ });
183
+
184
+ it('should create product as admin', async () => {
185
+ const result = await request(app)
186
+ .post('/products')
187
+ .set('Authorization', adminToken) // ✅ Use admin token
188
+ .send(productData);
189
+
190
+ expect(result.status).toBe(201); // ✅ Passes
191
+ });
192
+
193
+ it('should reject product creation for regular user', async () => {
194
+ const result = await request(app)
195
+ .post('/products')
196
+ .set('Authorization', regularUserToken)
197
+ .send(productData);
198
+
199
+ expect(result.status).toBe(403); // ✅ Test security works!
200
+ });
201
+ ```
202
+
203
+ ---
204
+
205
+ ## Rule 4: Test with Least Privileged User
206
+
207
+ **Always test with the LEAST privileged user who is authorized to perform the action.**
208
+
209
+ ### ❌ WRONG
210
+
211
+ ```typescript
212
+ // Method allows S_USER, but testing with ADMIN
213
+ @Roles(RoleEnum.S_USER)
214
+ async getProducts() { }
215
+
216
+ it('should get products', async () => {
217
+ const result = await request(app)
218
+ .get('/products')
219
+ .set('Authorization', adminToken); // ❌ Over-privileged!
220
+ });
221
+ ```
222
+
223
+ ### ✅ CORRECT
224
+
225
+ ```typescript
226
+ @Roles(RoleEnum.S_USER)
227
+ async getProducts() { }
228
+
229
+ it('should get products as regular user', async () => {
230
+ const result = await request(app)
231
+ .get('/products')
232
+ .set('Authorization', regularUserToken); // ✅ Least privilege
233
+ });
234
+ ```
235
+
236
+ **Why this matters:**
237
+ - Tests might pass with ADMIN but fail with S_USER
238
+ - You won't catch permission bugs
239
+ - False confidence in security
240
+
241
+ ---
242
+
243
+ ## Rule 5: Create Appropriate Test Users
244
+
245
+ **Create test users for EACH permission level you need to test.**
246
+
247
+ ### Example Test Setup
248
+
249
+ ```typescript
250
+ describe('ProductController', () => {
251
+ let adminToken: string;
252
+ let userToken: string;
253
+ let everyoneToken: string;
254
+
255
+ beforeAll(async () => {
256
+ // Create admin user
257
+ const admin = await createTestUser({
258
+ roles: [RoleEnum.ADMIN]
259
+ });
260
+ adminToken = admin.token;
261
+
262
+ // Create regular user
263
+ const user = await createTestUser({
264
+ roles: [RoleEnum.S_USER]
265
+ });
266
+ userToken = user.token;
267
+
268
+ // Create unauthenticated scenario
269
+ const guest = await createTestUser({
270
+ roles: [RoleEnum.S_EVERYONE]
271
+ });
272
+ everyoneToken = guest.token;
273
+ });
274
+
275
+ it('admin can delete products', async () => {
276
+ // Use adminToken
277
+ });
278
+
279
+ it('regular user can create products', async () => {
280
+ // Use userToken
281
+ });
282
+
283
+ it('everyone can view products', async () => {
284
+ // Use everyoneToken or no token
285
+ });
286
+
287
+ it('regular user cannot delete products', async () => {
288
+ // Use userToken, expect 403
289
+ });
290
+ });
291
+ ```
292
+
293
+ ---
294
+
295
+ ## Rule 6: Comprehensive Test Coverage
296
+
297
+ **Aim for 80-100% test coverage depending on criticality:**
298
+
299
+ - **High criticality** (payments, user data, admin functions): 95-100%
300
+ - **Medium criticality** (business logic, CRUD): 80-90%
301
+ - **Low criticality** (utilities, formatters): 70-80%
302
+
303
+ ### What to Test
304
+
305
+ **For each endpoint/method:**
306
+
307
+ 1. ✅ Happy path (authorized user, valid data)
308
+ 2. ✅ Permission denied (unauthorized user)
309
+ 3. ✅ Validation errors (invalid input)
310
+ 4. ✅ Edge cases (empty data, boundaries)
311
+ 5. ✅ Error handling (server errors, missing resources)
312
+
313
+ ### Example Comprehensive Tests
314
+
315
+ ```typescript
316
+ describe('createProduct', () => {
317
+ it('should create product with admin user', async () => {
318
+ // Happy path
319
+ });
320
+
321
+ it('should reject creation by regular user', async () => {
322
+ // Permission test
323
+ });
324
+
325
+ it('should reject invalid product data', async () => {
326
+ // Validation test
327
+ });
328
+
329
+ it('should reject duplicate product name', async () => {
330
+ // Business rule test
331
+ });
332
+
333
+ it('should handle missing required fields', async () => {
334
+ // Edge case
335
+ });
336
+ });
337
+ ```
338
+
339
+ ---
340
+
341
+ ## Quick Security Checklist
342
+
343
+ Before completing ANY task:
344
+
345
+ - [ ] **All @Restricted decorators preserved**
346
+ - [ ] **@Roles decorators NOT made more permissive**
347
+ - [ ] **Tests use appropriate user roles**
348
+ - [ ] **Test users created for each permission level**
349
+ - [ ] **Least privileged user tested**
350
+ - [ ] **Permission denial tested (403 responses)**
351
+ - [ ] **No securityCheck() logic bypassed**
352
+ - [ ] **Test coverage ≥ 80%**
353
+ - [ ] **All edge cases covered**
354
+
355
+ ---
356
+
357
+ ## Security Decision Protocol
358
+
359
+ **When you encounter a security-related decision:**
360
+
361
+ 1. **STOP** - Don't make the change immediately
362
+ 2. **ANALYZE** - Why does the current security exist?
363
+ 3. **ASK** - Consult the developer before changing
364
+ 4. **DOCUMENT** - If approved, document the reason
365
+ 5. **TEST** - Ensure security still works after change
366
+
367
+ **Remember:**
368
+ - **Security > Convenience**
369
+ - **Better to over-restrict than under-restrict**
370
+ - **Always preserve existing security mechanisms**
371
+ - **When in doubt, ask the developer**