@lenne.tech/cli 1.0.1 → 1.1.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 (32) hide show
  1. package/build/commands/claude/install-commands.js +10 -5
  2. package/build/commands/claude/install-mcps.js +258 -0
  3. package/build/commands/claude/install-skills.js +90 -23
  4. package/build/lib/mcp-registry.js +80 -0
  5. package/build/templates/claude-commands/commit-message.md +21 -0
  6. package/build/templates/claude-commands/create-story.md +407 -0
  7. package/build/templates/claude-commands/skill-optimize.md +431 -90
  8. package/build/templates/claude-skills/building-stories-with-tdd/SKILL.md +265 -0
  9. package/build/templates/claude-skills/{story-tdd → building-stories-with-tdd}/code-quality.md +10 -0
  10. package/build/templates/claude-skills/{story-tdd → building-stories-with-tdd}/database-indexes.md +9 -0
  11. package/build/templates/claude-skills/{story-tdd → building-stories-with-tdd}/examples.md +115 -64
  12. package/build/templates/claude-skills/building-stories-with-tdd/handling-existing-tests.md +197 -0
  13. package/build/templates/claude-skills/{story-tdd → building-stories-with-tdd}/reference.md +276 -29
  14. package/build/templates/claude-skills/{story-tdd → building-stories-with-tdd}/security-review.md +8 -0
  15. package/build/templates/claude-skills/building-stories-with-tdd/workflow.md +1004 -0
  16. package/build/templates/claude-skills/generating-nest-servers/SKILL.md +303 -0
  17. package/build/templates/claude-skills/{nest-server-generator → generating-nest-servers}/configuration.md +6 -0
  18. package/build/templates/claude-skills/{nest-server-generator → generating-nest-servers}/declare-keyword-warning.md +9 -0
  19. package/build/templates/claude-skills/{nest-server-generator → generating-nest-servers}/description-management.md +9 -0
  20. package/build/templates/claude-skills/{nest-server-generator → generating-nest-servers}/examples.md +7 -0
  21. package/build/templates/claude-skills/generating-nest-servers/framework-guide.md +259 -0
  22. package/build/templates/claude-skills/{nest-server-generator → generating-nest-servers}/quality-review.md +9 -0
  23. package/build/templates/claude-skills/{nest-server-generator → generating-nest-servers}/reference.md +16 -0
  24. package/build/templates/claude-skills/{nest-server-generator → generating-nest-servers}/security-rules.md +13 -0
  25. package/build/templates/claude-skills/generating-nest-servers/verification-checklist.md +262 -0
  26. package/build/templates/claude-skills/generating-nest-servers/workflow-process.md +1061 -0
  27. package/build/templates/claude-skills/{lt-cli → using-lt-cli}/SKILL.md +22 -10
  28. package/build/templates/claude-skills/{lt-cli → using-lt-cli}/examples.md +7 -3
  29. package/build/templates/claude-skills/{lt-cli → using-lt-cli}/reference.md +10 -3
  30. package/package.json +2 -2
  31. package/build/templates/claude-skills/nest-server-generator/SKILL.md +0 -1891
  32. package/build/templates/claude-skills/story-tdd/SKILL.md +0 -1173
@@ -0,0 +1,265 @@
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.
@@ -6,6 +6,16 @@ description: Code quality and refactoring guidelines for Test-Driven Development
6
6
 
7
7
  # Code Quality & Refactoring Check
8
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
+
9
19
  **BEFORE marking the task as complete, perform a code quality review!**
10
20
 
11
21
  Once all tests are passing, analyze your implementation for code quality issues.
@@ -6,6 +6,15 @@ description: Database index guidelines for @UnifiedField decorator - keep indexe
6
6
 
7
7
  # 🔍 Database Indexes with @UnifiedField
8
8
 
9
+ ## Table of Contents
10
+ - [When to Add Indexes](#when-to-add-indexes)
11
+ - [Example Patterns](#example-patterns)
12
+ - [DON'T Create Indexes Separately!](#-dont-create-indexes-separately)
13
+ - [Benefits of Decorator-Based Indexes](#benefits-of-decorator-based-indexes)
14
+ - [Index Verification Checklist](#index-verification-checklist)
15
+ - [Red Flags - Missing Indexes](#red-flags---missing-indexes)
16
+ - [Quick Index Checklist](#quick-index-checklist)
17
+
9
18
  **IMPORTANT: Always define indexes directly in the @UnifiedField decorator!**
10
19
 
11
20
  This keeps indexes visible right where properties are defined, making them easy to spot during code reviews.