@lenne.tech/cli 1.2.0 → 1.3.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.
Files changed (36) hide show
  1. package/build/commands/claude/install-plugin.js +339 -0
  2. package/package.json +1 -1
  3. package/build/commands/claude/install-commands.js +0 -337
  4. package/build/commands/claude/install-mcps.js +0 -258
  5. package/build/commands/claude/install-skills.js +0 -693
  6. package/build/lib/mcp-registry.js +0 -80
  7. package/build/templates/claude-commands/code-cleanup.md +0 -82
  8. package/build/templates/claude-commands/commit-message.md +0 -21
  9. package/build/templates/claude-commands/create-story.md +0 -435
  10. package/build/templates/claude-commands/mr-description-clipboard.md +0 -48
  11. package/build/templates/claude-commands/mr-description.md +0 -33
  12. package/build/templates/claude-commands/sec-review.md +0 -62
  13. package/build/templates/claude-commands/skill-optimize.md +0 -481
  14. package/build/templates/claude-commands/test-generate.md +0 -45
  15. package/build/templates/claude-skills/building-stories-with-tdd/SKILL.md +0 -265
  16. package/build/templates/claude-skills/building-stories-with-tdd/code-quality.md +0 -276
  17. package/build/templates/claude-skills/building-stories-with-tdd/database-indexes.md +0 -182
  18. package/build/templates/claude-skills/building-stories-with-tdd/examples.md +0 -1383
  19. package/build/templates/claude-skills/building-stories-with-tdd/handling-existing-tests.md +0 -197
  20. package/build/templates/claude-skills/building-stories-with-tdd/reference.md +0 -1427
  21. package/build/templates/claude-skills/building-stories-with-tdd/security-review.md +0 -307
  22. package/build/templates/claude-skills/building-stories-with-tdd/workflow.md +0 -1004
  23. package/build/templates/claude-skills/generating-nest-servers/SKILL.md +0 -303
  24. package/build/templates/claude-skills/generating-nest-servers/configuration.md +0 -285
  25. package/build/templates/claude-skills/generating-nest-servers/declare-keyword-warning.md +0 -133
  26. package/build/templates/claude-skills/generating-nest-servers/description-management.md +0 -226
  27. package/build/templates/claude-skills/generating-nest-servers/examples.md +0 -893
  28. package/build/templates/claude-skills/generating-nest-servers/framework-guide.md +0 -259
  29. package/build/templates/claude-skills/generating-nest-servers/quality-review.md +0 -864
  30. package/build/templates/claude-skills/generating-nest-servers/reference.md +0 -487
  31. package/build/templates/claude-skills/generating-nest-servers/security-rules.md +0 -371
  32. package/build/templates/claude-skills/generating-nest-servers/verification-checklist.md +0 -262
  33. package/build/templates/claude-skills/generating-nest-servers/workflow-process.md +0 -1061
  34. package/build/templates/claude-skills/using-lt-cli/SKILL.md +0 -284
  35. package/build/templates/claude-skills/using-lt-cli/examples.md +0 -546
  36. package/build/templates/claude-skills/using-lt-cli/reference.md +0 -513
@@ -1,265 +0,0 @@
1
- ---
2
- name: building-stories-with-tdd
3
- version: 1.2.0
4
- description: Expert for building user stories using Test-Driven Development (TDD) with NestJS and @lenne.tech/nest-server. Implements new features by creating story tests first in tests/stories/, then uses generating-nest-servers skill to develop code until all tests pass. Ensures high code quality and security compliance. Use in projects with @lenne.tech/nest-server in package.json dependencies (supports monorepos with projects/*, packages/*, apps/* structure).
5
- ---
6
-
7
- # Story-Based Test-Driven Development Expert
8
-
9
- You are an expert in Test-Driven Development (TDD) for NestJS applications using @lenne.tech/nest-server. You help developers implement new features by first creating comprehensive story tests, then iteratively developing the code until all tests pass.
10
-
11
- ## When to Use This Skill
12
-
13
- **✅ ALWAYS use this skill for:**
14
- - Implementing new API features using Test-Driven Development
15
- - Creating story tests for user stories or requirements
16
- - Developing new functionality in a test-first approach
17
- - Ensuring comprehensive test coverage for new features
18
- - Iterative development with test validation
19
-
20
- ## Related Skills
21
-
22
- **🔄 Works closely with:**
23
- - `generating-nest-servers` skill - For code implementation (modules, objects, properties)
24
- - `using-lt-cli` skill - For Git operations and project initialization
25
-
26
- **When to use which:**
27
- - Building new features with TDD? → Use this skill (building-stories-with-tdd)
28
- - Direct NestJS work without TDD? → Use `generating-nest-servers` skill
29
- - Git operations? → Use `using-lt-cli` skill
30
-
31
- ---
32
-
33
- ## 🚨 GOLDEN RULES: API-First Testing 🚨
34
-
35
- **READ THIS BEFORE WRITING ANY TEST!**
36
-
37
- ### Rule 1: Test Through API Only
38
-
39
- **Tests MUST go through REST/GraphQL interfaces using TestHelper. Direct Service or Database access in test logic makes tests WORTHLESS.**
40
-
41
- **Why this rule is absolute:**
42
- - **Security**: Direct Service calls bypass authentication, authorization, guards, decorators
43
- - **Reality**: Tests must verify what actual users experience through the API
44
- - **Worthless**: Tests bypassing the API cannot catch real bugs in the security layer
45
-
46
- **✅ ALWAYS:**
47
- - Use `testHelper.rest()` for REST endpoints
48
- - Use `testHelper.graphQl()` for GraphQL operations
49
- - Test the complete chain: API → Guards → Service → Database
50
-
51
- **❌ NEVER:**
52
- - Call Services directly: `userService.create()` ❌
53
- - Query DB in tests: `db.collection('users').findOne()` ❌
54
- - Mock Controllers/Resolvers ❌
55
-
56
- **🔓 Only Exception: Setup/Cleanup**
57
- - Setting roles: `db.collection('users').updateOne({ _id: id }, { $set: { roles: ['admin'] } })` ✅
58
- - Setting verified: `db.collection('users').updateOne({ _id: id }, { $set: { verified: true } })` ✅
59
- - Cleanup: `db.collection('entities').deleteMany({ createdBy: userId })` ✅
60
-
61
- ### Rule 2: Verify Before Assuming
62
-
63
- **NEVER assume endpoints, methods, or properties exist - ALWAYS verify by reading the actual code!**
64
-
65
- **✅ BEFORE writing tests:**
66
- - Read Controller files to verify endpoints exist
67
- - Read Resolver files to verify GraphQL operations exist
68
- - Read existing tests to understand patterns
69
- - Document what you verified with file references
70
-
71
- **✅ BEFORE implementing:**
72
- - Read Service files to verify method signatures
73
- - Read Model files to verify properties and types
74
- - Read CrudService base class to understand inherited methods
75
- - Check actual code, don't assume!
76
-
77
- **❌ NEVER:**
78
- - Assume an endpoint exists without reading the controller ❌
79
- - Assume a method signature without reading the service ❌
80
- - Guess property names without reading the model ❌
81
-
82
- **Full details in Steps 1, 2, and 4 below.**
83
-
84
- ---
85
-
86
- ## Core TDD Workflow - The Seven Steps
87
-
88
- **📖 Complete workflow details: `workflow.md`**
89
-
90
- **Process:** Step 1 (Analysis) → Step 2 (Create Test) → Step 3 (Run Tests) → [Step 3a: Fix Tests if needed] → Step 4 (Implement) → Step 5 (Validate) → Step 5a (Quality Check) → Step 5b (Final Validation)
91
-
92
- ---
93
-
94
- ### Step 1: Story Analysis & Validation
95
- **📖 Details: `workflow.md` → Step 1**
96
-
97
- - Read story, verify existing API structure (read Controllers/Resolvers)
98
- - Document what exists vs what needs creation
99
- - Ask for clarification if ambiguous (use AskUserQuestion)
100
-
101
- ### Step 2: Create Story Test
102
- **📖 Details: `workflow.md` → Step 2**
103
-
104
- **🚨 CRITICAL: Test through API only - NEVER direct Service/DB access!**
105
-
106
- - ✅ Use `testHelper.rest()` or `testHelper.graphQl()`
107
- - ❌ NEVER call Services directly or query DB in test logic
108
- - 🔓 Exception: Direct DB access ONLY for setup/cleanup (roles, verified status)
109
-
110
- **Test Data Rules (parallel execution):**
111
- 1. Emails MUST end with `@test.com` (use: `user-${Date.now()}-${Math.random().toString(36).substring(2, 8)}@test.com`)
112
- 2. Never reuse data across test files
113
- 3. Only delete entities created in same test file
114
- 4. Implement complete cleanup in `afterAll`
115
-
116
- ### Step 3: Run Tests & Analyze
117
- **📖 Details: `workflow.md` → Step 3**
118
-
119
- ```bash
120
- npm test # Or: npm test -- tests/stories/your-story.story.test.ts
121
- ```
122
-
123
- **Decide:** Test bugs → Step 3a | Implementation missing → Step 4
124
-
125
- ### Step 3a: Fix Test Errors
126
- **📖 Details: `workflow.md` → Step 3a**
127
-
128
- Fix test logic/errors. NEVER "fix" by removing security. Return to Step 3 after fixing.
129
-
130
- ### Step 4: Implement/Extend API Code
131
- **📖 Details: `workflow.md` → Step 4**
132
-
133
- **Use `generating-nest-servers` skill for:** Module/object creation, understanding existing code
134
-
135
- **Critical Rules:**
136
- 1. **Property Descriptions:** Format as `ENGLISH (GERMAN)` when user provides German comments
137
- 2. **ServiceOptions:** Only pass what's needed (usually just `currentUser`), NOT all options
138
- 3. **Guards:** DON'T add `@UseGuards(AuthGuard(...))` - automatically activated by `@Roles()`
139
- 4. **Database indexes:** Define in @UnifiedField decorator (see `database-indexes.md`)
140
-
141
- ### Step 5: Validate & Iterate
142
- **📖 Details: `workflow.md` → Step 5**
143
-
144
- ```bash
145
- npm test
146
- ```
147
-
148
- ✅ All pass → Step 5a | ❌ Fail → Return to Step 3
149
-
150
- ### Step 5a: Code Quality & Refactoring Check
151
- **📖 Details: `workflow.md` → Step 5a**
152
-
153
- Review: Code quality (`code-quality.md`), Database indexes (`database-indexes.md`), Security (`security-review.md`). Run tests after changes.
154
-
155
- ### Step 5b: Final Validation
156
- **📖 Details: `workflow.md` → Step 5b**
157
-
158
- Run all tests, verify quality checks, generate final report. DONE! 🎉
159
-
160
- ## 🔄 Handling Existing Tests When Modifying Code
161
-
162
- **📖 Complete details: `handling-existing-tests.md`**
163
-
164
- **When your changes break existing tests:**
165
- - Intentional change? → Update tests + document why
166
- - Unclear? → Investigate with git (`git show HEAD`, `git diff`), fix to satisfy both old & new tests
167
-
168
- **Remember:** Existing tests document expected behavior - preserve backward compatibility!
169
-
170
- ---
171
-
172
- ## ⛔ CRITICAL: GIT COMMITS
173
-
174
- **🚨 NEVER create git commits unless explicitly requested by the developer.**
175
-
176
- Your responsibility:
177
- - ✅ Create/modify files, run tests, provide comprehensive report
178
- - ❌ **NEVER commit to git without explicit request**
179
-
180
- You may remind in final report: "Implementation complete - review and commit when ready."
181
-
182
- ---
183
-
184
- ## 🚨 CRITICAL SECURITY RULES
185
-
186
- **📖 Complete details: `security-review.md`**
187
-
188
- ### ⛔ NEVER:
189
- - Remove/weaken `@Restricted()` or `@Roles()` decorators
190
- - Modify `securityCheck()` to bypass security
191
- - Add `@UseGuards(AuthGuard(...))` manually (automatically activated by `@Roles()`)
192
-
193
- ### ✅ ALWAYS:
194
- - Analyze existing security before writing tests
195
- - Create appropriate test users with correct roles
196
- - Test with least-privileged users
197
- - Ask before changing ANY security decorator
198
-
199
- **When tests fail due to security:** Create proper test users with appropriate roles, NEVER remove security decorators.
200
-
201
- ## Code Quality Standards
202
-
203
- **📖 Complete details: `code-quality.md`**
204
-
205
- **Must follow:**
206
- - File organization, naming conventions, import statements from existing code
207
- - Error handling and validation patterns
208
- - Use @lenne.tech/nest-server first, add packages as last resort
209
-
210
- **Test quality:**
211
- - 80-100% coverage, self-documenting, independent, repeatable, fast
212
-
213
- **🚨 NEVER use `declare` keyword** - it prevents decorators from working!
214
-
215
- ## Autonomous Execution
216
-
217
- **Work autonomously:** Create tests, run tests, fix code, iterate Steps 3-5, use nest-server-generator skill
218
-
219
- **Only ask when:** Story ambiguous, security changes needed, new packages, architectural decisions, persistent failures
220
-
221
- ## Final Report
222
-
223
- When all tests pass, provide comprehensive report including:
224
- - Story name, tests created (location, count, coverage)
225
- - Implementation summary (modules/objects/properties created/modified)
226
- - Test results (all passing, scenarios summary)
227
- - Code quality (patterns followed, security preserved, dependencies, refactoring, indexes)
228
- - Security review (auth/authz, validation, data exposure, ownership, injection prevention, errors, security tests)
229
- - Files modified (with changes description)
230
- - Next steps (recommendations)
231
-
232
- ## Common Patterns
233
-
234
- **📖 Complete patterns and examples: `examples.md` and `reference.md`**
235
-
236
- **Study existing tests first!** Common patterns:
237
- - Create test users via `/auth/signin`, set roles/verified via DB
238
- - REST requests: `testHelper.rest('/api/...', { method, payload, token, statusCode })`
239
- - GraphQL queries: `testHelper.graphQl({ name, type, arguments, fields }, { token })`
240
- - Test organization: `describe` blocks for Happy Path, Error Cases, Edge Cases
241
-
242
- ## Integration with generating-nest-servers
243
-
244
- **During Step 4 (Implementation), use `generating-nest-servers` skill for:**
245
- - Module creation (`lt server module`)
246
- - Object creation (`lt server object`)
247
- - Adding properties (`lt server addProp`)
248
- - Understanding existing code (Services, Controllers, Resolvers, Models, DTOs)
249
-
250
- **Best Practice:** Invoke skill for NestJS component work rather than manual editing.
251
-
252
- ## Remember
253
-
254
- 1. Tests first, code second - write tests before implementation
255
- 2. Iterate until green - all tests must pass
256
- 3. Security review mandatory - check before final tests
257
- 4. Refactor before done - extract common functionality
258
- 5. Security is sacred - never compromise for passing tests
259
- 6. Quality over speed - good tests and clean code
260
- 7. Ask when uncertain - clarify early
261
- 8. Autonomous execution - work independently, report comprehensively
262
- 9. Match existing patterns - equivalent implementation
263
- 10. Clean up test data - comprehensive cleanup in afterAll
264
-
265
- **Goal:** Deliver fully tested, high-quality, maintainable, secure features that integrate seamlessly with existing codebase.
@@ -1,276 +0,0 @@
1
- ---
2
- name: story-tdd-code-quality
3
- version: 1.0.0
4
- description: Code quality and refactoring guidelines for Test-Driven Development
5
- ---
6
-
7
- # Code Quality & Refactoring Check
8
-
9
- ## Table of Contents
10
- - [1. Check for Code Duplication](#1-check-for-code-duplication)
11
- - [2. Extract Common Functionality](#2-extract-common-functionality)
12
- - [3. Consolidate Similar Code Paths](#3-consolidate-similar-code-paths)
13
- - [4. Review for Consistency](#4-review-for-consistency)
14
- - [5. Refactoring Decision Tree](#5-refactoring-decision-tree)
15
- - [6. Run Tests After Refactoring](#6-run-tests-after-refactoring)
16
- - [7. When to Skip Refactoring](#7-when-to-skip-refactoring)
17
- - [Quick Code Quality Checklist](#quick-code-quality-checklist)
18
-
19
- **BEFORE marking the task as complete, perform a code quality review!**
20
-
21
- Once all tests are passing, analyze your implementation for code quality issues.
22
-
23
- ---
24
-
25
- ## 1. Check for Code Duplication
26
-
27
- **Identify redundant code patterns:**
28
- - Repeated logic in multiple methods
29
- - Similar code blocks with minor variations
30
- - Duplicated validation logic
31
- - Repeated data transformations
32
- - Multiple similar helper functions
33
-
34
- **Example of code duplication:**
35
-
36
- ```typescript
37
- // ❌ BAD: Duplicated validation logic
38
- async createProduct(input: ProductInput) {
39
- if (!input.name || input.name.trim().length === 0) {
40
- throw new BadRequestException('Name is required');
41
- }
42
- if (!input.price || input.price <= 0) {
43
- throw new BadRequestException('Price must be positive');
44
- }
45
- // ... create product
46
- }
47
-
48
- async updateProduct(id: string, input: ProductInput) {
49
- if (!input.name || input.name.trim().length === 0) {
50
- throw new BadRequestException('Name is required');
51
- }
52
- if (!input.price || input.price <= 0) {
53
- throw new BadRequestException('Price must be positive');
54
- }
55
- // ... update product
56
- }
57
-
58
- // ✅ GOOD: Extracted to reusable function
59
- private validateProductInput(input: ProductInput) {
60
- if (!input.name || input.name.trim().length === 0) {
61
- throw new BadRequestException('Name is required');
62
- }
63
- if (!input.price || input.price <= 0) {
64
- throw new BadRequestException('Price must be positive');
65
- }
66
- }
67
-
68
- async createProduct(input: ProductInput) {
69
- this.validateProductInput(input);
70
- // ... create product
71
- }
72
-
73
- async updateProduct(id: string, input: ProductInput) {
74
- this.validateProductInput(input);
75
- // ... update product
76
- }
77
- ```
78
-
79
- ---
80
-
81
- ## 2. Extract Common Functionality
82
-
83
- **Look for opportunities to create helper functions:**
84
- - Data transformation logic
85
- - Validation logic
86
- - Query building
87
- - Response formatting
88
- - Common calculations
89
-
90
- **Example of extracting common functionality:**
91
-
92
- ```typescript
93
- // ❌ BAD: Repeated price calculation logic
94
- async createOrder(input: OrderInput) {
95
- let totalPrice = 0;
96
- for (const item of input.items) {
97
- const product = await this.productService.findById(item.productId);
98
- totalPrice += product.price * item.quantity;
99
- }
100
- // ... create order
101
- }
102
-
103
- async estimateOrderPrice(items: OrderItem[]) {
104
- let totalPrice = 0;
105
- for (const item of items) {
106
- const product = await this.productService.findById(item.productId);
107
- totalPrice += product.price * item.quantity;
108
- }
109
- return totalPrice;
110
- }
111
-
112
- // ✅ GOOD: Extracted to reusable helper
113
- private async calculateOrderTotal(items: OrderItem[]): Promise<number> {
114
- let totalPrice = 0;
115
- for (const item of items) {
116
- const product = await this.productService.findById(item.productId);
117
- totalPrice += product.price * item.quantity;
118
- }
119
- return totalPrice;
120
- }
121
-
122
- async createOrder(input: OrderInput) {
123
- const totalPrice = await this.calculateOrderTotal(input.items);
124
- // ... create order
125
- }
126
-
127
- async estimateOrderPrice(items: OrderItem[]) {
128
- return this.calculateOrderTotal(items);
129
- }
130
- ```
131
-
132
- ---
133
-
134
- ## 3. Consolidate Similar Code Paths
135
-
136
- **Identify code paths that can be unified:**
137
- - Methods with similar logic but different parameters
138
- - Conditional branches that can be combined
139
- - Similar error handling patterns
140
-
141
- **Example of consolidating code paths:**
142
-
143
- ```typescript
144
- // ❌ BAD: Similar methods with duplicated logic
145
- async findProductsByCategory(category: string) {
146
- return this.find({
147
- where: { category },
148
- relations: ['reviews', 'supplier'],
149
- order: { createdAt: 'DESC' },
150
- });
151
- }
152
-
153
- async findProductsBySupplier(supplierId: string) {
154
- return this.find({
155
- where: { supplierId },
156
- relations: ['reviews', 'supplier'],
157
- order: { createdAt: 'DESC' },
158
- });
159
- }
160
-
161
- async findProductsByPriceRange(minPrice: number, maxPrice: number) {
162
- return this.find({
163
- where: { price: Between(minPrice, maxPrice) },
164
- relations: ['reviews', 'supplier'],
165
- order: { createdAt: 'DESC' },
166
- });
167
- }
168
-
169
- // ✅ GOOD: Unified method with flexible filtering
170
- async findProducts(filters: {
171
- category?: string;
172
- supplierId?: string;
173
- priceRange?: { min: number; max: number };
174
- }) {
175
- const where: any = {};
176
-
177
- if (filters.category) {
178
- where.category = filters.category;
179
- }
180
-
181
- if (filters.supplierId) {
182
- where.supplierId = filters.supplierId;
183
- }
184
-
185
- if (filters.priceRange) {
186
- where.price = Between(filters.priceRange.min, filters.priceRange.max);
187
- }
188
-
189
- return this.find({
190
- where,
191
- relations: ['reviews', 'supplier'],
192
- order: { createdAt: 'DESC' },
193
- });
194
- }
195
- ```
196
-
197
- ---
198
-
199
- ## 4. Review for Consistency
200
-
201
- **Ensure consistent patterns throughout your implementation:**
202
- - Naming conventions match existing codebase
203
- - Error handling follows project patterns
204
- - Return types are consistent
205
- - Similar operations use similar approaches
206
-
207
- ---
208
-
209
- ## 5. Refactoring Decision Tree
210
-
211
- ```
212
- Code duplication detected?
213
-
214
- ├─► Used in 2+ places?
215
- │ │
216
- │ ├─► YES: Extract to private method
217
- │ │ │
218
- │ │ └─► Used across multiple services?
219
- │ │ │
220
- │ │ ├─► YES: Consider utility class/function
221
- │ │ └─► NO: Keep as private method
222
- │ │
223
- │ └─► NO: Leave as-is (don't over-engineer)
224
-
225
- └─► Complex logic block?
226
-
227
- ├─► Hard to understand?
228
- │ └─► Extract to well-named method
229
-
230
- └─► Simple and clear?
231
- └─► Leave as-is
232
- ```
233
-
234
- ---
235
-
236
- ## 6. Run Tests After Refactoring
237
-
238
- **CRITICAL: After any refactoring:**
239
-
240
- ```bash
241
- npm test
242
- ```
243
-
244
- **Ensure:**
245
- - ✅ All tests still pass
246
- - ✅ No new failures introduced
247
- - ✅ Code is more maintainable
248
- - ✅ No functionality changed
249
-
250
- ---
251
-
252
- ## 7. When to Skip Refactoring
253
-
254
- **Don't refactor if:**
255
- - Code is used in only ONE place
256
- - Extraction would make code harder to understand
257
- - The duplication is coincidental, not conceptual
258
- - Time constraints don't allow for safe refactoring
259
-
260
- **Remember:**
261
- - **Working code > Perfect code**
262
- - **Refactor only if it improves maintainability**
263
- - **Always run tests after refactoring**
264
-
265
- ---
266
-
267
- ## Quick Code Quality Checklist
268
-
269
- Before marking complete:
270
-
271
- - [ ] **No obvious code duplication**
272
- - [ ] **Common functionality extracted to helpers**
273
- - [ ] **Consistent patterns throughout**
274
- - [ ] **Code follows existing patterns**
275
- - [ ] **Proper error handling**
276
- - [ ] **Tests still pass after refactoring**