@malamute/ai-rules 1.0.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 (145) hide show
  1. package/README.md +272 -121
  2. package/bin/cli.js +5 -2
  3. package/configs/_shared/CLAUDE.md +52 -149
  4. package/configs/_shared/rules/conventions/documentation.md +324 -0
  5. package/configs/_shared/rules/conventions/git.md +265 -0
  6. package/configs/_shared/rules/conventions/npm.md +80 -0
  7. package/configs/_shared/{.claude/rules → rules/conventions}/performance.md +1 -1
  8. package/configs/_shared/rules/conventions/principles.md +334 -0
  9. package/configs/_shared/rules/devops/ci-cd.md +262 -0
  10. package/configs/_shared/rules/devops/docker.md +275 -0
  11. package/configs/_shared/rules/devops/nx.md +194 -0
  12. package/configs/_shared/rules/domain/backend/api-design.md +203 -0
  13. package/configs/_shared/rules/lang/csharp/async.md +220 -0
  14. package/configs/_shared/rules/lang/csharp/csharp.md +314 -0
  15. package/configs/_shared/rules/lang/csharp/linq.md +210 -0
  16. package/configs/_shared/rules/lang/python/async.md +337 -0
  17. package/configs/_shared/rules/lang/python/celery.md +476 -0
  18. package/configs/_shared/rules/lang/python/config.md +339 -0
  19. package/configs/{python/.claude/rules → _shared/rules/lang/python}/database/sqlalchemy.md +6 -1
  20. package/configs/_shared/rules/lang/python/deployment.md +523 -0
  21. package/configs/_shared/rules/lang/python/error-handling.md +330 -0
  22. package/configs/_shared/rules/lang/python/migrations.md +421 -0
  23. package/configs/_shared/rules/lang/python/python.md +172 -0
  24. package/configs/_shared/rules/lang/python/repository.md +383 -0
  25. package/configs/{python/.claude/rules → _shared/rules/lang/python}/testing.md +2 -69
  26. package/configs/_shared/rules/lang/typescript/async.md +447 -0
  27. package/configs/_shared/rules/lang/typescript/generics.md +356 -0
  28. package/configs/_shared/rules/lang/typescript/typescript.md +212 -0
  29. package/configs/_shared/rules/quality/error-handling.md +48 -0
  30. package/configs/_shared/rules/quality/logging.md +45 -0
  31. package/configs/_shared/rules/quality/observability.md +240 -0
  32. package/configs/_shared/rules/quality/testing-patterns.md +65 -0
  33. package/configs/_shared/rules/security/secrets-management.md +222 -0
  34. package/configs/_shared/skills/analysis/explore/SKILL.md +257 -0
  35. package/configs/_shared/skills/analysis/security-audit/SKILL.md +184 -0
  36. package/configs/_shared/skills/dev/api-endpoint/SKILL.md +126 -0
  37. package/configs/_shared/{.claude/commands/generate-tests.md → skills/dev/generate-tests/SKILL.md} +6 -0
  38. package/configs/_shared/{.claude/commands/fix-issue.md → skills/git/fix-issue/SKILL.md} +6 -0
  39. package/configs/_shared/{.claude/commands/review-pr.md → skills/git/review-pr/SKILL.md} +6 -0
  40. package/configs/_shared/skills/infra/deploy/SKILL.md +139 -0
  41. package/configs/_shared/skills/infra/docker/SKILL.md +95 -0
  42. package/configs/_shared/skills/infra/migration/SKILL.md +158 -0
  43. package/configs/_shared/skills/nx/nx-affected/SKILL.md +72 -0
  44. package/configs/_shared/skills/nx/nx-lib/SKILL.md +375 -0
  45. package/configs/angular/CLAUDE.md +24 -216
  46. package/configs/angular/{.claude/rules → rules/core}/components.md +69 -15
  47. package/configs/angular/rules/core/resource.md +285 -0
  48. package/configs/angular/rules/core/signals.md +323 -0
  49. package/configs/angular/rules/http.md +338 -0
  50. package/configs/angular/rules/routing.md +291 -0
  51. package/configs/angular/rules/ssr.md +312 -0
  52. package/configs/angular/rules/state/signal-store.md +408 -0
  53. package/configs/angular/{.claude/rules → rules/state}/state.md +2 -2
  54. package/configs/angular/{.claude/rules → rules}/testing.md +7 -7
  55. package/configs/angular/rules/ui/aria.md +422 -0
  56. package/configs/angular/rules/ui/forms.md +424 -0
  57. package/configs/angular/rules/ui/pipes-directives.md +335 -0
  58. package/configs/angular/{.claude/settings.json → settings.json} +3 -0
  59. package/configs/dotnet/CLAUDE.md +53 -286
  60. package/configs/dotnet/rules/background-services.md +552 -0
  61. package/configs/dotnet/rules/configuration.md +426 -0
  62. package/configs/dotnet/rules/ddd.md +447 -0
  63. package/configs/dotnet/rules/dependency-injection.md +343 -0
  64. package/configs/dotnet/rules/mediatr.md +320 -0
  65. package/configs/dotnet/rules/middleware.md +489 -0
  66. package/configs/dotnet/rules/result-pattern.md +363 -0
  67. package/configs/dotnet/rules/validation.md +388 -0
  68. package/configs/dotnet/settings.json +29 -0
  69. package/configs/fastapi/CLAUDE.md +144 -0
  70. package/configs/fastapi/rules/background-tasks.md +254 -0
  71. package/configs/fastapi/rules/dependencies.md +170 -0
  72. package/configs/{python/.claude → fastapi}/rules/fastapi.md +61 -1
  73. package/configs/fastapi/rules/lifespan.md +274 -0
  74. package/configs/fastapi/rules/middleware.md +229 -0
  75. package/configs/fastapi/rules/pydantic.md +433 -0
  76. package/configs/fastapi/rules/responses.md +251 -0
  77. package/configs/fastapi/rules/routers.md +202 -0
  78. package/configs/fastapi/rules/security.md +222 -0
  79. package/configs/fastapi/rules/testing.md +251 -0
  80. package/configs/fastapi/rules/websockets.md +298 -0
  81. package/configs/fastapi/settings.json +35 -0
  82. package/configs/flask/CLAUDE.md +166 -0
  83. package/configs/flask/rules/blueprints.md +208 -0
  84. package/configs/flask/rules/cli.md +285 -0
  85. package/configs/flask/rules/configuration.md +281 -0
  86. package/configs/flask/rules/context.md +238 -0
  87. package/configs/flask/rules/error-handlers.md +278 -0
  88. package/configs/flask/rules/extensions.md +278 -0
  89. package/configs/flask/rules/flask.md +171 -0
  90. package/configs/flask/rules/marshmallow.md +206 -0
  91. package/configs/flask/rules/security.md +267 -0
  92. package/configs/flask/rules/testing.md +284 -0
  93. package/configs/flask/settings.json +35 -0
  94. package/configs/nestjs/CLAUDE.md +57 -215
  95. package/configs/nestjs/rules/common-patterns.md +300 -0
  96. package/configs/nestjs/rules/filters.md +376 -0
  97. package/configs/nestjs/rules/interceptors.md +317 -0
  98. package/configs/nestjs/rules/middleware.md +321 -0
  99. package/configs/nestjs/{.claude/rules → rules}/modules.md +26 -0
  100. package/configs/nestjs/rules/pipes.md +351 -0
  101. package/configs/nestjs/rules/websockets.md +451 -0
  102. package/configs/nestjs/settings.json +31 -0
  103. package/configs/nextjs/CLAUDE.md +69 -331
  104. package/configs/nextjs/rules/api-routes.md +358 -0
  105. package/configs/nextjs/rules/authentication.md +355 -0
  106. package/configs/nextjs/{.claude/rules → rules}/components.md +52 -0
  107. package/configs/nextjs/rules/data-fetching.md +249 -0
  108. package/configs/nextjs/rules/database.md +400 -0
  109. package/configs/nextjs/rules/middleware.md +303 -0
  110. package/configs/nextjs/rules/routing.md +324 -0
  111. package/configs/nextjs/rules/seo.md +350 -0
  112. package/configs/nextjs/rules/server-actions.md +353 -0
  113. package/configs/nextjs/{.claude/rules → rules}/state/zustand.md +6 -6
  114. package/configs/nextjs/{.claude/settings.json → settings.json} +7 -0
  115. package/package.json +24 -9
  116. package/src/cli.js +218 -0
  117. package/src/config.js +63 -0
  118. package/src/index.js +4 -0
  119. package/src/installer.js +414 -0
  120. package/src/merge.js +109 -0
  121. package/src/tech-config.json +45 -0
  122. package/src/utils.js +88 -0
  123. package/configs/dotnet/.claude/settings.json +0 -9
  124. package/configs/nestjs/.claude/settings.json +0 -15
  125. package/configs/python/.claude/rules/flask.md +0 -332
  126. package/configs/python/.claude/settings.json +0 -18
  127. package/configs/python/CLAUDE.md +0 -273
  128. package/src/install.js +0 -315
  129. /package/configs/_shared/{.claude/rules → rules/domain/frontend}/accessibility.md +0 -0
  130. /package/configs/_shared/{.claude/rules → rules/security}/security.md +0 -0
  131. /package/configs/_shared/{.claude/skills → skills/dev}/debug/SKILL.md +0 -0
  132. /package/configs/_shared/{.claude/skills → skills/dev}/learning/SKILL.md +0 -0
  133. /package/configs/_shared/{.claude/skills → skills/dev}/spec/SKILL.md +0 -0
  134. /package/configs/_shared/{.claude/skills → skills/git}/review/SKILL.md +0 -0
  135. /package/configs/dotnet/{.claude/rules → rules}/api.md +0 -0
  136. /package/configs/dotnet/{.claude/rules → rules}/architecture.md +0 -0
  137. /package/configs/dotnet/{.claude/rules → rules}/database/efcore.md +0 -0
  138. /package/configs/dotnet/{.claude/rules → rules}/testing.md +0 -0
  139. /package/configs/nestjs/{.claude/rules → rules}/auth.md +0 -0
  140. /package/configs/nestjs/{.claude/rules → rules}/database/prisma.md +0 -0
  141. /package/configs/nestjs/{.claude/rules → rules}/database/typeorm.md +0 -0
  142. /package/configs/nestjs/{.claude/rules → rules}/testing.md +0 -0
  143. /package/configs/nestjs/{.claude/rules → rules}/validation.md +0 -0
  144. /package/configs/nextjs/{.claude/rules → rules}/state/redux-toolkit.md +0 -0
  145. /package/configs/nextjs/{.claude/rules → rules}/testing.md +0 -0
@@ -4,316 +4,83 @@
4
4
 
5
5
  ## Stack
6
6
 
7
- - .NET 8+ (latest LTS)
7
+ - .NET 9 / .NET 8 (LTS)
8
8
  - ASP.NET Core Web API
9
9
  - Entity Framework Core
10
- - C# 12+ features
11
- - xUnit for testing
10
+ - C# 13+
11
+ - xUnit + NSubstitute + FluentAssertions
12
12
 
13
- ## Architecture
14
-
15
- ### Clean Architecture (Recommended)
13
+ ## Architecture - Clean Architecture
16
14
 
17
15
  ```
18
16
  src/
19
- ├── Domain/ # Core business logic (no dependencies)
20
- ├── Entities/
21
- │ │ └── User.cs
22
- ├── ValueObjects/
23
- │ └── Email.cs
24
- ├── Enums/
25
- │ ├── Exceptions/
26
- │ │ └── DomainException.cs
27
- │ └── Interfaces/
28
- │ └── IUserRepository.cs
29
-
30
- ├── Application/ # Use cases, CQRS, DTOs
31
- │ ├── Common/
32
- │ │ ├── Behaviors/
33
- │ │ │ ├── ValidationBehavior.cs
34
- │ │ │ └── LoggingBehavior.cs
35
- │ │ ├── Interfaces/
36
- │ │ │ └── IApplicationDbContext.cs
37
- │ │ └── Mappings/
38
- │ │ └── MappingProfile.cs
39
- │ ├── Users/
40
- │ │ ├── Commands/
41
- │ │ │ ├── CreateUser/
42
- │ │ │ │ ├── CreateUserCommand.cs
43
- │ │ │ │ ├── CreateUserCommandHandler.cs
44
- │ │ │ │ └── CreateUserCommandValidator.cs
45
- │ │ │ └── UpdateUser/
46
- │ │ └── Queries/
47
- │ │ ├── GetUser/
48
- │ │ │ ├── GetUserQuery.cs
49
- │ │ │ ├── GetUserQueryHandler.cs
50
- │ │ │ └── UserDto.cs
51
- │ │ └── GetUsers/
52
- │ └── DependencyInjection.cs
53
-
54
- ├── Infrastructure/ # External concerns
55
- │ ├── Data/
56
- │ │ ├── ApplicationDbContext.cs
57
- │ │ ├── Configurations/
58
- │ │ │ └── UserConfiguration.cs
59
- │ │ └── Migrations/
60
- │ ├── Repositories/
61
- │ │ └── UserRepository.cs
62
- │ ├── Services/
63
- │ │ └── DateTimeService.cs
64
- │ └── DependencyInjection.cs
65
-
66
- └── WebApi/ # Presentation layer
67
- ├── Controllers/
68
- │ └── UsersController.cs
69
- ├── Filters/
70
- │ └── ApiExceptionFilterAttribute.cs
71
- ├── Middleware/
72
- │ └── ExceptionHandlingMiddleware.cs
73
- ├── Program.cs
74
- └── appsettings.json
17
+ ├── Domain/ # Entities, ValueObjects, Interfaces
18
+ # ZERO external dependencies
19
+ ├── Application/ # Commands, Queries, DTOs, Validators
20
+ # MediatR, FluentValidation
21
+ ├── Infrastructure/ # DbContext, Repositories, External services
22
+ # EF Core, external APIs
23
+ └── WebApi/ # Controllers/Endpoints, Middleware
24
+ # Presentation layer
75
25
  ```
76
26
 
77
- ### Project References
27
+ **Dependencies**:
28
+ - `WebApi → Application → Domain`
29
+ - `Infrastructure → Application → Domain`
78
30
 
79
- ```
80
- WebApi → Application → Domain
81
- WebApi → Infrastructure → Application → Domain
82
- ```
31
+ ## Core Principles
83
32
 
84
- **Key rule**: Domain has ZERO external dependencies.
33
+ ### CQRS with MediatR
85
34
 
86
- ## Code Style
35
+ - **Commands** (write): Modify state, return minimal data (ID or void)
36
+ - **Queries** (read): Return data, never modify state
37
+ - Commands and queries implement `IRequest<T>`
87
38
 
88
- ### Naming Conventions
39
+ ### C# 12 Style
89
40
 
90
- | Element | Convention | Example |
91
- |---------|------------|---------|
92
- | Classes | PascalCase | `UserService` |
93
- | Interfaces | IPascalCase | `IUserRepository` |
94
- | Methods | PascalCase | `GetUserById` |
95
- | Properties | PascalCase | `FirstName` |
96
- | Private fields | _camelCase | `_userRepository` |
97
- | Parameters | camelCase | `userId` |
98
- | Constants | PascalCase | `MaxRetryCount` |
99
- | Async methods | Suffix Async | `GetUserAsync` |
41
+ - File-scoped namespaces
42
+ - Primary constructors for DI
43
+ - Records for DTOs
44
+ - Nullable reference types enabled
45
+ - Required members with `required` keyword
100
46
 
101
- ### File-Scoped Namespaces
47
+ ### Naming
102
48
 
103
- ```csharp
104
- // Good - C# 10+
105
- namespace MyApp.Domain.Entities;
49
+ | Element | Convention |
50
+ |---------|------------|
51
+ | Classes/Methods | PascalCase |
52
+ | Interfaces | IPascalCase |
53
+ | Private fields | _camelCase |
54
+ | Async methods | Suffix `Async` |
55
+ | Constants | PascalCase |
106
56
 
107
- public class User { }
57
+ ### API Patterns
108
58
 
109
- // Avoid
110
- namespace MyApp.Domain.Entities
111
- {
112
- public class User { }
113
- }
114
- ```
59
+ - **Minimal APIs**: Preferred for new projects (93% less memory in .NET 9)
60
+ - **Controllers**: Only for complex model binding scenarios
61
+ - Use `ISender` from MediatR for dispatching commands/queries
62
+ - Return `TypedResults.Ok()`, `TypedResults.NotFound()`, etc.
63
+ - Built-in OpenAPI: `AddOpenApi()` + `MapOpenApi()`
115
64
 
116
- ### Primary Constructors (C# 12)
65
+ ### Validation
117
66
 
118
- ```csharp
119
- // Good - for simple DI
120
- public class UserService(IUserRepository userRepository, ILogger<UserService> logger)
121
- {
122
- public async Task<User?> GetByIdAsync(Guid id)
123
- {
124
- logger.LogInformation("Getting user {UserId}", id);
125
- return await userRepository.GetByIdAsync(id);
126
- }
127
- }
128
-
129
- // Use traditional constructors when you need field assignment or validation
130
- ```
131
-
132
- ### Records for DTOs
133
-
134
- ```csharp
135
- // Immutable DTOs
136
- public record UserDto(Guid Id, string Email, string Name);
137
-
138
- public record CreateUserRequest(string Email, string Password, string Name);
139
-
140
- // With validation attributes
141
- public record CreateUserCommand(
142
- [Required][EmailAddress] string Email,
143
- [Required][MinLength(8)] string Password,
144
- [Required] string Name
145
- ) : IRequest<Guid>;
146
- ```
147
-
148
- ### Nullable Reference Types
149
-
150
- ```csharp
151
- // Enable in .csproj
152
- <Nullable>enable</Nullable>
153
-
154
- // Be explicit about nullability
155
- public async Task<User?> GetByIdAsync(Guid id); // Can return null
156
- public async Task<User> GetByIdOrThrowAsync(Guid id); // Never null
157
- ```
67
+ - FluentValidation for complex rules
68
+ - Data annotations for simple DTOs
69
+ - Validation in MediatR pipeline behavior
158
70
 
159
71
  ## Commands
160
72
 
161
73
  ```bash
162
- # Development
163
- dotnet run --project src/WebApi
164
-
165
- # Build
166
- dotnet build
167
- dotnet publish -c Release
168
-
169
- # Tests
170
- dotnet test
171
- dotnet test --filter "Category=Unit"
172
- dotnet test --collect:"XPlat Code Coverage"
173
-
174
- # EF Core migrations
175
- dotnet ef migrations add InitialCreate -p src/Infrastructure -s src/WebApi
74
+ dotnet run --project src/WebApi # Dev
75
+ dotnet build # Build
76
+ dotnet test # Test
77
+ dotnet ef migrations add Name -p src/Infrastructure -s src/WebApi
176
78
  dotnet ef database update -p src/Infrastructure -s src/WebApi
177
-
178
- # Format
179
- dotnet format
180
79
  ```
181
80
 
182
- ## Common Patterns
183
-
184
- ### Minimal API Endpoints
185
-
186
- ```csharp
187
- // Program.cs or endpoint extension
188
- app.MapGet("/users/{id:guid}", async (Guid id, ISender sender) =>
189
- {
190
- var user = await sender.Send(new GetUserQuery(id));
191
- return user is not null ? Results.Ok(user) : Results.NotFound();
192
- })
193
- .WithName("GetUser")
194
- .WithOpenApi()
195
- .RequireAuthorization();
196
-
197
- app.MapPost("/users", async (CreateUserCommand command, ISender sender) =>
198
- {
199
- var id = await sender.Send(command);
200
- return Results.CreatedAtRoute("GetUser", new { id }, id);
201
- })
202
- .WithName("CreateUser")
203
- .WithOpenApi();
204
- ```
205
-
206
- ### Controller-Based API
207
-
208
- ```csharp
209
- [ApiController]
210
- [Route("api/[controller]")]
211
- public class UsersController(ISender sender) : ControllerBase
212
- {
213
- [HttpGet("{id:guid}")]
214
- [ProducesResponseType<UserDto>(StatusCodes.Status200OK)]
215
- [ProducesResponseType(StatusCodes.Status404NotFound)]
216
- public async Task<IActionResult> Get(Guid id)
217
- {
218
- var user = await sender.Send(new GetUserQuery(id));
219
- return user is not null ? Ok(user) : NotFound();
220
- }
221
-
222
- [HttpPost]
223
- [ProducesResponseType<Guid>(StatusCodes.Status201Created)]
224
- [ProducesResponseType(StatusCodes.Status400BadRequest)]
225
- public async Task<IActionResult> Create(CreateUserCommand command)
226
- {
227
- var id = await sender.Send(command);
228
- return CreatedAtAction(nameof(Get), new { id }, id);
229
- }
230
- }
231
- ```
232
-
233
- ### Global Exception Handling
234
-
235
- ```csharp
236
- public class ExceptionHandlingMiddleware(RequestDelegate next, ILogger<ExceptionHandlingMiddleware> logger)
237
- {
238
- public async Task InvokeAsync(HttpContext context)
239
- {
240
- try
241
- {
242
- await next(context);
243
- }
244
- catch (ValidationException ex)
245
- {
246
- context.Response.StatusCode = StatusCodes.Status400BadRequest;
247
- await context.Response.WriteAsJsonAsync(new ProblemDetails
248
- {
249
- Status = 400,
250
- Title = "Validation Error",
251
- Detail = string.Join(", ", ex.Errors.Select(e => e.ErrorMessage))
252
- });
253
- }
254
- catch (NotFoundException ex)
255
- {
256
- context.Response.StatusCode = StatusCodes.Status404NotFound;
257
- await context.Response.WriteAsJsonAsync(new ProblemDetails
258
- {
259
- Status = 404,
260
- Title = "Not Found",
261
- Detail = ex.Message
262
- });
263
- }
264
- catch (Exception ex)
265
- {
266
- logger.LogError(ex, "Unhandled exception");
267
- context.Response.StatusCode = StatusCodes.Status500InternalServerError;
268
- await context.Response.WriteAsJsonAsync(new ProblemDetails
269
- {
270
- Status = 500,
271
- Title = "Server Error"
272
- });
273
- }
274
- }
275
- }
276
- ```
277
-
278
- ### Dependency Injection Setup
279
-
280
- ```csharp
281
- // Application/DependencyInjection.cs
282
- public static class DependencyInjection
283
- {
284
- public static IServiceCollection AddApplication(this IServiceCollection services)
285
- {
286
- services.AddMediatR(cfg => {
287
- cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
288
- cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
289
- cfg.AddBehavior(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>));
290
- });
291
-
292
- services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
293
- services.AddAutoMapper(Assembly.GetExecutingAssembly());
294
-
295
- return services;
296
- }
297
- }
298
-
299
- // Infrastructure/DependencyInjection.cs
300
- public static class DependencyInjection
301
- {
302
- public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
303
- {
304
- services.AddDbContext<ApplicationDbContext>(options =>
305
- options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")));
306
-
307
- services.AddScoped<IApplicationDbContext>(sp =>
308
- sp.GetRequiredService<ApplicationDbContext>());
309
-
310
- services.AddScoped<IUserRepository, UserRepository>();
311
-
312
- return services;
313
- }
314
- }
81
+ ## Code Style
315
82
 
316
- // Program.cs
317
- builder.Services.AddApplication();
318
- builder.Services.AddInfrastructure(builder.Configuration);
319
- ```
83
+ - `readonly` for immutable fields
84
+ - Expression-bodied members when simple
85
+ - Pattern matching over type checks
86
+ - `async`/`await` all the way down