@malamute/ai-rules 1.0.0 → 1.2.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 (133) hide show
  1. package/README.md +270 -121
  2. package/bin/cli.js +5 -2
  3. package/configs/_shared/.claude/rules/conventions/documentation.md +324 -0
  4. package/configs/_shared/.claude/rules/conventions/git.md +265 -0
  5. package/configs/_shared/.claude/rules/{performance.md → conventions/performance.md} +1 -1
  6. package/configs/_shared/.claude/rules/conventions/principles.md +334 -0
  7. package/configs/_shared/.claude/rules/devops/ci-cd.md +262 -0
  8. package/configs/_shared/.claude/rules/devops/docker.md +275 -0
  9. package/configs/_shared/.claude/rules/devops/nx.md +194 -0
  10. package/configs/_shared/.claude/rules/domain/backend/api-design.md +203 -0
  11. package/configs/_shared/.claude/rules/lang/csharp/async.md +220 -0
  12. package/configs/_shared/.claude/rules/lang/csharp/csharp.md +314 -0
  13. package/configs/_shared/.claude/rules/lang/csharp/linq.md +210 -0
  14. package/configs/_shared/.claude/rules/lang/python/async.md +337 -0
  15. package/configs/_shared/.claude/rules/lang/python/celery.md +476 -0
  16. package/configs/_shared/.claude/rules/lang/python/config.md +339 -0
  17. package/configs/{python/.claude/rules → _shared/.claude/rules/lang/python}/database/sqlalchemy.md +6 -1
  18. package/configs/_shared/.claude/rules/lang/python/deployment.md +523 -0
  19. package/configs/_shared/.claude/rules/lang/python/error-handling.md +330 -0
  20. package/configs/_shared/.claude/rules/lang/python/migrations.md +421 -0
  21. package/configs/_shared/.claude/rules/lang/python/python.md +172 -0
  22. package/configs/_shared/.claude/rules/lang/python/repository.md +383 -0
  23. package/configs/{python/.claude/rules → _shared/.claude/rules/lang/python}/testing.md +2 -69
  24. package/configs/_shared/.claude/rules/lang/typescript/async.md +447 -0
  25. package/configs/_shared/.claude/rules/lang/typescript/generics.md +356 -0
  26. package/configs/_shared/.claude/rules/lang/typescript/typescript.md +212 -0
  27. package/configs/_shared/.claude/rules/quality/error-handling.md +48 -0
  28. package/configs/_shared/.claude/rules/quality/logging.md +45 -0
  29. package/configs/_shared/.claude/rules/quality/observability.md +240 -0
  30. package/configs/_shared/.claude/rules/quality/testing-patterns.md +65 -0
  31. package/configs/_shared/.claude/rules/security/secrets-management.md +222 -0
  32. package/configs/_shared/.claude/skills/analysis/explore/SKILL.md +257 -0
  33. package/configs/_shared/.claude/skills/analysis/security-audit/SKILL.md +184 -0
  34. package/configs/_shared/.claude/skills/dev/api-endpoint/SKILL.md +126 -0
  35. package/configs/_shared/.claude/{commands/generate-tests.md → skills/dev/generate-tests/SKILL.md} +6 -0
  36. package/configs/_shared/.claude/{commands/fix-issue.md → skills/git/fix-issue/SKILL.md} +6 -0
  37. package/configs/_shared/.claude/{commands/review-pr.md → skills/git/review-pr/SKILL.md} +6 -0
  38. package/configs/_shared/.claude/skills/infra/deploy/SKILL.md +139 -0
  39. package/configs/_shared/.claude/skills/infra/docker/SKILL.md +95 -0
  40. package/configs/_shared/.claude/skills/infra/migration/SKILL.md +158 -0
  41. package/configs/_shared/.claude/skills/nx/nx-affected/SKILL.md +72 -0
  42. package/configs/_shared/.claude/skills/nx/nx-lib/SKILL.md +375 -0
  43. package/configs/_shared/CLAUDE.md +52 -149
  44. package/configs/angular/.claude/rules/{components.md → core/components.md} +69 -15
  45. package/configs/angular/.claude/rules/core/resource.md +285 -0
  46. package/configs/angular/.claude/rules/core/signals.md +323 -0
  47. package/configs/angular/.claude/rules/http.md +338 -0
  48. package/configs/angular/.claude/rules/routing.md +291 -0
  49. package/configs/angular/.claude/rules/ssr.md +312 -0
  50. package/configs/angular/.claude/rules/state/signal-store.md +408 -0
  51. package/configs/angular/.claude/rules/{state.md → state/state.md} +2 -2
  52. package/configs/angular/.claude/rules/testing.md +7 -7
  53. package/configs/angular/.claude/rules/ui/aria.md +422 -0
  54. package/configs/angular/.claude/rules/ui/forms.md +424 -0
  55. package/configs/angular/.claude/rules/ui/pipes-directives.md +335 -0
  56. package/configs/angular/.claude/settings.json +1 -0
  57. package/configs/angular/.claude/skills/ngrx-slice/SKILL.md +362 -0
  58. package/configs/angular/.claude/skills/signal-store/SKILL.md +445 -0
  59. package/configs/angular/CLAUDE.md +24 -216
  60. package/configs/dotnet/.claude/rules/background-services.md +552 -0
  61. package/configs/dotnet/.claude/rules/configuration.md +426 -0
  62. package/configs/dotnet/.claude/rules/ddd.md +447 -0
  63. package/configs/dotnet/.claude/rules/dependency-injection.md +343 -0
  64. package/configs/dotnet/.claude/rules/mediatr.md +320 -0
  65. package/configs/dotnet/.claude/rules/middleware.md +489 -0
  66. package/configs/dotnet/.claude/rules/result-pattern.md +363 -0
  67. package/configs/dotnet/.claude/rules/validation.md +388 -0
  68. package/configs/dotnet/.claude/settings.json +21 -3
  69. package/configs/dotnet/CLAUDE.md +53 -286
  70. package/configs/fastapi/.claude/rules/background-tasks.md +254 -0
  71. package/configs/fastapi/.claude/rules/dependencies.md +170 -0
  72. package/configs/{python → fastapi}/.claude/rules/fastapi.md +61 -1
  73. package/configs/fastapi/.claude/rules/lifespan.md +274 -0
  74. package/configs/fastapi/.claude/rules/middleware.md +229 -0
  75. package/configs/fastapi/.claude/rules/pydantic.md +433 -0
  76. package/configs/fastapi/.claude/rules/responses.md +251 -0
  77. package/configs/fastapi/.claude/rules/routers.md +202 -0
  78. package/configs/fastapi/.claude/rules/security.md +222 -0
  79. package/configs/fastapi/.claude/rules/testing.md +251 -0
  80. package/configs/fastapi/.claude/rules/websockets.md +298 -0
  81. package/configs/fastapi/.claude/settings.json +33 -0
  82. package/configs/fastapi/CLAUDE.md +144 -0
  83. package/configs/flask/.claude/rules/blueprints.md +208 -0
  84. package/configs/flask/.claude/rules/cli.md +285 -0
  85. package/configs/flask/.claude/rules/configuration.md +281 -0
  86. package/configs/flask/.claude/rules/context.md +238 -0
  87. package/configs/flask/.claude/rules/error-handlers.md +278 -0
  88. package/configs/flask/.claude/rules/extensions.md +278 -0
  89. package/configs/flask/.claude/rules/flask.md +171 -0
  90. package/configs/flask/.claude/rules/marshmallow.md +206 -0
  91. package/configs/flask/.claude/rules/security.md +267 -0
  92. package/configs/flask/.claude/rules/testing.md +284 -0
  93. package/configs/flask/.claude/settings.json +33 -0
  94. package/configs/flask/CLAUDE.md +166 -0
  95. package/configs/nestjs/.claude/rules/common-patterns.md +300 -0
  96. package/configs/nestjs/.claude/rules/filters.md +376 -0
  97. package/configs/nestjs/.claude/rules/interceptors.md +317 -0
  98. package/configs/nestjs/.claude/rules/middleware.md +321 -0
  99. package/configs/nestjs/.claude/rules/modules.md +26 -0
  100. package/configs/nestjs/.claude/rules/pipes.md +351 -0
  101. package/configs/nestjs/.claude/rules/websockets.md +451 -0
  102. package/configs/nestjs/.claude/settings.json +16 -2
  103. package/configs/nestjs/CLAUDE.md +57 -215
  104. package/configs/nextjs/.claude/rules/api-routes.md +358 -0
  105. package/configs/nextjs/.claude/rules/authentication.md +355 -0
  106. package/configs/nextjs/.claude/rules/components.md +52 -0
  107. package/configs/nextjs/.claude/rules/data-fetching.md +249 -0
  108. package/configs/nextjs/.claude/rules/database.md +400 -0
  109. package/configs/nextjs/.claude/rules/middleware.md +303 -0
  110. package/configs/nextjs/.claude/rules/routing.md +324 -0
  111. package/configs/nextjs/.claude/rules/seo.md +350 -0
  112. package/configs/nextjs/.claude/rules/server-actions.md +353 -0
  113. package/configs/nextjs/.claude/rules/state/zustand.md +6 -6
  114. package/configs/nextjs/.claude/settings.json +5 -0
  115. package/configs/nextjs/CLAUDE.md +69 -331
  116. package/package.json +23 -9
  117. package/src/cli.js +220 -0
  118. package/src/config.js +29 -0
  119. package/src/index.js +13 -0
  120. package/src/installer.js +361 -0
  121. package/src/merge.js +116 -0
  122. package/src/tech-config.json +29 -0
  123. package/src/utils.js +96 -0
  124. package/configs/python/.claude/rules/flask.md +0 -332
  125. package/configs/python/.claude/settings.json +0 -18
  126. package/configs/python/CLAUDE.md +0 -273
  127. package/src/install.js +0 -315
  128. /package/configs/_shared/.claude/rules/{accessibility.md → domain/frontend/accessibility.md} +0 -0
  129. /package/configs/_shared/.claude/rules/{security.md → security/security.md} +0 -0
  130. /package/configs/_shared/.claude/skills/{debug → dev/debug}/SKILL.md +0 -0
  131. /package/configs/_shared/.claude/skills/{learning → dev/learning}/SKILL.md +0 -0
  132. /package/configs/_shared/.claude/skills/{spec → dev/spec}/SKILL.md +0 -0
  133. /package/configs/_shared/.claude/skills/{review → git/review}/SKILL.md +0 -0
@@ -0,0 +1,375 @@
1
+ ---
2
+ name: nx-lib
3
+ description: Generate an Nx library for any framework with proper structure and tags
4
+ argument-hint: <framework> <type> <scope>/<name>
5
+ ---
6
+
7
+ # Generate Nx Library
8
+
9
+ ## Syntax
10
+
11
+ ```
12
+ /nx-lib <framework> <type> <scope>/<name>
13
+ ```
14
+
15
+ ## Supported Frameworks
16
+
17
+ | Framework | Generator Package |
18
+ |-----------|-------------------|
19
+ | `angular` | `@nx/angular` |
20
+ | `react` | `@nx/react` |
21
+ | `next` | `@nx/next` |
22
+ | `nest` | `@nx/nest` |
23
+ | `node` | `@nx/node` |
24
+ | `js` | `@nx/js` (pure TypeScript) |
25
+ | `dotnet` | `@nx-dotnet/core` |
26
+ | `python` | `@nxlv/python` |
27
+
28
+ ## Library Types by Framework
29
+
30
+ ### Angular
31
+ | Type | Description | Generator |
32
+ |------|-------------|-----------|
33
+ | `feature` | Smart components, pages, routing | `@nx/angular:lib --standalone` |
34
+ | `ui` | Presentational components | `@nx/angular:lib --standalone` |
35
+ | `data-access` | NgRx store, services | `@nx/angular:lib` + NgRx files |
36
+ | `util` | Pure functions, types | `@nx/js:lib` |
37
+
38
+ ### React / Next.js
39
+ | Type | Description | Generator |
40
+ |------|-------------|-----------|
41
+ | `feature` | Pages, containers | `@nx/react:lib` or `@nx/next:lib` |
42
+ | `ui` | Presentational components | `@nx/react:lib` |
43
+ | `data-access` | Zustand/Redux, API hooks | `@nx/react:lib` |
44
+ | `util` | Pure functions, types | `@nx/js:lib` |
45
+
46
+ ### NestJS
47
+ | Type | Description | Generator |
48
+ |------|-------------|-----------|
49
+ | `feature` | Module with controller | `@nx/nest:lib` + controller |
50
+ | `data-access` | Repository, services | `@nx/nest:lib` |
51
+ | `util` | Pure functions, types | `@nx/js:lib` |
52
+
53
+ ### Node / JS
54
+ | Type | Description | Generator |
55
+ |------|-------------|-----------|
56
+ | `util` | Pure functions, types | `@nx/js:lib` |
57
+ | `data-access` | Services, repositories | `@nx/js:lib` |
58
+
59
+ ### .NET
60
+ | Type | Description | Generator |
61
+ |------|-------------|-----------|
62
+ | `webapi` | ASP.NET Core Web API | `@nx-dotnet/core:app --template webapi` |
63
+ | `classlib` | Class library | `@nx-dotnet/core:lib --template classlib` |
64
+ | `feature` | Feature library (CQRS) | `@nx-dotnet/core:lib` + MediatR handlers |
65
+ | `data-access` | EF Core repositories | `@nx-dotnet/core:lib` + DbContext |
66
+ | `util` | Shared utilities | `@nx-dotnet/core:lib --template classlib` |
67
+
68
+ ### Python
69
+ | Type | Description | Generator |
70
+ |------|-------------|-----------|
71
+ | `app` | FastAPI/Flask app | `@nxlv/python:poetry-project` |
72
+ | `lib` | Python library | `@nxlv/python:poetry-project --projectType=library` |
73
+ | `util` | Utility functions | `@nxlv/python:poetry-project --projectType=library` |
74
+
75
+ ## Examples
76
+
77
+ ```bash
78
+ # Angular feature library
79
+ /nx-lib angular feature users/list
80
+
81
+ # Angular data-access with NgRx
82
+ /nx-lib angular data-access users
83
+
84
+ # React UI component library
85
+ /nx-lib react ui shared/button
86
+
87
+ # NestJS feature module
88
+ /nx-lib nest feature orders
89
+
90
+ # Pure TypeScript utility
91
+ /nx-lib js util shared/format
92
+
93
+ # .NET class library
94
+ /nx-lib dotnet classlib shared/domain
95
+
96
+ # .NET Web API
97
+ /nx-lib dotnet webapi orders
98
+
99
+ # .NET data-access with EF Core
100
+ /nx-lib dotnet data-access users
101
+
102
+ # Python FastAPI app
103
+ /nx-lib python app api
104
+
105
+ # Python library
106
+ /nx-lib python lib shared/utils
107
+ ```
108
+
109
+ ## Execution Steps
110
+
111
+ ### Step 1: Parse Arguments
112
+
113
+ ```
114
+ /nx-lib angular data-access users/profile
115
+ │ │ │
116
+ │ │ └── scope: users, name: profile
117
+ │ └── type: data-access
118
+ └── framework: angular
119
+ ```
120
+
121
+ ### Step 2: Run Generator
122
+
123
+ Based on framework and type:
124
+
125
+ ```bash
126
+ # Angular feature/ui
127
+ nx g @nx/angular:lib <name> \
128
+ --directory=libs/<scope>/<type>-<name> \
129
+ --tags="scope:<scope>,type:<type>" \
130
+ --standalone \
131
+ --style=scss \
132
+ --changeDetection=OnPush
133
+
134
+ # Angular data-access
135
+ nx g @nx/angular:lib <name> \
136
+ --directory=libs/<scope>/data-access \
137
+ --tags="scope:<scope>,type:data-access"
138
+ # Then generate NgRx: actions, reducer, effects, selectors
139
+
140
+ # React/Next feature/ui
141
+ nx g @nx/react:lib <name> \
142
+ --directory=libs/<scope>/<type>-<name> \
143
+ --tags="scope:<scope>,type:<type>"
144
+
145
+ # NestJS feature
146
+ nx g @nx/nest:lib <name> \
147
+ --directory=libs/<scope>/feature-<name> \
148
+ --tags="scope:<scope>,type:feature"
149
+ # Then generate controller
150
+
151
+ # Pure JS/TS util
152
+ nx g @nx/js:lib <name> \
153
+ --directory=libs/<scope>/util-<name> \
154
+ --tags="scope:<scope>,type:util" \
155
+ --bundler=none
156
+
157
+ # .NET class library
158
+ nx g @nx-dotnet/core:lib <name> \
159
+ --directory=libs/<scope>/<type>-<name> \
160
+ --template=classlib \
161
+ --tags="scope:<scope>,type:<type>,framework:dotnet"
162
+
163
+ # .NET Web API
164
+ nx g @nx-dotnet/core:app <name> \
165
+ --directory=apps/<name> \
166
+ --template=webapi \
167
+ --tags="scope:<scope>,type:webapi,framework:dotnet"
168
+
169
+ # Python library
170
+ nx g @nxlv/python:poetry-project <name> \
171
+ --directory=libs/<scope>/<type>-<name> \
172
+ --projectType=library \
173
+ --tags="scope:<scope>,type:<type>,framework:python"
174
+
175
+ # Python app
176
+ nx g @nxlv/python:poetry-project <name> \
177
+ --directory=apps/<name> \
178
+ --projectType=application \
179
+ --tags="scope:<scope>,type:app,framework:python"
180
+ ```
181
+
182
+ ### Step 3: Generate Boilerplate by Type
183
+
184
+ #### Angular `data-access`
185
+ ```
186
+ libs/<scope>/data-access/src/lib/
187
+ ├── +state/
188
+ │ ├── <name>.actions.ts
189
+ │ ├── <name>.reducer.ts
190
+ │ ├── <name>.effects.ts
191
+ │ ├── <name>.selectors.ts
192
+ │ └── <name>.state.ts
193
+ ├── services/
194
+ │ └── <name>.service.ts
195
+ └── index.ts
196
+ ```
197
+
198
+ #### Angular `feature`
199
+ ```
200
+ libs/<scope>/feature-<name>/src/lib/
201
+ ├── <name>.component.ts
202
+ ├── <name>.component.html
203
+ ├── <name>.component.scss
204
+ ├── <name>.routes.ts
205
+ └── index.ts
206
+ ```
207
+
208
+ #### Angular `ui`
209
+ ```
210
+ libs/<scope>/ui-<name>/src/lib/
211
+ ├── <name>.component.ts
212
+ ├── <name>.component.html
213
+ ├── <name>.component.scss
214
+ └── index.ts
215
+ ```
216
+
217
+ #### React `data-access`
218
+ ```
219
+ libs/<scope>/data-access/src/lib/
220
+ ├── store/
221
+ │ └── <name>.store.ts # Zustand store
222
+ ├── hooks/
223
+ │ └── use-<name>.ts # Custom hooks
224
+ ├── api/
225
+ │ └── <name>.api.ts # API calls
226
+ └── index.ts
227
+ ```
228
+
229
+ #### NestJS `feature`
230
+ ```
231
+ libs/<scope>/feature-<name>/src/lib/
232
+ ├── <name>.module.ts
233
+ ├── <name>.controller.ts
234
+ ├── <name>.service.ts
235
+ ├── dto/
236
+ │ ├── create-<name>.dto.ts
237
+ │ └── update-<name>.dto.ts
238
+ └── index.ts
239
+ ```
240
+
241
+ #### JS/TS `util`
242
+ ```
243
+ libs/<scope>/util-<name>/src/lib/
244
+ ├── <name>.ts # Functions
245
+ ├── <name>.types.ts # Types/interfaces
246
+ ├── <name>.spec.ts # Tests
247
+ └── index.ts
248
+ ```
249
+
250
+ #### .NET `webapi`
251
+ ```
252
+ apps/<name>/
253
+ ├── Controllers/
254
+ │ └── <Name>Controller.cs
255
+ ├── Program.cs
256
+ ├── appsettings.json
257
+ ├── <Name>.Api.csproj
258
+ └── project.json
259
+ ```
260
+
261
+ #### .NET `classlib`
262
+ ```
263
+ libs/<scope>/<type>-<name>/
264
+ ├── src/
265
+ │ └── <Name>.cs
266
+ ├── <Scope>.<Type>.<Name>.csproj
267
+ └── project.json
268
+ ```
269
+
270
+ #### .NET `data-access`
271
+ ```
272
+ libs/<scope>/data-access/
273
+ ├── src/
274
+ │ ├── DbContext/
275
+ │ │ └── AppDbContext.cs
276
+ │ ├── Repositories/
277
+ │ │ ├── I<Name>Repository.cs
278
+ │ │ └── <Name>Repository.cs
279
+ │ └── Entities/
280
+ │ └── <Name>.cs
281
+ ├── <Scope>.DataAccess.csproj
282
+ └── project.json
283
+ ```
284
+
285
+ #### .NET `feature` (CQRS)
286
+ ```
287
+ libs/<scope>/feature-<name>/
288
+ ├── src/
289
+ │ ├── Commands/
290
+ │ │ ├── Create<Name>/
291
+ │ │ │ ├── Create<Name>Command.cs
292
+ │ │ │ └── Create<Name>Handler.cs
293
+ │ │ └── Update<Name>/
294
+ │ │ ├── Update<Name>Command.cs
295
+ │ │ └── Update<Name>Handler.cs
296
+ │ ├── Queries/
297
+ │ │ └── Get<Name>/
298
+ │ │ ├── Get<Name>Query.cs
299
+ │ │ └── Get<Name>Handler.cs
300
+ │ └── DependencyInjection.cs
301
+ ├── <Scope>.Feature.<Name>.csproj
302
+ └── project.json
303
+ ```
304
+
305
+ #### Python `app` (FastAPI)
306
+ ```
307
+ apps/<name>/
308
+ ├── src/
309
+ │ └── <name>/
310
+ │ ├── __init__.py
311
+ │ ├── main.py
312
+ │ ├── routers/
313
+ │ │ └── <name>_router.py
314
+ │ ├── schemas/
315
+ │ │ └── <name>_schema.py
316
+ │ └── services/
317
+ │ └── <name>_service.py
318
+ ├── tests/
319
+ │ └── test_<name>.py
320
+ ├── pyproject.toml
321
+ └── project.json
322
+ ```
323
+
324
+ #### Python `lib`
325
+ ```
326
+ libs/<scope>/<type>-<name>/
327
+ ├── src/
328
+ │ └── <name>/
329
+ │ ├── __init__.py
330
+ │ └── <name>.py
331
+ ├── tests/
332
+ │ └── test_<name>.py
333
+ ├── pyproject.toml
334
+ └── project.json
335
+ ```
336
+
337
+ ### Step 4: Configure project.json
338
+
339
+ ```json
340
+ {
341
+ "name": "<scope>-<type>-<name>",
342
+ "tags": ["scope:<scope>", "type:<type>", "framework:<framework>"]
343
+ }
344
+ ```
345
+
346
+ ### Step 5: Update Public API (index.ts)
347
+
348
+ Export all public items appropriately for the type.
349
+
350
+ ### Step 6: Verify
351
+
352
+ ```bash
353
+ nx lint <project-name>
354
+ nx test <project-name>
355
+ ```
356
+
357
+ ## Output Summary
358
+
359
+ ```
360
+ ✓ Created library: libs/<scope>/<type>-<name>
361
+
362
+ Import path: @<org>/<scope>/<type>-<name>
363
+ Project name: <scope>-<type>-<name>
364
+ Tags: scope:<scope>, type:<type>, framework:<framework>
365
+
366
+ Files created:
367
+ - libs/<scope>/<type>-<name>/src/index.ts
368
+ - libs/<scope>/<type>-<name>/src/lib/...
369
+ - libs/<scope>/<type>-<name>/project.json
370
+
371
+ Next steps:
372
+ - Add business logic
373
+ - Export public API from index.ts
374
+ - Run: nx test <scope>-<type>-<name>
375
+ ```
@@ -1,174 +1,77 @@
1
1
  # Shared Conventions
2
2
 
3
- ## Git Workflow
4
-
5
- ### Branch Naming
6
-
7
- ```
8
- feature/[ticket-id]-short-description
9
- fix/[ticket-id]-short-description
10
- refactor/description
11
- chore/description
12
- ```
3
+ ## Code Quality
13
4
 
14
- ### Commit Messages (Conventional Commits)
5
+ ### Naming - Be Explicit
15
6
 
16
- ```
17
- type(scope): description
7
+ - No cryptic names: No `c`, `x`, `tmp`, `data`
8
+ - No magic numbers: Use named constants
9
+ - Small functions: < 30 lines, single responsibility
10
+ - Max nesting: 3 levels, use early returns
11
+ - No dead code: Delete, don't comment out
18
12
 
19
- [optional body]
13
+ ### Lint Disable - Only With Justification
20
14
 
21
- [optional footer]
22
- ```
15
+ Never disable lint rules without an explicit reason and ticket reference.
23
16
 
24
- Types:
25
- - `feat`: New feature
26
- - `fix`: Bug fix
27
- - `docs`: Documentation only
28
- - `style`: Formatting, no code change
29
- - `refactor`: Code change that neither fixes a bug nor adds a feature
30
- - `perf`: Performance improvement
31
- - `test`: Adding or updating tests
32
- - `chore`: Maintenance tasks
17
+ ## Error Handling
33
18
 
34
- Examples:
35
- ```
36
- feat(users): add user profile page
37
- fix(auth): resolve token refresh race condition
38
- refactor(api): simplify error handling
39
- test(cart): add unit tests for checkout flow
40
- ```
19
+ - Never swallow errors silently
20
+ - Log with context (user ID, request ID)
21
+ - User-facing: clear, actionable messages
22
+ - Internal: detailed logs, generic user message
41
23
 
42
- ### Pull Requests
24
+ ## Testing
43
25
 
44
- - Keep PRs small and focused
45
- - One feature/fix per PR
46
- - Write meaningful descriptions
47
- - Link related issues
48
-
49
- ## TypeScript Guidelines
50
-
51
- ### Strict Mode
52
-
53
- Always use strict TypeScript configuration:
54
- ```json
55
- {
56
- "compilerOptions": {
57
- "strict": true,
58
- "noImplicitAny": true,
59
- "strictNullChecks": true,
60
- "noImplicitReturns": true
61
- }
62
- }
63
- ```
64
-
65
- ### Type Definitions
66
-
67
- ```typescript
68
- // Prefer interfaces for object shapes
69
- interface User {
70
- id: string;
71
- name: string;
72
- email: string;
73
- }
74
-
75
- // Use type for unions, intersections, utility types
76
- type Status = 'pending' | 'active' | 'inactive';
77
- type UserWithRole = User & { role: Role };
78
-
79
- // Avoid 'any' - use 'unknown' if type is truly unknown
80
- function parse(input: unknown): Result {
81
- // ...
82
- }
83
- ```
84
-
85
- ### Naming Conventions
86
-
87
- | Element | Convention | Example |
88
- |---------|------------|---------|
89
- | Classes | PascalCase | `UserService` |
90
- | Interfaces | PascalCase | `UserProfile` |
91
- | Functions | camelCase | `getUserById` |
92
- | Variables | camelCase | `currentUser` |
93
- | Constants | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT` |
94
- | Files | kebab-case | `user-profile.service.ts` |
95
- | Folders | kebab-case | `user-management/` |
96
-
97
- ### Explicit Return Types
98
-
99
- Always declare return types on public methods:
100
-
101
- ```typescript
102
- // Good
103
- function getUser(id: string): User | null {
104
- // ...
105
- }
106
-
107
- // Avoid
108
- function getUser(id: string) {
109
- // ...
110
- }
111
- ```
26
+ - Test behavior, not implementation
27
+ - Descriptive names: `should_returnUser_when_validId`
28
+ - One assertion per test when practical
29
+ - Mock external dependencies only
112
30
 
113
- ## Code Quality
31
+ ## Security
114
32
 
115
- ### Avoid
33
+ - **Never commit secrets** (use env vars)
34
+ - **Validate all inputs** (never trust user data)
35
+ - **Parameterized queries** (no string concatenation)
36
+ - **Sanitize outputs** (prevent XSS)
116
37
 
117
- - `any` type
118
- - Magic numbers (use named constants)
119
- - Deep nesting (max 3 levels)
120
- - Long functions (max ~50 lines)
121
- - Commented-out code
122
- - Useless comments (code should be self-documenting)
123
- - Cryptic variable names (`c`, `x`, `tmp`, `data`)
38
+ ## Documentation
124
39
 
125
- ### Prefer
40
+ - Self-documenting code first
41
+ - Comments explain "why", not "what"
42
+ - Keep comments up-to-date or delete them
126
43
 
127
- - Early returns
128
- - Descriptive variable names
129
- - Single responsibility principle
130
- - Composition over inheritance
131
- - Immutable data patterns
44
+ ## Git Workflow
132
45
 
133
- ### Naming - Be Explicit
46
+ ### Commits
134
47
 
135
- ```typescript
136
- // BAD
137
- const c = getConfig();
138
- users.filter(u => u.a);
139
- const handleClick = (e) => { ... };
48
+ - Atomic commits: one logical change per commit
49
+ - Conventional commits: `feat:`, `fix:`, `refactor:`, `docs:`, `test:`, `chore:`
50
+ - Present tense: "add feature" not "added feature"
140
51
 
141
- // GOOD
142
- const appConfig = getConfig();
143
- users.filter(user => user.isActive);
144
- const handleUserSelection = (event: MouseEvent) => { ... };
145
- ```
52
+ ### Branches
146
53
 
147
- ### Lint Rules - Never Disable Without Justification
54
+ - `feature/<ticket>-<description>` for new features
55
+ - `fix/<ticket>-<description>` for bug fixes
56
+ - `refactor/<description>` for refactoring
148
57
 
149
- ```typescript
150
- // FORBIDDEN
151
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
152
- const data: any = response;
58
+ ### Pull Requests
153
59
 
154
- // ONLY IF ABSOLUTELY NECESSARY - with explicit reason
155
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Legacy API returns untyped, see ticket TECH-456
156
- const legacyData: any = legacyApi.fetch();
157
- ```
60
+ - Small, focused PRs (< 400 lines)
61
+ - Clear description with context
62
+ - Link to related issues
158
63
 
159
- ## Documentation
64
+ ## Dependencies
160
65
 
161
- - Write self-documenting code first
162
- - Add JSDoc only when intent isn't obvious
163
- - Keep comments up-to-date or remove them
164
- - Document "why", not "what"
66
+ - Pin exact versions in lock files
67
+ - Regular security audits (`npm audit`, `pip-audit`)
68
+ - Prefer well-maintained packages with active communities
69
+ - Minimize dependency count
165
70
 
166
- ```typescript
167
- // Bad: describes what code does
168
- // Increment counter by 1
169
- counter++;
71
+ ## Performance
170
72
 
171
- // Good: explains why
172
- // Compensate for 0-based index in display
173
- counter++;
174
- ```
73
+ - Measure before optimizing
74
+ - Profile to find bottlenecks
75
+ - Cache expensive operations
76
+ - Lazy load when possible
77
+ - Avoid premature optimization