@h1dr0n/skill-pool 0.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 (189) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +296 -0
  3. package/bin/cli.js +157 -0
  4. package/package.json +41 -0
  5. package/skills/api/agents/backend-specialist.md +69 -0
  6. package/skills/api/agents/database-optimizer.md +176 -0
  7. package/skills/api/manifest.yaml +20 -0
  8. package/skills/api/rules/auth-security.md +45 -0
  9. package/skills/api/skills/api-patterns/SKILL.md +81 -0
  10. package/skills/api/skills/api-patterns/api-style.md +42 -0
  11. package/skills/api/skills/api-patterns/auth.md +24 -0
  12. package/skills/api/skills/api-patterns/documentation.md +26 -0
  13. package/skills/api/skills/api-patterns/graphql.md +41 -0
  14. package/skills/api/skills/api-patterns/rate-limiting.md +31 -0
  15. package/skills/api/skills/api-patterns/response.md +37 -0
  16. package/skills/api/skills/api-patterns/rest.md +40 -0
  17. package/skills/api/skills/api-patterns/scripts/api_validator.py +211 -0
  18. package/skills/api/skills/api-patterns/security-testing.md +122 -0
  19. package/skills/api/skills/api-patterns/trpc.md +41 -0
  20. package/skills/api/skills/api-patterns/versioning.md +22 -0
  21. package/skills/api/skills/database-patterns.md +126 -0
  22. package/skills/api/skills/deployment-patterns.md +105 -0
  23. package/skills/api/skills/docker-patterns.md +135 -0
  24. package/skills/common/agents/code-reviewer.md +78 -0
  25. package/skills/common/agents/planner.md +80 -0
  26. package/skills/common/agents/security-reviewer.md +82 -0
  27. package/skills/common/agents/software-architect.md +81 -0
  28. package/skills/common/manifest.yaml +25 -0
  29. package/skills/common/rules/coding-style.md +39 -0
  30. package/skills/common/rules/git-workflow.md +33 -0
  31. package/skills/common/rules/security.md +25 -0
  32. package/skills/common/skills/architecture/SKILL.md +55 -0
  33. package/skills/common/skills/architecture/context-discovery.md +43 -0
  34. package/skills/common/skills/architecture/examples.md +94 -0
  35. package/skills/common/skills/architecture/pattern-selection.md +68 -0
  36. package/skills/common/skills/architecture/patterns-reference.md +50 -0
  37. package/skills/common/skills/architecture/trade-off-analysis.md +77 -0
  38. package/skills/common/skills/brainstorming/SKILL.md +163 -0
  39. package/skills/common/skills/brainstorming/dynamic-questioning.md +350 -0
  40. package/skills/common/skills/clean-code.md +99 -0
  41. package/skills/common/skills/code-review-checklist.md +86 -0
  42. package/skills/common/skills/plan-writing/SKILL.md +152 -0
  43. package/skills/common/skills/skill-feedback.md +94 -0
  44. package/skills/common/skills/tdd-workflow.md +130 -0
  45. package/skills/common/skills/verification-loop.md +112 -0
  46. package/skills/cpp/agents/cpp-build-resolver.md +90 -0
  47. package/skills/cpp/agents/cpp-reviewer.md +72 -0
  48. package/skills/cpp/manifest.yaml +15 -0
  49. package/skills/cpp/skills/cpp-coding-standards.md +722 -0
  50. package/skills/cpp/skills/cpp-testing.md +323 -0
  51. package/skills/devops/agents/devops-automator.md +376 -0
  52. package/skills/devops/agents/sre.md +90 -0
  53. package/skills/devops/manifest.yaml +20 -0
  54. package/skills/devops/skills/deployment-patterns.md +427 -0
  55. package/skills/devops/skills/deployment-procedures/SKILL.md +241 -0
  56. package/skills/devops/skills/docker-patterns.md +364 -0
  57. package/skills/devops/skills/e2e-testing.md +326 -0
  58. package/skills/devops/skills/github-ops.md +144 -0
  59. package/skills/django/manifest.yaml +16 -0
  60. package/skills/django/skills/django-patterns.md +734 -0
  61. package/skills/django/skills/django-security.md +593 -0
  62. package/skills/django/skills/django-tdd.md +729 -0
  63. package/skills/django/skills/django-verification.md +469 -0
  64. package/skills/dotnet/agents/csharp-reviewer.md +101 -0
  65. package/skills/dotnet/manifest.yaml +14 -0
  66. package/skills/dotnet/skills/csharp-testing.md +321 -0
  67. package/skills/dotnet/skills/dotnet-patterns.md +321 -0
  68. package/skills/go/agents/code-reviewer.md +76 -0
  69. package/skills/go/agents/go-build-resolver.md +94 -0
  70. package/skills/go/agents/go-reviewer.md +76 -0
  71. package/skills/go/manifest.yaml +17 -0
  72. package/skills/go/rules/go-style.md +55 -0
  73. package/skills/go/skills/golang-patterns.md +674 -0
  74. package/skills/go/skills/golang-testing.md +720 -0
  75. package/skills/java/agents/java-build-resolver.md +153 -0
  76. package/skills/java/agents/java-reviewer.md +92 -0
  77. package/skills/java/manifest.yaml +18 -0
  78. package/skills/java/skills/java-coding-standards.md +147 -0
  79. package/skills/java/skills/jpa-patterns.md +151 -0
  80. package/skills/java/skills/springboot-patterns.md +314 -0
  81. package/skills/java/skills/springboot-security.md +272 -0
  82. package/skills/kotlin/agents/kotlin-build-resolver.md +118 -0
  83. package/skills/kotlin/agents/kotlin-reviewer.md +159 -0
  84. package/skills/kotlin/manifest.yaml +17 -0
  85. package/skills/kotlin/skills/kotlin-coroutines-flows.md +284 -0
  86. package/skills/kotlin/skills/kotlin-patterns.md +711 -0
  87. package/skills/kotlin/skills/kotlin-testing.md +824 -0
  88. package/skills/laravel/manifest.yaml +15 -0
  89. package/skills/laravel/skills/laravel-patterns.md +409 -0
  90. package/skills/laravel/skills/laravel-security.md +279 -0
  91. package/skills/laravel/skills/laravel-tdd.md +277 -0
  92. package/skills/laravel/skills/laravel-verification.md +173 -0
  93. package/skills/mobile/agents/dart-build-resolver.md +201 -0
  94. package/skills/mobile/agents/flutter-reviewer.md +243 -0
  95. package/skills/mobile/manifest.yaml +19 -0
  96. package/skills/mobile/skills/android-clean-architecture.md +339 -0
  97. package/skills/mobile/skills/dart-flutter-patterns.md +563 -0
  98. package/skills/mobile/skills/swiftui-patterns.md +259 -0
  99. package/skills/nestjs/manifest.yaml +13 -0
  100. package/skills/nestjs/skills/nestjs-patterns.md +230 -0
  101. package/skills/perl/manifest.yaml +13 -0
  102. package/skills/perl/skills/perl-patterns.md +504 -0
  103. package/skills/perl/skills/perl-security.md +503 -0
  104. package/skills/perl/skills/perl-testing.md +475 -0
  105. package/skills/python/agents/python-reviewer.md +98 -0
  106. package/skills/python/manifest.yaml +18 -0
  107. package/skills/python/rules/python-style.md +69 -0
  108. package/skills/python/skills/python-patterns/SKILL.md +441 -0
  109. package/skills/python/skills/python-patterns.md +90 -0
  110. package/skills/python/skills/python-testing.md +81 -0
  111. package/skills/rust/agents/rust-build-resolver.md +148 -0
  112. package/skills/rust/agents/rust-reviewer.md +94 -0
  113. package/skills/rust/manifest.yaml +16 -0
  114. package/skills/rust/rules/rust-style.md +107 -0
  115. package/skills/rust/skills/rust-patterns.md +499 -0
  116. package/skills/rust/skills/rust-testing.md +500 -0
  117. package/skills/security/agents/accessibility-auditor.md +316 -0
  118. package/skills/security/agents/security-reviewer.md +108 -0
  119. package/skills/security/manifest.yaml +19 -0
  120. package/skills/security/skills/red-team-tactics/SKILL.md +199 -0
  121. package/skills/security/skills/security-bounty-hunter.md +99 -0
  122. package/skills/security/skills/security-review.md +495 -0
  123. package/skills/security/skills/security-scan.md +165 -0
  124. package/skills/security/skills/vulnerability-scanner/SKILL.md +276 -0
  125. package/skills/security/skills/vulnerability-scanner/checklists.md +121 -0
  126. package/skills/security/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
  127. package/skills/swift/manifest.yaml +16 -0
  128. package/skills/swift/skills/swift-actor-persistence.md +142 -0
  129. package/skills/swift/skills/swift-concurrency.md +216 -0
  130. package/skills/swift/skills/swift-protocol-di-testing.md +190 -0
  131. package/skills/swift/skills/swiftui-patterns.md +259 -0
  132. package/skills/unity/agents/game-designer.md +167 -0
  133. package/skills/unity/agents/unity-architect.md +52 -0
  134. package/skills/unity/agents/unity-editor-tool-developer.md +310 -0
  135. package/skills/unity/agents/unity-multiplayer-engineer.md +321 -0
  136. package/skills/unity/agents/unity-shader-graph-artist.md +269 -0
  137. package/skills/unity/manifest.yaml +21 -0
  138. package/skills/unity/rules/csharp-patterns.md +48 -0
  139. package/skills/unity/rules/unity-specific.md +53 -0
  140. package/skills/unity/skills/systematic-debugging.md +92 -0
  141. package/skills/unity/skills/unity-architecture.md +173 -0
  142. package/skills/unreal/agents/level-designer.md +208 -0
  143. package/skills/unreal/agents/technical-artist.md +229 -0
  144. package/skills/unreal/agents/unreal-multiplayer-architect.md +313 -0
  145. package/skills/unreal/agents/unreal-systems-engineer.md +310 -0
  146. package/skills/unreal/agents/unreal-technical-artist.md +256 -0
  147. package/skills/unreal/agents/unreal-world-builder.md +273 -0
  148. package/skills/unreal/manifest.yaml +21 -0
  149. package/skills/unreal/skills/unreal-patterns.md +183 -0
  150. package/skills/web/agents/frontend-specialist.md +71 -0
  151. package/skills/web/agents/ui-designer.md +383 -0
  152. package/skills/web/agents/ux-architect.md +469 -0
  153. package/skills/web/manifest.yaml +22 -0
  154. package/skills/web/rules/accessibility.md +54 -0
  155. package/skills/web/rules/css-performance.md +52 -0
  156. package/skills/web/skills/e2e-testing.md +132 -0
  157. package/skills/web/skills/frontend-design/SKILL.md +452 -0
  158. package/skills/web/skills/frontend-design/animation-guide.md +331 -0
  159. package/skills/web/skills/frontend-design/color-system.md +311 -0
  160. package/skills/web/skills/frontend-design/decision-trees.md +418 -0
  161. package/skills/web/skills/frontend-design/motion-graphics.md +306 -0
  162. package/skills/web/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  163. package/skills/web/skills/frontend-design/scripts/ux_audit.py +722 -0
  164. package/skills/web/skills/frontend-design/typography-system.md +345 -0
  165. package/skills/web/skills/frontend-design/ux-psychology.md +1116 -0
  166. package/skills/web/skills/frontend-design/visual-effects.md +383 -0
  167. package/skills/web/skills/react-nextjs.md +135 -0
  168. package/skills/web/skills/tailwind-patterns/SKILL.md +269 -0
  169. package/src/adapters/antigravity.js +164 -0
  170. package/src/adapters/claude.js +188 -0
  171. package/src/adapters/cursor.js +161 -0
  172. package/src/adapters/index.js +67 -0
  173. package/src/adapters/windsurf.js +158 -0
  174. package/src/commands/add.js +266 -0
  175. package/src/commands/create.js +127 -0
  176. package/src/commands/diff.js +78 -0
  177. package/src/commands/info.js +88 -0
  178. package/src/commands/init.js +224 -0
  179. package/src/commands/install.js +90 -0
  180. package/src/commands/list.js +54 -0
  181. package/src/commands/remove.js +101 -0
  182. package/src/commands/targets.js +32 -0
  183. package/src/commands/update.js +57 -0
  184. package/src/core/manifest.js +57 -0
  185. package/src/core/plugins.js +86 -0
  186. package/src/core/resolver.js +84 -0
  187. package/src/core/tracker.js +49 -0
  188. package/src/utils/fs.js +80 -0
  189. package/src/utils/git.js +52 -0
@@ -0,0 +1,321 @@
1
+ ---
2
+ name: csharp-testing
3
+ description: C# and .NET testing patterns with xUnit, FluentAssertions, mocking, integration tests, and test organization best practices.
4
+ origin: ECC
5
+ ---
6
+
7
+ # C# Testing Patterns
8
+
9
+ Comprehensive testing patterns for .NET applications using xUnit, FluentAssertions, and modern testing practices.
10
+
11
+ ## When to Activate
12
+
13
+ - Writing new tests for C# code
14
+ - Reviewing test quality and coverage
15
+ - Setting up test infrastructure for .NET projects
16
+ - Debugging flaky or slow tests
17
+
18
+ ## Test Framework Stack
19
+
20
+ | Tool | Purpose |
21
+ |---|---|
22
+ | **xUnit** | Test framework (preferred for .NET) |
23
+ | **FluentAssertions** | Readable assertion syntax |
24
+ | **NSubstitute** or **Moq** | Mocking dependencies |
25
+ | **Testcontainers** | Real infrastructure in integration tests |
26
+ | **WebApplicationFactory** | ASP.NET Core integration tests |
27
+ | **Bogus** | Realistic test data generation |
28
+
29
+ ## Unit Test Structure
30
+
31
+ ### Arrange-Act-Assert
32
+
33
+ ```csharp
34
+ public sealed class OrderServiceTests
35
+ {
36
+ private readonly IOrderRepository _repository = Substitute.For<IOrderRepository>();
37
+ private readonly ILogger<OrderService> _logger = Substitute.For<ILogger<OrderService>>();
38
+ private readonly OrderService _sut;
39
+
40
+ public OrderServiceTests()
41
+ {
42
+ _sut = new OrderService(_repository, _logger);
43
+ }
44
+
45
+ [Fact]
46
+ public async Task PlaceOrderAsync_ReturnsSuccess_WhenRequestIsValid()
47
+ {
48
+ // Arrange
49
+ var request = new CreateOrderRequest
50
+ {
51
+ CustomerId = "cust-123",
52
+ Items = [new OrderItem("SKU-001", 2, 29.99m)]
53
+ };
54
+
55
+ // Act
56
+ var result = await _sut.PlaceOrderAsync(request, CancellationToken.None);
57
+
58
+ // Assert
59
+ result.IsSuccess.Should().BeTrue();
60
+ result.Value.Should().NotBeNull();
61
+ result.Value!.CustomerId.Should().Be("cust-123");
62
+ }
63
+
64
+ [Fact]
65
+ public async Task PlaceOrderAsync_ReturnsFailure_WhenNoItems()
66
+ {
67
+ // Arrange
68
+ var request = new CreateOrderRequest
69
+ {
70
+ CustomerId = "cust-123",
71
+ Items = []
72
+ };
73
+
74
+ // Act
75
+ var result = await _sut.PlaceOrderAsync(request, CancellationToken.None);
76
+
77
+ // Assert
78
+ result.IsSuccess.Should().BeFalse();
79
+ result.Error.Should().Contain("at least one item");
80
+ }
81
+ }
82
+ ```
83
+
84
+ ### Parameterized Tests with Theory
85
+
86
+ ```csharp
87
+ [Theory]
88
+ [InlineData("", false)]
89
+ [InlineData("a", false)]
90
+ [InlineData("ab@c.d", false)]
91
+ [InlineData("user@example.com", true)]
92
+ [InlineData("user+tag@example.co.uk", true)]
93
+ public void IsValidEmail_ReturnsExpected(string email, bool expected)
94
+ {
95
+ EmailValidator.IsValid(email).Should().Be(expected);
96
+ }
97
+
98
+ [Theory]
99
+ [MemberData(nameof(InvalidOrderCases))]
100
+ public async Task PlaceOrderAsync_RejectsInvalidOrders(CreateOrderRequest request, string expectedError)
101
+ {
102
+ var result = await _sut.PlaceOrderAsync(request, CancellationToken.None);
103
+
104
+ result.IsSuccess.Should().BeFalse();
105
+ result.Error.Should().Contain(expectedError);
106
+ }
107
+
108
+ public static TheoryData<CreateOrderRequest, string> InvalidOrderCases => new()
109
+ {
110
+ { new() { CustomerId = "", Items = [ValidItem()] }, "CustomerId" },
111
+ { new() { CustomerId = "c1", Items = [] }, "at least one item" },
112
+ { new() { CustomerId = "c1", Items = [new("", 1, 10m)] }, "SKU" },
113
+ };
114
+ ```
115
+
116
+ ## Mocking with NSubstitute
117
+
118
+ ```csharp
119
+ [Fact]
120
+ public async Task GetOrderAsync_ReturnsNull_WhenNotFound()
121
+ {
122
+ // Arrange
123
+ var orderId = Guid.NewGuid();
124
+ _repository.FindByIdAsync(orderId, Arg.Any<CancellationToken>())
125
+ .Returns((Order?)null);
126
+
127
+ // Act
128
+ var result = await _sut.GetOrderAsync(orderId, CancellationToken.None);
129
+
130
+ // Assert
131
+ result.Should().BeNull();
132
+ }
133
+
134
+ [Fact]
135
+ public async Task PlaceOrderAsync_PersistsOrder()
136
+ {
137
+ // Arrange
138
+ var request = ValidOrderRequest();
139
+
140
+ // Act
141
+ await _sut.PlaceOrderAsync(request, CancellationToken.None);
142
+
143
+ // Assert — verify the repository was called
144
+ await _repository.Received(1).AddAsync(
145
+ Arg.Is<Order>(o => o.CustomerId == request.CustomerId),
146
+ Arg.Any<CancellationToken>());
147
+ }
148
+ ```
149
+
150
+ ## ASP.NET Core Integration Tests
151
+
152
+ ### WebApplicationFactory Setup
153
+
154
+ ```csharp
155
+ public sealed class OrderApiTests : IClassFixture<WebApplicationFactory<Program>>
156
+ {
157
+ private readonly HttpClient _client;
158
+
159
+ public OrderApiTests(WebApplicationFactory<Program> factory)
160
+ {
161
+ _client = factory.WithWebHostBuilder(builder =>
162
+ {
163
+ builder.ConfigureServices(services =>
164
+ {
165
+ // Replace real DB with in-memory for tests
166
+ services.RemoveAll<DbContextOptions<AppDbContext>>();
167
+ services.AddDbContext<AppDbContext>(options =>
168
+ options.UseInMemoryDatabase("TestDb"));
169
+ });
170
+ }).CreateClient();
171
+ }
172
+
173
+ [Fact]
174
+ public async Task GetOrder_Returns404_WhenNotFound()
175
+ {
176
+ var response = await _client.GetAsync($"/api/orders/{Guid.NewGuid()}");
177
+
178
+ response.StatusCode.Should().Be(HttpStatusCode.NotFound);
179
+ }
180
+
181
+ [Fact]
182
+ public async Task CreateOrder_Returns201_WithValidRequest()
183
+ {
184
+ var request = new CreateOrderRequest
185
+ {
186
+ CustomerId = "cust-1",
187
+ Items = [new("SKU-001", 1, 19.99m)]
188
+ };
189
+
190
+ var response = await _client.PostAsJsonAsync("/api/orders", request);
191
+
192
+ response.StatusCode.Should().Be(HttpStatusCode.Created);
193
+ response.Headers.Location.Should().NotBeNull();
194
+ }
195
+ }
196
+ ```
197
+
198
+ ### Testing with Testcontainers
199
+
200
+ ```csharp
201
+ public sealed class PostgresOrderRepositoryTests : IAsyncLifetime
202
+ {
203
+ private readonly PostgreSqlContainer _postgres = new PostgreSqlBuilder()
204
+ .WithImage("postgres:16-alpine")
205
+ .Build();
206
+
207
+ private AppDbContext _db = null!;
208
+
209
+ public async Task InitializeAsync()
210
+ {
211
+ await _postgres.StartAsync();
212
+ var options = new DbContextOptionsBuilder<AppDbContext>()
213
+ .UseNpgsql(_postgres.GetConnectionString())
214
+ .Options;
215
+ _db = new AppDbContext(options);
216
+ await _db.Database.MigrateAsync();
217
+ }
218
+
219
+ public async Task DisposeAsync()
220
+ {
221
+ await _db.DisposeAsync();
222
+ await _postgres.DisposeAsync();
223
+ }
224
+
225
+ [Fact]
226
+ public async Task AddAsync_PersistsOrder()
227
+ {
228
+ var repo = new SqlOrderRepository(_db);
229
+ var order = Order.Create("cust-1", [new OrderItem("SKU-001", 2, 10m)]);
230
+
231
+ await repo.AddAsync(order, CancellationToken.None);
232
+
233
+ var found = await repo.FindByIdAsync(order.Id, CancellationToken.None);
234
+ found.Should().NotBeNull();
235
+ found!.Items.Should().HaveCount(1);
236
+ }
237
+ }
238
+ ```
239
+
240
+ ## Test Organization
241
+
242
+ ```
243
+ tests/
244
+ MyApp.UnitTests/
245
+ Services/
246
+ OrderServiceTests.cs
247
+ PaymentServiceTests.cs
248
+ Validators/
249
+ EmailValidatorTests.cs
250
+ MyApp.IntegrationTests/
251
+ Api/
252
+ OrderApiTests.cs
253
+ Repositories/
254
+ OrderRepositoryTests.cs
255
+ MyApp.TestHelpers/
256
+ Builders/
257
+ OrderBuilder.cs
258
+ Fixtures/
259
+ DatabaseFixture.cs
260
+ ```
261
+
262
+ ## Test Data Builders
263
+
264
+ ```csharp
265
+ public sealed class OrderBuilder
266
+ {
267
+ private string _customerId = "cust-default";
268
+ private readonly List<OrderItem> _items = [new("SKU-001", 1, 10m)];
269
+
270
+ public OrderBuilder WithCustomer(string customerId)
271
+ {
272
+ _customerId = customerId;
273
+ return this;
274
+ }
275
+
276
+ public OrderBuilder WithItem(string sku, int quantity, decimal price)
277
+ {
278
+ _items.Add(new OrderItem(sku, quantity, price));
279
+ return this;
280
+ }
281
+
282
+ public Order Build() => Order.Create(_customerId, _items);
283
+ }
284
+
285
+ // Usage in tests
286
+ var order = new OrderBuilder()
287
+ .WithCustomer("cust-vip")
288
+ .WithItem("SKU-PREMIUM", 3, 99.99m)
289
+ .Build();
290
+ ```
291
+
292
+ ## Common Anti-Patterns
293
+
294
+ | Anti-Pattern | Fix |
295
+ |---|---|
296
+ | Testing implementation details | Test behavior and outcomes |
297
+ | Shared mutable test state | Fresh instance per test (xUnit does this via constructors) |
298
+ | `Thread.Sleep` in async tests | Use `Task.Delay` with timeout, or polling helpers |
299
+ | Asserting on `ToString()` output | Assert on typed properties |
300
+ | One giant assertion per test | One logical assertion per test |
301
+ | Test names describing implementation | Name by behavior: `Method_ExpectedResult_WhenCondition` |
302
+ | Ignoring `CancellationToken` | Always pass and verify cancellation |
303
+
304
+ ## Running Tests
305
+
306
+ ```bash
307
+ # Run all tests
308
+ dotnet test
309
+
310
+ # Run with coverage
311
+ dotnet test --collect:"XPlat Code Coverage"
312
+
313
+ # Run specific project
314
+ dotnet test tests/MyApp.UnitTests/
315
+
316
+ # Filter by test name
317
+ dotnet test --filter "FullyQualifiedName~OrderService"
318
+
319
+ # Watch mode during development
320
+ dotnet watch test --project tests/MyApp.UnitTests/
321
+ ```
@@ -0,0 +1,321 @@
1
+ ---
2
+ name: dotnet-patterns
3
+ description: Idiomatic C# and .NET patterns, conventions, dependency injection, async/await, and best practices for building robust, maintainable .NET applications.
4
+ origin: ECC
5
+ ---
6
+
7
+ # .NET Development Patterns
8
+
9
+ Idiomatic C# and .NET patterns for building robust, performant, and maintainable applications.
10
+
11
+ ## When to Activate
12
+
13
+ - Writing new C# code
14
+ - Reviewing C# code
15
+ - Refactoring existing .NET applications
16
+ - Designing service architectures with ASP.NET Core
17
+
18
+ ## Core Principles
19
+
20
+ ### 1. Prefer Immutability
21
+
22
+ Use records and init-only properties for data models. Mutability should be an explicit, justified choice.
23
+
24
+ ```csharp
25
+ // Good: Immutable value object
26
+ public sealed record Money(decimal Amount, string Currency);
27
+
28
+ // Good: Immutable DTO with init setters
29
+ public sealed class CreateOrderRequest
30
+ {
31
+ public required string CustomerId { get; init; }
32
+ public required IReadOnlyList<OrderItem> Items { get; init; }
33
+ }
34
+
35
+ // Bad: Mutable model with public setters
36
+ public class Order
37
+ {
38
+ public string CustomerId { get; set; }
39
+ public List<OrderItem> Items { get; set; }
40
+ }
41
+ ```
42
+
43
+ ### 2. Explicit Over Implicit
44
+
45
+ Be clear about nullability, access modifiers, and intent.
46
+
47
+ ```csharp
48
+ // Good: Explicit access modifiers and nullability
49
+ public sealed class UserService
50
+ {
51
+ private readonly IUserRepository _repository;
52
+ private readonly ILogger<UserService> _logger;
53
+
54
+ public UserService(IUserRepository repository, ILogger<UserService> logger)
55
+ {
56
+ _repository = repository ?? throw new ArgumentNullException(nameof(repository));
57
+ _logger = logger ?? throw new ArgumentNullException(nameof(logger));
58
+ }
59
+
60
+ public async Task<User?> FindByIdAsync(Guid id, CancellationToken cancellationToken)
61
+ {
62
+ return await _repository.FindByIdAsync(id, cancellationToken);
63
+ }
64
+ }
65
+ ```
66
+
67
+ ### 3. Depend on Abstractions
68
+
69
+ Use interfaces for service boundaries. Register via DI container.
70
+
71
+ ```csharp
72
+ // Good: Interface-based dependency
73
+ public interface IOrderRepository
74
+ {
75
+ Task<Order?> FindByIdAsync(Guid id, CancellationToken cancellationToken);
76
+ Task<IReadOnlyList<Order>> FindByCustomerAsync(string customerId, CancellationToken cancellationToken);
77
+ Task AddAsync(Order order, CancellationToken cancellationToken);
78
+ }
79
+
80
+ // Registration
81
+ builder.Services.AddScoped<IOrderRepository, SqlOrderRepository>();
82
+ ```
83
+
84
+ ## Async/Await Patterns
85
+
86
+ ### Proper Async Usage
87
+
88
+ ```csharp
89
+ // Good: Async all the way, with CancellationToken
90
+ public async Task<OrderSummary> GetOrderSummaryAsync(
91
+ Guid orderId,
92
+ CancellationToken cancellationToken)
93
+ {
94
+ var order = await _repository.FindByIdAsync(orderId, cancellationToken)
95
+ ?? throw new NotFoundException($"Order {orderId} not found");
96
+
97
+ var customer = await _customerService.GetAsync(order.CustomerId, cancellationToken);
98
+
99
+ return new OrderSummary(order, customer);
100
+ }
101
+
102
+ // Bad: Blocking on async
103
+ public OrderSummary GetOrderSummary(Guid orderId)
104
+ {
105
+ var order = _repository.FindByIdAsync(orderId, CancellationToken.None).Result; // Deadlock risk
106
+ return new OrderSummary(order);
107
+ }
108
+ ```
109
+
110
+ ### Parallel Async Operations
111
+
112
+ ```csharp
113
+ // Good: Concurrent independent operations
114
+ public async Task<DashboardData> LoadDashboardAsync(CancellationToken cancellationToken)
115
+ {
116
+ var ordersTask = _orderService.GetRecentAsync(cancellationToken);
117
+ var metricsTask = _metricsService.GetCurrentAsync(cancellationToken);
118
+ var alertsTask = _alertService.GetActiveAsync(cancellationToken);
119
+
120
+ await Task.WhenAll(ordersTask, metricsTask, alertsTask);
121
+
122
+ return new DashboardData(
123
+ Orders: await ordersTask,
124
+ Metrics: await metricsTask,
125
+ Alerts: await alertsTask);
126
+ }
127
+ ```
128
+
129
+ ## Options Pattern
130
+
131
+ Bind configuration sections to strongly-typed objects.
132
+
133
+ ```csharp
134
+ public sealed class SmtpOptions
135
+ {
136
+ public const string SectionName = "Smtp";
137
+
138
+ public required string Host { get; init; }
139
+ public required int Port { get; init; }
140
+ public required string Username { get; init; }
141
+ public bool UseSsl { get; init; } = true;
142
+ }
143
+
144
+ // Registration
145
+ builder.Services.Configure<SmtpOptions>(
146
+ builder.Configuration.GetSection(SmtpOptions.SectionName));
147
+
148
+ // Usage via injection
149
+ public class EmailService(IOptions<SmtpOptions> options)
150
+ {
151
+ private readonly SmtpOptions _smtp = options.Value;
152
+ }
153
+ ```
154
+
155
+ ## Result Pattern
156
+
157
+ Return explicit success/failure instead of throwing for expected failures.
158
+
159
+ ```csharp
160
+ public sealed record Result<T>
161
+ {
162
+ public bool IsSuccess { get; }
163
+ public T? Value { get; }
164
+ public string? Error { get; }
165
+
166
+ private Result(T value) { IsSuccess = true; Value = value; }
167
+ private Result(string error) { IsSuccess = false; Error = error; }
168
+
169
+ public static Result<T> Success(T value) => new(value);
170
+ public static Result<T> Failure(string error) => new(error);
171
+ }
172
+
173
+ // Usage
174
+ public async Task<Result<Order>> PlaceOrderAsync(CreateOrderRequest request)
175
+ {
176
+ if (request.Items.Count == 0)
177
+ return Result<Order>.Failure("Order must contain at least one item");
178
+
179
+ var order = Order.Create(request);
180
+ await _repository.AddAsync(order, CancellationToken.None);
181
+ return Result<Order>.Success(order);
182
+ }
183
+ ```
184
+
185
+ ## Repository Pattern with EF Core
186
+
187
+ ```csharp
188
+ public sealed class SqlOrderRepository : IOrderRepository
189
+ {
190
+ private readonly AppDbContext _db;
191
+
192
+ public SqlOrderRepository(AppDbContext db) => _db = db;
193
+
194
+ public async Task<Order?> FindByIdAsync(Guid id, CancellationToken cancellationToken)
195
+ {
196
+ return await _db.Orders
197
+ .Include(o => o.Items)
198
+ .AsNoTracking()
199
+ .FirstOrDefaultAsync(o => o.Id == id, cancellationToken);
200
+ }
201
+
202
+ public async Task<IReadOnlyList<Order>> FindByCustomerAsync(
203
+ string customerId,
204
+ CancellationToken cancellationToken)
205
+ {
206
+ return await _db.Orders
207
+ .Where(o => o.CustomerId == customerId)
208
+ .OrderByDescending(o => o.CreatedAt)
209
+ .AsNoTracking()
210
+ .ToListAsync(cancellationToken);
211
+ }
212
+
213
+ public async Task AddAsync(Order order, CancellationToken cancellationToken)
214
+ {
215
+ _db.Orders.Add(order);
216
+ await _db.SaveChangesAsync(cancellationToken);
217
+ }
218
+ }
219
+ ```
220
+
221
+ ## Middleware and Pipeline
222
+
223
+ ```csharp
224
+ // Custom middleware
225
+ public sealed class RequestTimingMiddleware
226
+ {
227
+ private readonly RequestDelegate _next;
228
+ private readonly ILogger<RequestTimingMiddleware> _logger;
229
+
230
+ public RequestTimingMiddleware(RequestDelegate next, ILogger<RequestTimingMiddleware> logger)
231
+ {
232
+ _next = next;
233
+ _logger = logger;
234
+ }
235
+
236
+ public async Task InvokeAsync(HttpContext context)
237
+ {
238
+ var stopwatch = Stopwatch.StartNew();
239
+ try
240
+ {
241
+ await _next(context);
242
+ }
243
+ finally
244
+ {
245
+ stopwatch.Stop();
246
+ _logger.LogInformation(
247
+ "Request {Method} {Path} completed in {ElapsedMs}ms with status {StatusCode}",
248
+ context.Request.Method,
249
+ context.Request.Path,
250
+ stopwatch.ElapsedMilliseconds,
251
+ context.Response.StatusCode);
252
+ }
253
+ }
254
+ }
255
+ ```
256
+
257
+ ## Minimal API Patterns
258
+
259
+ ```csharp
260
+ // Organized with route groups
261
+ var orders = app.MapGroup("/api/orders")
262
+ .RequireAuthorization()
263
+ .WithTags("Orders");
264
+
265
+ orders.MapGet("/{id:guid}", async (
266
+ Guid id,
267
+ IOrderRepository repository,
268
+ CancellationToken cancellationToken) =>
269
+ {
270
+ var order = await repository.FindByIdAsync(id, cancellationToken);
271
+ return order is not null
272
+ ? TypedResults.Ok(order)
273
+ : TypedResults.NotFound();
274
+ });
275
+
276
+ orders.MapPost("/", async (
277
+ CreateOrderRequest request,
278
+ IOrderService service,
279
+ CancellationToken cancellationToken) =>
280
+ {
281
+ var result = await service.PlaceOrderAsync(request, cancellationToken);
282
+ return result.IsSuccess
283
+ ? TypedResults.Created($"/api/orders/{result.Value!.Id}", result.Value)
284
+ : TypedResults.BadRequest(result.Error);
285
+ });
286
+ ```
287
+
288
+ ## Guard Clauses
289
+
290
+ ```csharp
291
+ // Good: Early returns with clear validation
292
+ public async Task<ProcessResult> ProcessPaymentAsync(
293
+ PaymentRequest request,
294
+ CancellationToken cancellationToken)
295
+ {
296
+ ArgumentNullException.ThrowIfNull(request);
297
+
298
+ if (request.Amount <= 0)
299
+ throw new ArgumentOutOfRangeException(nameof(request.Amount), "Amount must be positive");
300
+
301
+ if (string.IsNullOrWhiteSpace(request.Currency))
302
+ throw new ArgumentException("Currency is required", nameof(request.Currency));
303
+
304
+ // Happy path continues here without nesting
305
+ var gateway = _gatewayFactory.Create(request.Currency);
306
+ return await gateway.ChargeAsync(request, cancellationToken);
307
+ }
308
+ ```
309
+
310
+ ## Anti-Patterns to Avoid
311
+
312
+ | Anti-Pattern | Fix |
313
+ |---|---|
314
+ | `async void` methods | Return `Task` (except event handlers) |
315
+ | `.Result` or `.Wait()` | Use `await` |
316
+ | `catch (Exception) { }` | Handle or rethrow with context |
317
+ | `new Service()` in constructors | Use constructor injection |
318
+ | `public` fields | Use properties with appropriate accessors |
319
+ | `dynamic` in business logic | Use generics or explicit types |
320
+ | Mutable `static` state | Use DI scoping or `ConcurrentDictionary` |
321
+ | `string.Format` in loops | Use `StringBuilder` or interpolated string handlers |
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: Code Reviewer
3
+ description: Expert code reviewer who provides constructive, actionable feedback focused on correctness, maintainability, security, and performance — not style preferences.
4
+ color: purple
5
+ emoji: 👁️
6
+ vibe: Reviews code like a mentor, not a gatekeeper. Every comment teaches something.
7
+ ---
8
+
9
+ # Code Reviewer Agent
10
+
11
+ You are **Code Reviewer**, an expert who provides thorough, constructive code reviews. You focus on what matters — correctness, security, maintainability, and performance — not tabs vs spaces.
12
+
13
+ ## 🧠 Your Identity & Memory
14
+ - **Role**: Code review and quality assurance specialist
15
+ - **Personality**: Constructive, thorough, educational, respectful
16
+ - **Memory**: You remember common anti-patterns, security pitfalls, and review techniques that improve code quality
17
+ - **Experience**: You've reviewed thousands of PRs and know that the best reviews teach, not just criticize
18
+
19
+ ## 🎯 Your Core Mission
20
+
21
+ Provide code reviews that improve code quality AND developer skills:
22
+
23
+ 1. **Correctness** — Does it do what it's supposed to?
24
+ 2. **Security** — Are there vulnerabilities? Input validation? Auth checks?
25
+ 3. **Maintainability** — Will someone understand this in 6 months?
26
+ 4. **Performance** — Any obvious bottlenecks or N+1 queries?
27
+ 5. **Testing** — Are the important paths tested?
28
+
29
+ ## 🔧 Critical Rules
30
+
31
+ 1. **Be specific** — "This could cause an SQL injection on line 42" not "security issue"
32
+ 2. **Explain why** — Don't just say what to change, explain the reasoning
33
+ 3. **Suggest, don't demand** — "Consider using X because Y" not "Change this to X"
34
+ 4. **Prioritize** — Mark issues as 🔴 blocker, 🟡 suggestion, 💭 nit
35
+ 5. **Praise good code** — Call out clever solutions and clean patterns
36
+ 6. **One review, complete feedback** — Don't drip-feed comments across rounds
37
+
38
+ ## 📋 Review Checklist
39
+
40
+ ### 🔴 Blockers (Must Fix)
41
+ - Security vulnerabilities (injection, XSS, auth bypass)
42
+ - Data loss or corruption risks
43
+ - Race conditions or deadlocks
44
+ - Breaking API contracts
45
+ - Missing error handling for critical paths
46
+
47
+ ### 🟡 Suggestions (Should Fix)
48
+ - Missing input validation
49
+ - Unclear naming or confusing logic
50
+ - Missing tests for important behavior
51
+ - Performance issues (N+1 queries, unnecessary allocations)
52
+ - Code duplication that should be extracted
53
+
54
+ ### 💭 Nits (Nice to Have)
55
+ - Style inconsistencies (if no linter handles it)
56
+ - Minor naming improvements
57
+ - Documentation gaps
58
+ - Alternative approaches worth considering
59
+
60
+ ## 📝 Review Comment Format
61
+
62
+ ```
63
+ 🔴 **Security: SQL Injection Risk**
64
+ Line 42: User input is interpolated directly into the query.
65
+
66
+ **Why:** An attacker could inject `'; DROP TABLE users; --` as the name parameter.
67
+
68
+ **Suggestion:**
69
+ - Use parameterized queries: `db.query('SELECT * FROM users WHERE name = $1', [name])`
70
+ ```
71
+
72
+ ## 💬 Communication Style
73
+ - Start with a summary: overall impression, key concerns, what's good
74
+ - Use the priority markers consistently
75
+ - Ask questions when intent is unclear rather than assuming it's wrong
76
+ - End with encouragement and next steps