tribunal-kit 2.4.5 → 3.0.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 (144) hide show
  1. package/.agent/agents/accessibility-reviewer.md +220 -134
  2. package/.agent/agents/ai-code-reviewer.md +233 -129
  3. package/.agent/agents/backend-specialist.md +238 -178
  4. package/.agent/agents/code-archaeologist.md +181 -119
  5. package/.agent/agents/database-architect.md +207 -164
  6. package/.agent/agents/debugger.md +218 -151
  7. package/.agent/agents/dependency-reviewer.md +136 -55
  8. package/.agent/agents/devops-engineer.md +238 -175
  9. package/.agent/agents/documentation-writer.md +221 -137
  10. package/.agent/agents/explorer-agent.md +180 -142
  11. package/.agent/agents/frontend-reviewer.md +194 -80
  12. package/.agent/agents/frontend-specialist.md +237 -188
  13. package/.agent/agents/game-developer.md +52 -184
  14. package/.agent/agents/logic-reviewer.md +149 -78
  15. package/.agent/agents/mobile-developer.md +223 -152
  16. package/.agent/agents/mobile-reviewer.md +195 -79
  17. package/.agent/agents/orchestrator.md +211 -170
  18. package/.agent/agents/penetration-tester.md +174 -131
  19. package/.agent/agents/performance-optimizer.md +203 -139
  20. package/.agent/agents/performance-reviewer.md +211 -108
  21. package/.agent/agents/product-manager.md +162 -108
  22. package/.agent/agents/project-planner.md +162 -142
  23. package/.agent/agents/qa-automation-engineer.md +242 -138
  24. package/.agent/agents/security-auditor.md +194 -170
  25. package/.agent/agents/seo-specialist.md +213 -132
  26. package/.agent/agents/sql-reviewer.md +194 -73
  27. package/.agent/agents/supervisor-agent.md +203 -156
  28. package/.agent/agents/test-coverage-reviewer.md +193 -81
  29. package/.agent/agents/type-safety-reviewer.md +208 -65
  30. package/.agent/scripts/__pycache__/auto_preview.cpython-311.pyc +0 -0
  31. package/.agent/scripts/__pycache__/bundle_analyzer.cpython-311.pyc +0 -0
  32. package/.agent/scripts/__pycache__/checklist.cpython-311.pyc +0 -0
  33. package/.agent/scripts/__pycache__/dependency_analyzer.cpython-311.pyc +0 -0
  34. package/.agent/scripts/__pycache__/security_scan.cpython-311.pyc +0 -0
  35. package/.agent/scripts/__pycache__/session_manager.cpython-311.pyc +0 -0
  36. package/.agent/scripts/__pycache__/skill_integrator.cpython-311.pyc +0 -0
  37. package/.agent/scripts/__pycache__/swarm_dispatcher.cpython-311.pyc +0 -0
  38. package/.agent/scripts/__pycache__/test_runner.cpython-311.pyc +0 -0
  39. package/.agent/scripts/__pycache__/verify_all.cpython-311.pyc +0 -0
  40. package/.agent/skills/agent-organizer/SKILL.md +126 -132
  41. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +160 -0
  42. package/.agent/skills/api-patterns/SKILL.md +289 -257
  43. package/.agent/skills/api-security-auditor/SKILL.md +177 -0
  44. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +1 -1
  45. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +1 -1
  46. package/.agent/skills/appflow-wireframe/SKILL.md +107 -58
  47. package/.agent/skills/architecture/SKILL.md +331 -200
  48. package/.agent/skills/authentication-best-practices/SKILL.md +173 -0
  49. package/.agent/skills/bash-linux/SKILL.md +154 -215
  50. package/.agent/skills/brainstorming/SKILL.md +104 -210
  51. package/.agent/skills/building-native-ui/SKILL.md +174 -0
  52. package/.agent/skills/clean-code/SKILL.md +360 -206
  53. package/.agent/skills/config-validator/SKILL.md +141 -165
  54. package/.agent/skills/csharp-developer/SKILL.md +528 -107
  55. package/.agent/skills/database-design/SKILL.md +455 -275
  56. package/.agent/skills/deployment-procedures/SKILL.md +145 -188
  57. package/.agent/skills/devops-engineer/SKILL.md +332 -134
  58. package/.agent/skills/devops-incident-responder/SKILL.md +113 -98
  59. package/.agent/skills/edge-computing/SKILL.md +157 -213
  60. package/.agent/skills/extract-design-system/SKILL.md +134 -0
  61. package/.agent/skills/framer-motion-expert/SKILL.md +939 -0
  62. package/.agent/skills/game-design-expert/SKILL.md +105 -0
  63. package/.agent/skills/game-engineering-expert/SKILL.md +122 -0
  64. package/.agent/skills/geo-fundamentals/SKILL.md +124 -215
  65. package/.agent/skills/github-operations/SKILL.md +314 -354
  66. package/.agent/skills/gsap-expert/SKILL.md +901 -0
  67. package/.agent/skills/i18n-localization/SKILL.md +138 -216
  68. package/.agent/skills/intelligent-routing/SKILL.md +127 -139
  69. package/.agent/skills/llm-engineering/SKILL.md +357 -258
  70. package/.agent/skills/local-first/SKILL.md +154 -203
  71. package/.agent/skills/mcp-builder/SKILL.md +118 -224
  72. package/.agent/skills/nextjs-react-expert/SKILL.md +783 -203
  73. package/.agent/skills/nodejs-best-practices/SKILL.md +559 -280
  74. package/.agent/skills/observability/SKILL.md +330 -285
  75. package/.agent/skills/parallel-agents/SKILL.md +122 -181
  76. package/.agent/skills/performance-profiling/SKILL.md +254 -197
  77. package/.agent/skills/plan-writing/SKILL.md +118 -188
  78. package/.agent/skills/platform-engineer/SKILL.md +123 -135
  79. package/.agent/skills/playwright-best-practices/SKILL.md +162 -0
  80. package/.agent/skills/powershell-windows/SKILL.md +146 -230
  81. package/.agent/skills/python-pro/SKILL.md +879 -114
  82. package/.agent/skills/react-specialist/SKILL.md +931 -108
  83. package/.agent/skills/readme-builder/SKILL.md +42 -0
  84. package/.agent/skills/realtime-patterns/SKILL.md +304 -296
  85. package/.agent/skills/rust-pro/SKILL.md +701 -240
  86. package/.agent/skills/seo-fundamentals/SKILL.md +154 -181
  87. package/.agent/skills/server-management/SKILL.md +190 -212
  88. package/.agent/skills/shadcn-ui-expert/SKILL.md +206 -0
  89. package/.agent/skills/skill-creator/SKILL.md +68 -0
  90. package/.agent/skills/sql-pro/SKILL.md +633 -104
  91. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +78 -0
  92. package/.agent/skills/swiftui-expert/SKILL.md +176 -0
  93. package/.agent/skills/systematic-debugging/SKILL.md +118 -186
  94. package/.agent/skills/tailwind-patterns/SKILL.md +576 -232
  95. package/.agent/skills/tdd-workflow/SKILL.md +137 -209
  96. package/.agent/skills/testing-patterns/SKILL.md +573 -205
  97. package/.agent/skills/vue-expert/SKILL.md +964 -119
  98. package/.agent/skills/vulnerability-scanner/SKILL.md +269 -316
  99. package/.agent/skills/web-accessibility-auditor/SKILL.md +193 -0
  100. package/.agent/skills/webapp-testing/SKILL.md +145 -236
  101. package/.agent/workflows/api-tester.md +151 -279
  102. package/.agent/workflows/audit.md +138 -168
  103. package/.agent/workflows/brainstorm.md +110 -146
  104. package/.agent/workflows/changelog.md +112 -144
  105. package/.agent/workflows/create.md +124 -139
  106. package/.agent/workflows/debug.md +189 -196
  107. package/.agent/workflows/deploy.md +189 -153
  108. package/.agent/workflows/enhance.md +151 -139
  109. package/.agent/workflows/fix.md +135 -143
  110. package/.agent/workflows/generate.md +157 -164
  111. package/.agent/workflows/migrate.md +160 -163
  112. package/.agent/workflows/orchestrate.md +168 -151
  113. package/.agent/workflows/performance-benchmarker.md +123 -305
  114. package/.agent/workflows/plan.md +173 -151
  115. package/.agent/workflows/preview.md +80 -137
  116. package/.agent/workflows/refactor.md +183 -153
  117. package/.agent/workflows/review-ai.md +129 -140
  118. package/.agent/workflows/review.md +116 -155
  119. package/.agent/workflows/session.md +94 -154
  120. package/.agent/workflows/status.md +79 -125
  121. package/.agent/workflows/strengthen-skills.md +139 -99
  122. package/.agent/workflows/swarm.md +179 -194
  123. package/.agent/workflows/test.md +211 -166
  124. package/.agent/workflows/tribunal-backend.md +113 -111
  125. package/.agent/workflows/tribunal-database.md +115 -132
  126. package/.agent/workflows/tribunal-frontend.md +118 -115
  127. package/.agent/workflows/tribunal-full.md +133 -136
  128. package/.agent/workflows/tribunal-mobile.md +119 -123
  129. package/.agent/workflows/tribunal-performance.md +133 -152
  130. package/.agent/workflows/ui-ux-pro-max.md +143 -171
  131. package/README.md +11 -15
  132. package/package.json +1 -1
  133. package/.agent/skills/dotnet-core-expert/SKILL.md +0 -103
  134. package/.agent/skills/game-development/2d-games/SKILL.md +0 -119
  135. package/.agent/skills/game-development/3d-games/SKILL.md +0 -135
  136. package/.agent/skills/game-development/SKILL.md +0 -236
  137. package/.agent/skills/game-development/game-art/SKILL.md +0 -185
  138. package/.agent/skills/game-development/game-audio/SKILL.md +0 -190
  139. package/.agent/skills/game-development/game-design/SKILL.md +0 -129
  140. package/.agent/skills/game-development/mobile-games/SKILL.md +0 -108
  141. package/.agent/skills/game-development/multiplayer/SKILL.md +0 -132
  142. package/.agent/skills/game-development/pc-games/SKILL.md +0 -144
  143. package/.agent/skills/game-development/vr-ar/SKILL.md +0 -123
  144. package/.agent/skills/game-development/web-games/SKILL.md +0 -150
@@ -1,107 +1,528 @@
1
- ---
2
- name: csharp-developer
3
- description: Senior C# developer with mastery of .NET 8+ and the Microsoft ecosystem. Specializing in high-performance web applications, cloud-native solutions, cross-platform development, ASP.NET Core, Blazor, and Entity Framework Core.
4
- allowed-tools: Read, Write, Edit, Glob, Grep
5
- version: 1.0.0
6
- last-updated: 2026-03-12
7
- applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
8
- ---
9
-
10
- # Csharp Developer - Claude Code Sub-Agent
11
-
12
- You are a senior C# developer with mastery of .NET 8+ and the Microsoft ecosystem. Your focus spans building high-performance web applications, cloud-native solutions, cross-platform development, and modern C# language features with a focus on clean code and architectural patterns.
13
-
14
- ## Configuration & Context Assessment
15
- When invoked:
16
- 1. Query context manager for existing .NET solution structure and project configuration
17
- 2. Review `.csproj` files, NuGet packages, and solution architecture
18
- 3. Analyze C# patterns, nullable reference types usage, and performance characteristics
19
- 4. Implement solutions leveraging modern C# features and .NET best practices
20
-
21
- ---
22
-
23
- ## The C# Excellence Checklist
24
- - Nullable reference types enabled
25
- - Code analysis with `.editorconfig`
26
- - StyleCop and analyzer compliance
27
- - Test coverage exceeding 80%
28
- - API versioning implemented
29
- - Performance profiling completed
30
- - Security scanning passed
31
- - Documentation XML generated
32
-
33
- ---
34
-
35
- ## Core Architecture Decision Framework
36
-
37
- ### Modern C# Patterns & Language Features
38
- * **Immutability & Types:** Record types, Nullable reference types discipline, Global using directives.
39
- * **Control Flow & Expressions:** Pattern matching expressions, LINQ optimization techniques, Expression trees usage.
40
- * **Advanced Concepts:** Async/await best practices, Source generators adoption.
41
- * **Async Programming:** `ConfigureAwait` usage, Cancellation tokens, Async streams, `Parallel.ForEachAsync`, Channels for producers, Exception handling, Deadlock prevention.
42
-
43
- ### ASP.NET Core & Blazor Development
44
- * **Minimal APIs:** Middleware pipeline optimization, Endpoint filters, OpenAPI integration, Route groups, custom model binding, Output caching strategies, Health checks.
45
- * **Blazor:** Component architecture design, State management patterns, JavaScript interop, WebAssembly optimization, Server-side vs WASM, Component lifecycle, Real-time with SignalR.
46
- * **gRPC Integration:** Service definition, Client factory setup, Interceptors, Streaming patterns.
47
-
48
- ### Entity Framework Core & Data Access
49
- * Code-first migrations and Interceptors
50
- * Query optimization, compiled queries, and bulk operations
51
- * Complex relationships and change tracking optimization
52
- * Multi-tenancy implementation
53
-
54
- ### Extreme Performance & Architecture Patterns
55
- * `Span<T>` and `Memory<T>` usage, ArrayPool for allocations
56
- * ValueTask patterns, SIMD operations
57
- * AOT compilation readiness, trimming compatibility
58
- * Clean Architecture setup, CQRS with MediatR, Repository pattern, Result/Options pattern.
59
-
60
- ---
61
-
62
- ## Output Format
63
-
64
- When this skill produces or reviews code, structure your output as follows:
65
-
66
- ```
67
- ━━━ Csharp Developer Report ━━━━━━━━━━━━━━━━━━━━━━━━
68
- Skill: Csharp Developer
69
- Language: [detected language / framework]
70
- Scope: [N files · N functions]
71
- ─────────────────────────────────────────────────
72
- ✅ Passed: [checks that passed, or "All clean"]
73
- ⚠️ Warnings: [non-blocking issues, or "None"]
74
- ❌ Blocked: [blocking issues requiring fix, or "None"]
75
- ─────────────────────────────────────────────────
76
- VBC status: PENDING → VERIFIED
77
- Evidence: [test output / lint pass / compile success]
78
- ```
79
-
80
- **VBC (Verification-Before-Completion) is mandatory.**
81
- Do not mark status as VERIFIED until concrete terminal evidence is provided.
82
-
83
-
84
- ---
85
-
86
- ## 🏛️ Tribunal Integration (Anti-Hallucination)
87
-
88
- **Slash command: `/tribunal-backend`**
89
- **Active reviewers: `logic` · `security` · `dependency` · `type-safety`**
90
-
91
- ### Forbidden AI Tropes in C#
92
- 1. **Missing Async/Await** always use async methods for I/O bound operations. Never use `.Wait()` or `.Result` synchronously.
93
- 2. **Ignoring Nullable Reference Types** — always respect `?` and `!` annotations; do not hallucinate null-checks if the compiler validates it.
94
- 3. **Leaking Entity instances to APIs** — always use DTOs or ViewModels instead of returning raw Entity Framework models from controllers/Minimal APIs.
95
- 4. **Hardcoded Connection Strings** — always use `IConfiguration` or secret managers (Azure Key Vault).
96
- 5. **Inefficient LINQ** — beware of multiple enumeration or pulling entire DB tables into memory before filtering (`.ToList().Where(...)`).
97
-
98
- ### ✅ Pre-Flight Self-Audit
99
-
100
- Review these questions before generating C# code:
101
- ```text
102
- Did I maximize the use of modern C# features (records, pattern matching, primary constructors)?
103
- ✅ Are all asynchronous methods passing `CancellationToken` correctly?
104
- Is dependency injection configured properly without anti-patterns (e.g. Service Locator)?
105
- Are my Minimal APIs grouped and versioned properly?
106
- ✅ Did I use MediatR or Repository layers instead of stuffing logic into the Endpoint/Controller?
107
- ```
1
+ ---
2
+ name: csharp-developer
3
+ description: Senior C#/.NET developer with mastery of .NET 9+, C# 13, ASP.NET Core Minimal APIs, Entity Framework Core, Blazor, gRPC, AOT compilation, Span<T>/Memory<T> performance, dependency injection, and clean architecture. Covers modern language features, async patterns, testing with xUnit, and production deployment. Use when building .NET applications, APIs, or any C# code.
4
+ allowed-tools: Read, Write, Edit, Glob, Grep
5
+ version: 2.0.0
6
+ last-updated: 2026-04-01
7
+ applies-to-model: gemini-2.5-pro, claude-3-7-sonnet
8
+ ---
9
+
10
+ # C# / .NET Pro .NET 9+ & C# 13 Mastery
11
+
12
+ > .NET is not "enterprise Java." It is a high-performance, cross-platform, AOT-capable runtime.
13
+ > Every method gets CancellationToken. Every async method returns Task. Every entity stays out of the API layer. No shortcuts.
14
+
15
+ ---
16
+
17
+ ## Modern C# Language Features
18
+
19
+ ### Records & Primary Constructors
20
+
21
+ ```csharp
22
+ // Records — immutable data types with value equality
23
+ public record UserDto(string Name, string Email, string Role = "user");
24
+
25
+ // With custom validation
26
+ public record CreateUserRequest(string Name, string Email)
27
+ {
28
+ public string Name { get; init; } = !string.IsNullOrWhiteSpace(Name)
29
+ ? Name.Trim()
30
+ : throw new ArgumentException("Name is required", nameof(Name));
31
+ }
32
+
33
+ // Primary constructors (C# 12+) — classes too
34
+ public class UserService(IUserRepository repo, ILogger<UserService> logger)
35
+ {
36
+ public async Task<User?> GetUserAsync(int id, CancellationToken ct = default)
37
+ {
38
+ logger.LogInformation("Fetching user {UserId}", id);
39
+ return await repo.GetByIdAsync(id, ct);
40
+ }
41
+ }
42
+
43
+ // HALLUCINATION TRAP: Primary constructor parameters are NOT fields
44
+ // They're captured by closure don't use them where a field is needed
45
+ // For mutable backing, assign to a private field explicitly
46
+ ```
47
+
48
+ ### Pattern Matching (C# 12+)
49
+
50
+ ```csharp
51
+ // Switch expressions with pattern matching
52
+ public static string ClassifyTemperature(double temp) => temp switch
53
+ {
54
+ < 0 => "Freezing",
55
+ >= 0 and < 15 => "Cold",
56
+ >= 15 and < 25 => "Comfortable",
57
+ >= 25 and < 35 => "Warm",
58
+ >= 35 => "Hot",
59
+ };
60
+
61
+ // Property patterns
62
+ public static decimal CalculateDiscount(Order order) => order switch
63
+ {
64
+ { Total: > 1000, Customer.IsPremium: true } => 0.20m,
65
+ { Total: > 500 } => 0.10m,
66
+ { Customer.IsPremium: true } => 0.05m,
67
+ _ => 0m,
68
+ };
69
+
70
+ // List patterns (C# 11+)
71
+ public static string DescribeArray(int[] arr) => arr switch
72
+ {
73
+ [] => "Empty",
74
+ [var single] => $"Single: {single}",
75
+ [var first, .., var last] => $"First: {first}, Last: {last}",
76
+ };
77
+ ```
78
+
79
+ ### Collection Expressions & Ranges
80
+
81
+ ```csharp
82
+ // Collection expressions (C# 12+)
83
+ List<int> numbers = [1, 2, 3, 4, 5];
84
+ int[] array = [10, 20, 30];
85
+ Span<byte> bytes = [0xFF, 0x00, 0xAB];
86
+
87
+ // Spread operator
88
+ int[] combined = [..numbers, ..array, 99];
89
+
90
+ // Ranges and indices
91
+ var last = array[^1]; // last element
92
+ var slice = array[1..^1]; // skip first and last
93
+ var firstThree = array[..3]; // first 3 elements
94
+ ```
95
+
96
+ ### Nullable Reference Types
97
+
98
+ ```csharp
99
+ // Enable globally in .csproj
100
+ // <Nullable>enable</Nullable>
101
+
102
+ public class UserService
103
+ {
104
+ // Non-nullable compiler enforces this is never null
105
+ public string GetDisplayName(User user)
106
+ {
107
+ return user.DisplayName ?? user.Email; // DisplayName might be null
108
+ }
109
+
110
+ // Nullable return — caller MUST handle null
111
+ public async Task<User?> FindUserAsync(string email, CancellationToken ct)
112
+ {
113
+ return await _db.Users.FirstOrDefaultAsync(u => u.Email == email, ct);
114
+ }
115
+
116
+ // ❌ HALLUCINATION TRAP: Never use the null-forgiving operator (!) to suppress warnings
117
+ // ❌ var user = await FindUserAsync(email, ct)!; ← hides nulls, crashes at runtime
118
+ // ✅ var user = await FindUserAsync(email, ct) ?? throw new NotFoundException("User");
119
+ }
120
+ ```
121
+
122
+ ---
123
+
124
+ ## ASP.NET Core Minimal APIs
125
+
126
+ ### Route Structure
127
+
128
+ ```csharp
129
+ var builder = WebApplication.CreateBuilder(args);
130
+
131
+ // Services
132
+ builder.Services.AddDbContext<AppDbContext>(options =>
133
+ options.UseNpgsql(builder.Configuration.GetConnectionString("Default")));
134
+ builder.Services.AddScoped<IUserService, UserService>();
135
+ builder.Services.AddEndpointsApiExplorer();
136
+ builder.Services.AddSwaggerGen();
137
+
138
+ var app = builder.Build();
139
+
140
+ // Middleware
141
+ if (app.Environment.IsDevelopment())
142
+ {
143
+ app.UseSwagger();
144
+ app.UseSwaggerUI();
145
+ }
146
+ app.UseHttpsRedirection();
147
+ app.UseAuthentication();
148
+ app.UseAuthorization();
149
+
150
+ // Route groups
151
+ var api = app.MapGroup("/api").RequireAuthorization();
152
+
153
+ var users = api.MapGroup("/users").WithTags("Users");
154
+ users.MapGet("/", GetUsersAsync);
155
+ users.MapGet("/{id:int}", GetUserByIdAsync);
156
+ users.MapPost("/", CreateUserAsync).AllowAnonymous();
157
+ users.MapPut("/{id:int}", UpdateUserAsync);
158
+ users.MapDelete("/{id:int}", DeleteUserAsync);
159
+
160
+ app.Run();
161
+ ```
162
+
163
+ ### Handler Methods
164
+
165
+ ```csharp
166
+ static async Task<Results<Ok<UserDto>, NotFound>> GetUserByIdAsync(
167
+ int id,
168
+ IUserService userService,
169
+ CancellationToken ct)
170
+ {
171
+ var user = await userService.GetByIdAsync(id, ct);
172
+ return user is not null
173
+ ? TypedResults.Ok(user.ToDto())
174
+ : TypedResults.NotFound();
175
+ }
176
+
177
+ static async Task<Results<Created<UserDto>, ValidationProblem>> CreateUserAsync(
178
+ CreateUserRequest request,
179
+ IUserService userService,
180
+ IValidator<CreateUserRequest> validator,
181
+ CancellationToken ct)
182
+ {
183
+ var validation = await validator.ValidateAsync(request, ct);
184
+ if (!validation.IsValid)
185
+ return TypedResults.ValidationProblem(validation.ToDictionary());
186
+
187
+ var user = await userService.CreateAsync(request, ct);
188
+ return TypedResults.Created($"/api/users/{user.Id}", user.ToDto());
189
+ }
190
+
191
+ // ❌ HALLUCINATION TRAP: Always accept CancellationToken in async handlers
192
+ // ASP.NET Core provides it automatically via DI
193
+ // Without it, requests can't be cancelled on client disconnect
194
+ ```
195
+
196
+ ### Endpoint Filters (Middleware for Endpoints)
197
+
198
+ ```csharp
199
+ // Validation filter
200
+ public class ValidationFilter<T> : IEndpointFilter where T : class
201
+ {
202
+ public async ValueTask<object?> InvokeAsync(
203
+ EndpointFilterInvocationContext ctx,
204
+ EndpointFilterDelegate next)
205
+ {
206
+ var validator = ctx.HttpContext.RequestServices.GetService<IValidator<T>>();
207
+ var argument = ctx.Arguments.OfType<T>().FirstOrDefault();
208
+
209
+ if (validator is not null && argument is not null)
210
+ {
211
+ var result = await validator.ValidateAsync(argument);
212
+ if (!result.IsValid)
213
+ return TypedResults.ValidationProblem(result.ToDictionary());
214
+ }
215
+
216
+ return await next(ctx);
217
+ }
218
+ }
219
+
220
+ // Usage:
221
+ users.MapPost("/", CreateUserAsync)
222
+ .AddEndpointFilter<ValidationFilter<CreateUserRequest>>();
223
+ ```
224
+
225
+ ---
226
+
227
+ ## Entity Framework Core
228
+
229
+ ### DbContext & Configuration
230
+
231
+ ```csharp
232
+ public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
233
+ {
234
+ public DbSet<User> Users => Set<User>();
235
+ public DbSet<Post> Posts => Set<Post>();
236
+
237
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
238
+ {
239
+ modelBuilder.ApplyConfigurationsFromAssembly(typeof(AppDbContext).Assembly);
240
+ }
241
+
242
+ // Auto-set timestamps
243
+ public override async Task<int> SaveChangesAsync(CancellationToken ct = default)
244
+ {
245
+ foreach (var entry in ChangeTracker.Entries<BaseEntity>())
246
+ {
247
+ if (entry.State == EntityState.Added)
248
+ entry.Entity.CreatedAt = DateTime.UtcNow;
249
+ if (entry.State is EntityState.Added or EntityState.Modified)
250
+ entry.Entity.UpdatedAt = DateTime.UtcNow;
251
+ }
252
+ return await base.SaveChangesAsync(ct);
253
+ }
254
+ }
255
+
256
+ // Entity configuration (separate file per entity)
257
+ public class UserConfiguration : IEntityTypeConfiguration<User>
258
+ {
259
+ public void Configure(EntityTypeBuilder<User> builder)
260
+ {
261
+ builder.HasIndex(u => u.Email).IsUnique();
262
+ builder.Property(u => u.Name).HasMaxLength(100).IsRequired();
263
+ builder.Property(u => u.Email).HasMaxLength(255).IsRequired();
264
+ builder.HasMany(u => u.Posts).WithOne(p => p.Author).HasForeignKey(p => p.AuthorId);
265
+ }
266
+ }
267
+ ```
268
+
269
+ ### Query Patterns
270
+
271
+ ```csharp
272
+ // ✅ Efficient queries — project to DTOs at the database level
273
+ public async Task<List<UserDto>> GetActiveUsersAsync(CancellationToken ct)
274
+ {
275
+ return await _db.Users
276
+ .AsNoTracking() // read-only — no change tracking overhead
277
+ .Where(u => u.IsActive)
278
+ .OrderByDescending(u => u.CreatedAt)
279
+ .Select(u => new UserDto(u.Name, u.Email, u.Role)) // projects SQL SELECT
280
+ .ToListAsync(ct);
281
+ }
282
+
283
+ // ❌ HALLUCINATION TRAP: Loading entities then mapping is N+1 and memory waste
284
+ // ❌ var users = await _db.Users.ToListAsync(ct); ← loads ALL columns, ALL rows
285
+ // return users.Select(u => new UserDto(u.Name, u.Email)); ← maps in memory
286
+ // ✅ Use .Select() BEFORE .ToListAsync() to project at DB level
287
+
288
+ // Pagination
289
+ public async Task<PagedResult<UserDto>> GetUsersPagedAsync(int page, int pageSize, CancellationToken ct)
290
+ {
291
+ var query = _db.Users.AsNoTracking().Where(u => u.IsActive);
292
+
293
+ var totalCount = await query.CountAsync(ct);
294
+ var items = await query
295
+ .OrderBy(u => u.Id)
296
+ .Skip((page - 1) * pageSize)
297
+ .Take(pageSize)
298
+ .Select(u => new UserDto(u.Name, u.Email, u.Role))
299
+ .ToListAsync(ct);
300
+
301
+ return new PagedResult<UserDto>(items, totalCount, page, pageSize);
302
+ }
303
+
304
+ // Compiled queries (for hot paths)
305
+ private static readonly Func<AppDbContext, string, CancellationToken, Task<User?>> _getUserByEmail =
306
+ EF.CompileAsyncQuery((AppDbContext db, string email, CancellationToken ct) =>
307
+ db.Users.FirstOrDefault(u => u.Email == email));
308
+ ```
309
+
310
+ ---
311
+
312
+ ## Async Patterns
313
+
314
+ ```csharp
315
+ // ✅ Correct async patterns
316
+ public async Task<Result<User>> ProcessUserAsync(int id, CancellationToken ct)
317
+ {
318
+ // Parallel async operations
319
+ var (user, permissions) = await (
320
+ _userRepo.GetByIdAsync(id, ct),
321
+ _permissionService.GetPermissionsAsync(id, ct)
322
+ );
323
+
324
+ // Async streams (IAsyncEnumerable)
325
+ await foreach (var notification in GetNotificationsAsync(id, ct))
326
+ {
327
+ await SendNotificationAsync(notification, ct);
328
+ }
329
+
330
+ return Result.Ok(user);
331
+ }
332
+
333
+ // Channels (producer-consumer)
334
+ var channel = Channel.CreateBounded<WorkItem>(100);
335
+
336
+ // Producer
337
+ async Task ProduceAsync(ChannelWriter<WorkItem> writer, CancellationToken ct)
338
+ {
339
+ await foreach (var item in GetWorkItemsAsync(ct))
340
+ {
341
+ await writer.WriteAsync(item, ct);
342
+ }
343
+ writer.Complete();
344
+ }
345
+
346
+ // Consumer
347
+ async Task ConsumeAsync(ChannelReader<WorkItem> reader, CancellationToken ct)
348
+ {
349
+ await foreach (var item in reader.ReadAllAsync(ct))
350
+ {
351
+ await ProcessAsync(item, ct);
352
+ }
353
+ }
354
+
355
+ // ❌ HALLUCINATION TRAP: Never use .Result or .Wait() on async methods
356
+ // ❌ var user = GetUserAsync(id).Result; ← deadlock risk
357
+ // ❌ GetUserAsync(id).Wait(); ← deadlock risk
358
+ // ✅ var user = await GetUserAsync(id, ct);
359
+ ```
360
+
361
+ ---
362
+
363
+ ## Performance Patterns
364
+
365
+ ```csharp
366
+ // Span<T> — zero-allocation slicing
367
+ public static ReadOnlySpan<char> ExtractDomain(ReadOnlySpan<char> email)
368
+ {
369
+ var atIndex = email.IndexOf('@');
370
+ return atIndex >= 0 ? email[(atIndex + 1)..] : ReadOnlySpan<char>.Empty;
371
+ }
372
+
373
+ // ArrayPool — rent instead of allocate
374
+ public static void ProcessLargeData()
375
+ {
376
+ var buffer = ArrayPool<byte>.Shared.Rent(8192);
377
+ try
378
+ {
379
+ // Use buffer...
380
+ }
381
+ finally
382
+ {
383
+ ArrayPool<byte>.Shared.Return(buffer);
384
+ }
385
+ }
386
+
387
+ // Frozen collections (immutable, optimized lookup)
388
+ FrozenDictionary<string, int> lookup = new Dictionary<string, int>
389
+ {
390
+ ["admin"] = 1,
391
+ ["user"] = 2,
392
+ ["moderator"] = 3,
393
+ }.ToFrozenDictionary();
394
+ ```
395
+
396
+ ---
397
+
398
+ ## Testing with xUnit
399
+
400
+ ```csharp
401
+ public class UserServiceTests
402
+ {
403
+ private readonly Mock<IUserRepository> _repoMock = new();
404
+ private readonly Mock<ILogger<UserService>> _loggerMock = new();
405
+ private readonly UserService _sut;
406
+
407
+ public UserServiceTests()
408
+ {
409
+ _sut = new UserService(_repoMock.Object, _loggerMock.Object);
410
+ }
411
+
412
+ [Fact]
413
+ public async Task GetUserAsync_ReturnsUser_WhenFound()
414
+ {
415
+ // Arrange
416
+ var expected = new User { Id = 1, Name = "Alice", Email = "alice@test.com" };
417
+ _repoMock.Setup(r => r.GetByIdAsync(1, It.IsAny<CancellationToken>()))
418
+ .ReturnsAsync(expected);
419
+
420
+ // Act
421
+ var result = await _sut.GetUserAsync(1);
422
+
423
+ // Assert
424
+ Assert.NotNull(result);
425
+ Assert.Equal("Alice", result.Name);
426
+ }
427
+
428
+ [Fact]
429
+ public async Task GetUserAsync_ReturnsNull_WhenNotFound()
430
+ {
431
+ _repoMock.Setup(r => r.GetByIdAsync(999, It.IsAny<CancellationToken>()))
432
+ .ReturnsAsync((User?)null);
433
+
434
+ var result = await _sut.GetUserAsync(999);
435
+
436
+ Assert.Null(result);
437
+ }
438
+
439
+ [Theory]
440
+ [InlineData("", "required")]
441
+ [InlineData("ab", "too short")]
442
+ public async Task CreateUser_Fails_WithInvalidName(string name, string expectedError)
443
+ {
444
+ var request = new CreateUserRequest(name, "test@test.com");
445
+
446
+ var ex = await Assert.ThrowsAsync<ValidationException>(
447
+ () => _sut.CreateAsync(request));
448
+
449
+ Assert.Contains(expectedError, ex.Message, StringComparison.OrdinalIgnoreCase);
450
+ }
451
+ }
452
+
453
+ // Integration test with WebApplicationFactory
454
+ public class UsersApiTests(WebApplicationFactory<Program> factory)
455
+ : IClassFixture<WebApplicationFactory<Program>>
456
+ {
457
+ private readonly HttpClient _client = factory.CreateClient();
458
+
459
+ [Fact]
460
+ public async Task GetUsers_Returns200()
461
+ {
462
+ var response = await _client.GetAsync("/api/users");
463
+ response.EnsureSuccessStatusCode();
464
+
465
+ var users = await response.Content.ReadFromJsonAsync<List<UserDto>>();
466
+ Assert.NotNull(users);
467
+ }
468
+ }
469
+ ```
470
+
471
+ ---
472
+
473
+ ## Output Format
474
+
475
+ ```
476
+ ━━━ C#/.NET Report ━━━━━━━━━━━━━━━━━━━━━━━━
477
+ Skill: C# / .NET Pro
478
+ .NET Ver: 9+
479
+ Scope: [N files · N endpoints]
480
+ ─────────────────────────────────────────────────
481
+ ✅ Passed: [checks that passed, or "All clean"]
482
+ ⚠️ Warnings: [non-blocking issues, or "None"]
483
+ ❌ Blocked: [blocking issues requiring fix, or "None"]
484
+ ─────────────────────────────────────────────────
485
+ VBC status: PENDING → VERIFIED
486
+ Evidence: [dotnet build / dotnet test / lint output]
487
+ ```
488
+
489
+ ---
490
+
491
+ ## 🤖 LLM-Specific Traps
492
+
493
+ 1. **`.Result` / `.Wait()` on Async:** Never block on async. It causes deadlocks in ASP.NET Core. Always use `await`.
494
+ 2. **Missing `CancellationToken`:** Every async method in ASP.NET Core must accept and pass `CancellationToken`.
495
+ 3. **Returning EF Entities from APIs:** Never expose Entity Framework models to the API. Map to DTOs/records.
496
+ 4. **`.ToList().Where()`:** Loading all rows then filtering in memory. Use `.Where()` BEFORE `.ToListAsync()`.
497
+ 5. **Null-Forgiving Operator (`!`):** Don't suppress nullable warnings. Handle nulls explicitly.
498
+ 6. **Hardcoded Connection Strings:** Use `IConfiguration`, `appsettings.json`, or secret managers.
499
+ 7. **`ConfigureAwait(false)` in ASP.NET Core:** This is unnecessary in ASP.NET Core (no SynchronizationContext). Only use in libraries.
500
+ 8. **Missing `AsNoTracking()`:** Read-only queries must use `.AsNoTracking()` to avoid change tracking overhead.
501
+ 9. **Controller-Based APIs in Greenfield:** Minimal APIs are the modern standard. Only use controllers for legacy code.
502
+ 10. **Service Locator Anti-Pattern:** Never resolve services with `IServiceProvider.GetService<T>()` inside constructors. Use proper DI.
503
+
504
+ ---
505
+
506
+ ## 🏛️ Tribunal Integration
507
+
508
+ **Slash command: `/tribunal-backend`**
509
+
510
+ ### ✅ Pre-Flight Self-Audit
511
+
512
+ ```
513
+ ✅ Did I use records/DTOs (not EF entities) in API responses?
514
+ ✅ Did I pass CancellationToken through all async methods?
515
+ ✅ Did I use await (not .Result or .Wait())?
516
+ ✅ Did I use AsNoTracking for read-only queries?
517
+ ✅ Did I project with .Select() before .ToListAsync()?
518
+ ✅ Are nullable reference types enabled and respected?
519
+ ✅ Did I use DI (not Service Locator)?
520
+ ✅ Are connection strings in configuration (not hardcoded)?
521
+ ✅ Did I use pattern matching and modern C# features?
522
+ ✅ Does dotnet build and dotnet test pass?
523
+ ```
524
+
525
+ ### 🛑 VBC Protocol
526
+
527
+ - ❌ **Forbidden:** Declaring .NET code "works" because it compiles.
528
+ - ✅ **Required:** Provide `dotnet build` and `dotnet test` output.