@ngxtm/devkit 3.11.0 → 3.12.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 (28) hide show
  1. package/SKILLS_INDEX.md +1 -1
  2. package/cli/init.js +1 -1
  3. package/cli/update.js +1 -1
  4. package/merged-commands/learn.md +84 -413
  5. package/merged-commands/skill/sync.md +108 -0
  6. package/package.json +3 -2
  7. package/rules-index.json +8 -1
  8. package/scripts/merge-commands.js +0 -1
  9. package/skills-index.json +1 -1
  10. package/templates/base/rules/auto-skill.md +3 -2
  11. package/templates/base/rules/command-routing.md +71 -0
  12. package/templates/dotnet/rules/dotnet/aspnet-core/SKILL.md +92 -0
  13. package/templates/dotnet/rules/dotnet/aspnet-core/references/REFERENCE.md +335 -0
  14. package/templates/dotnet/rules/dotnet/best-practices/SKILL.md +101 -0
  15. package/templates/dotnet/rules/dotnet/best-practices/references/REFERENCE.md +256 -0
  16. package/templates/dotnet/rules/dotnet/blazor/SKILL.md +146 -0
  17. package/templates/dotnet/rules/dotnet/blazor/references/REFERENCE.md +392 -0
  18. package/templates/dotnet/rules/dotnet/language/SKILL.md +82 -0
  19. package/templates/dotnet/rules/dotnet/language/references/REFERENCE.md +222 -0
  20. package/templates/dotnet/rules/dotnet/patterns.rule.md +388 -0
  21. package/templates/dotnet/rules/dotnet/razor-pages/SKILL.md +124 -0
  22. package/templates/dotnet/rules/dotnet/razor-pages/references/REFERENCE.md +321 -0
  23. package/templates/dotnet/rules/dotnet/security/SKILL.md +89 -0
  24. package/templates/dotnet/rules/dotnet/security/references/REFERENCE.md +295 -0
  25. package/templates/dotnet/rules/dotnet/tooling/SKILL.md +92 -0
  26. package/templates/dotnet/rules/dotnet/tooling/references/REFERENCE.md +300 -0
  27. package/merged-commands/scout/ext.md +0 -35
  28. package/merged-commands/scout.md +0 -28
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: .NET Tooling
3
+ description: Essential tooling for .NET development and CI/CD.
4
+ metadata:
5
+ labels: [dotnet, tooling, testing, build, nuget]
6
+ triggers:
7
+ files: ['**/*.csproj', '**/*.sln', '.editorconfig', 'Directory.Build.props']
8
+ keywords: [PackageReference, dotnet, test, build, publish]
9
+ ---
10
+
11
+ # .NET Tooling
12
+
13
+ ## **Priority: P1 (OPERATIONAL)**
14
+
15
+ Essential tooling for .NET development, testing, and CI/CD.
16
+
17
+ ## Implementation Guidelines
18
+
19
+ - **Project Files**: SDK-style `.csproj`. Use `Directory.Build.props` for shared settings.
20
+ - **Central Package Management**: `Directory.Packages.props` for version consistency.
21
+ - **Testing**: xUnit or NUnit. FluentAssertions for readable assertions. Moq for mocking.
22
+ - **Code Analysis**: Enable built-in analyzers. Consider StyleCop, SonarQube.
23
+ - **Build**: `dotnet build`, `dotnet publish`. Use Release config for production.
24
+ - **EditorConfig**: Consistent code style across team.
25
+ - **CI/CD**: GitHub Actions, Azure DevOps, or GitLab CI.
26
+
27
+ ## Anti-Patterns
28
+
29
+ - **No `packages.config`**: Migrate to `PackageReference`.
30
+ - **No skipping tests in CI**: Tests must pass before merge.
31
+ - **No ignoring warnings**: Fix or suppress with documented justification.
32
+ - **No floating versions**: Pin versions (`8.0.0`, not `8.*`).
33
+
34
+ ## Code
35
+
36
+ ```xml
37
+ <!-- Directory.Build.props (shared across all projects) -->
38
+ <Project>
39
+ <PropertyGroup>
40
+ <TargetFramework>net8.0</TargetFramework>
41
+ <Nullable>enable</Nullable>
42
+ <ImplicitUsings>enable</ImplicitUsings>
43
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
44
+ <AnalysisLevel>latest-recommended</AnalysisLevel>
45
+ </PropertyGroup>
46
+ </Project>
47
+
48
+ <!-- Directory.Packages.props (Central Package Management) -->
49
+ <Project>
50
+ <PropertyGroup>
51
+ <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
52
+ </PropertyGroup>
53
+ <ItemGroup>
54
+ <PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
55
+ <PackageVersion Include="FluentValidation" Version="11.9.0" />
56
+ <PackageVersion Include="xunit" Version="2.6.6" />
57
+ </ItemGroup>
58
+ </Project>
59
+ ```
60
+
61
+ ```csharp
62
+ // xUnit test with FluentAssertions
63
+ public class UserServiceTests
64
+ {
65
+ [Fact]
66
+ public async Task GetUser_WithValidId_ReturnsUser()
67
+ {
68
+ // Arrange
69
+ var mockRepo = new Mock<IUserRepository>();
70
+ mockRepo.Setup(r => r.GetByIdAsync(1, default))
71
+ .ReturnsAsync(new User { Id = 1, Name = "Test" });
72
+ var sut = new UserService(mockRepo.Object);
73
+
74
+ // Act
75
+ var result = await sut.GetUserAsync(1);
76
+
77
+ // Assert
78
+ result.Should().NotBeNull();
79
+ result!.Name.Should().Be("Test");
80
+ mockRepo.Verify(r => r.GetByIdAsync(1, default), Times.Once);
81
+ }
82
+ }
83
+ ```
84
+
85
+ ## Reference & Examples
86
+
87
+ For CI/CD configuration and Docker setup:
88
+ See [references/REFERENCE.md](references/REFERENCE.md).
89
+
90
+ ## Related Topics
91
+
92
+ language | best-practices | security
@@ -0,0 +1,300 @@
1
+ # .NET Tooling Reference
2
+
3
+ Testing, CI/CD, and build configuration patterns.
4
+
5
+ ## References
6
+
7
+ - [**Testing Setup**](testing-setup.md) - xUnit, NUnit, integration tests.
8
+ - [**CI/CD**](ci-cd.md) - GitHub Actions, Azure DevOps pipelines.
9
+ - [**Docker**](docker.md) - Multi-stage builds for .NET.
10
+
11
+ ## Project File (.csproj) Reference
12
+
13
+ ```xml
14
+ <Project Sdk="Microsoft.NET.Sdk.Web">
15
+ <PropertyGroup>
16
+ <TargetFramework>net8.0</TargetFramework>
17
+ <Nullable>enable</Nullable>
18
+ <ImplicitUsings>enable</ImplicitUsings>
19
+
20
+ <!-- Code analysis -->
21
+ <AnalysisLevel>latest-recommended</AnalysisLevel>
22
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
23
+ <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
24
+
25
+ <!-- Assembly info -->
26
+ <Version>1.0.0</Version>
27
+ <Authors>Your Name</Authors>
28
+
29
+ <!-- Build optimization -->
30
+ <PublishTrimmed>true</PublishTrimmed>
31
+ <PublishSingleFile>true</PublishSingleFile>
32
+ <SelfContained>true</SelfContained>
33
+ </PropertyGroup>
34
+
35
+ <ItemGroup>
36
+ <!-- Package references (versions from Directory.Packages.props) -->
37
+ <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
38
+ <PackageReference Include="Serilog.AspNetCore" />
39
+ </ItemGroup>
40
+
41
+ <ItemGroup>
42
+ <!-- Project references -->
43
+ <ProjectReference Include="..\Domain\Domain.csproj" />
44
+ <ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
45
+ </ItemGroup>
46
+ </Project>
47
+ ```
48
+
49
+ ## GitHub Actions CI/CD
50
+
51
+ ```yaml
52
+ # .github/workflows/ci.yml
53
+ name: CI/CD
54
+
55
+ on:
56
+ push:
57
+ branches: [main, develop]
58
+ pull_request:
59
+ branches: [main]
60
+
61
+ env:
62
+ DOTNET_VERSION: '8.0.x'
63
+
64
+ jobs:
65
+ build-and-test:
66
+ runs-on: ubuntu-latest
67
+ steps:
68
+ - uses: actions/checkout@v4
69
+
70
+ - name: Setup .NET
71
+ uses: actions/setup-dotnet@v4
72
+ with:
73
+ dotnet-version: ${{ env.DOTNET_VERSION }}
74
+
75
+ - name: Restore dependencies
76
+ run: dotnet restore
77
+
78
+ - name: Build
79
+ run: dotnet build --no-restore --configuration Release
80
+
81
+ - name: Test
82
+ run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --results-directory ./coverage
83
+
84
+ - name: Upload coverage
85
+ uses: codecov/codecov-action@v3
86
+ with:
87
+ directory: ./coverage
88
+ fail_ci_if_error: true
89
+
90
+ publish:
91
+ needs: build-and-test
92
+ if: github.ref == 'refs/heads/main'
93
+ runs-on: ubuntu-latest
94
+ steps:
95
+ - uses: actions/checkout@v4
96
+
97
+ - name: Setup .NET
98
+ uses: actions/setup-dotnet@v4
99
+ with:
100
+ dotnet-version: ${{ env.DOTNET_VERSION }}
101
+
102
+ - name: Publish
103
+ run: dotnet publish src/WebApi/WebApi.csproj -c Release -o ./publish
104
+
105
+ - name: Build and push Docker image
106
+ uses: docker/build-push-action@v5
107
+ with:
108
+ context: .
109
+ push: true
110
+ tags: ghcr.io/${{ github.repository }}:latest
111
+ ```
112
+
113
+ ## Docker Multi-Stage Build
114
+
115
+ ```dockerfile
116
+ # Dockerfile
117
+ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
118
+ WORKDIR /src
119
+
120
+ # Copy csproj files and restore
121
+ COPY ["src/WebApi/WebApi.csproj", "src/WebApi/"]
122
+ COPY ["src/Domain/Domain.csproj", "src/Domain/"]
123
+ COPY ["src/Infrastructure/Infrastructure.csproj", "src/Infrastructure/"]
124
+ COPY ["Directory.Build.props", "./"]
125
+ COPY ["Directory.Packages.props", "./"]
126
+ RUN dotnet restore "src/WebApi/WebApi.csproj"
127
+
128
+ # Copy everything and build
129
+ COPY . .
130
+ RUN dotnet publish "src/WebApi/WebApi.csproj" -c Release -o /app/publish --no-restore
131
+
132
+ # Runtime image
133
+ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
134
+ WORKDIR /app
135
+
136
+ # Create non-root user
137
+ RUN adduser --disabled-password --gecos "" appuser
138
+ USER appuser
139
+
140
+ COPY --from=build /app/publish .
141
+
142
+ ENV ASPNETCORE_URLS=http://+:8080
143
+ EXPOSE 8080
144
+
145
+ ENTRYPOINT ["dotnet", "WebApi.dll"]
146
+ ```
147
+
148
+ ## Integration Testing with WebApplicationFactory
149
+
150
+ ```csharp
151
+ // CustomWebApplicationFactory.cs
152
+ public class CustomWebApplicationFactory<TProgram> : WebApplicationFactory<TProgram>
153
+ where TProgram : class
154
+ {
155
+ protected override void ConfigureWebHost(IWebHostBuilder builder)
156
+ {
157
+ builder.ConfigureServices(services =>
158
+ {
159
+ // Replace real database with in-memory
160
+ var descriptor = services.SingleOrDefault(
161
+ d => d.ServiceType == typeof(DbContextOptions<AppDbContext>));
162
+
163
+ if (descriptor != null)
164
+ services.Remove(descriptor);
165
+
166
+ services.AddDbContext<AppDbContext>(options =>
167
+ options.UseInMemoryDatabase("TestDb"));
168
+
169
+ // Replace external services with fakes
170
+ services.AddScoped<IEmailService, FakeEmailService>();
171
+ });
172
+
173
+ builder.UseEnvironment("Testing");
174
+ }
175
+ }
176
+
177
+ // Integration tests
178
+ public class UsersApiTests : IClassFixture<CustomWebApplicationFactory<Program>>
179
+ {
180
+ private readonly HttpClient _client;
181
+ private readonly CustomWebApplicationFactory<Program> _factory;
182
+
183
+ public UsersApiTests(CustomWebApplicationFactory<Program> factory)
184
+ {
185
+ _factory = factory;
186
+ _client = factory.CreateClient();
187
+ }
188
+
189
+ [Fact]
190
+ public async Task GetUsers_ReturnsSuccessAndUsers()
191
+ {
192
+ // Arrange - seed data
193
+ using var scope = _factory.Services.CreateScope();
194
+ var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
195
+ db.Users.Add(new User { Name = "Test User", Email = "test@example.com" });
196
+ await db.SaveChangesAsync();
197
+
198
+ // Act
199
+ var response = await _client.GetAsync("/api/users");
200
+
201
+ // Assert
202
+ response.StatusCode.Should().Be(HttpStatusCode.OK);
203
+ var users = await response.Content.ReadFromJsonAsync<List<UserDto>>();
204
+ users.Should().ContainSingle(u => u.Email == "test@example.com");
205
+ }
206
+
207
+ [Fact]
208
+ public async Task CreateUser_WithValidData_ReturnsCreated()
209
+ {
210
+ // Arrange
211
+ var newUser = new CreateUserDto { Name = "New User", Email = "new@example.com" };
212
+
213
+ // Act
214
+ var response = await _client.PostAsJsonAsync("/api/users", newUser);
215
+
216
+ // Assert
217
+ response.StatusCode.Should().Be(HttpStatusCode.Created);
218
+ response.Headers.Location.Should().NotBeNull();
219
+ }
220
+ }
221
+ ```
222
+
223
+ ## EditorConfig
224
+
225
+ ```ini
226
+ # .editorconfig
227
+ root = true
228
+
229
+ [*]
230
+ indent_style = space
231
+ indent_size = 4
232
+ end_of_line = lf
233
+ charset = utf-8
234
+ trim_trailing_whitespace = true
235
+ insert_final_newline = true
236
+
237
+ [*.cs]
238
+ # Naming conventions
239
+ dotnet_naming_rule.private_fields_should_be_camel_case.severity = error
240
+ dotnet_naming_rule.private_fields_should_be_camel_case.symbols = private_fields
241
+ dotnet_naming_rule.private_fields_should_be_camel_case.style = camel_case_underscore
242
+
243
+ dotnet_naming_symbols.private_fields.applicable_kinds = field
244
+ dotnet_naming_symbols.private_fields.applicable_accessibilities = private
245
+
246
+ dotnet_naming_style.camel_case_underscore.required_prefix = _
247
+ dotnet_naming_style.camel_case_underscore.capitalization = camel_case
248
+
249
+ # Code style
250
+ csharp_style_var_for_built_in_types = false:suggestion
251
+ csharp_style_var_when_type_is_apparent = true:suggestion
252
+ csharp_style_expression_bodied_methods = when_on_single_line:suggestion
253
+ csharp_prefer_braces = true:warning
254
+
255
+ # Formatting
256
+ csharp_new_line_before_open_brace = all
257
+ csharp_new_line_before_else = true
258
+ csharp_new_line_before_catch = true
259
+ csharp_new_line_before_finally = true
260
+
261
+ [*.{json,yml,yaml}]
262
+ indent_size = 2
263
+ ```
264
+
265
+ ## Benchmark.NET Setup
266
+
267
+ ```csharp
268
+ // Install: dotnet add package BenchmarkDotNet
269
+
270
+ [MemoryDiagnoser]
271
+ [SimpleJob(RuntimeMoniker.Net80)]
272
+ public class StringConcatBenchmarks
273
+ {
274
+ private readonly string[] _strings = Enumerable.Range(0, 100)
275
+ .Select(i => $"String{i}").ToArray();
276
+
277
+ [Benchmark(Baseline = true)]
278
+ public string ConcatWithPlus()
279
+ {
280
+ string result = "";
281
+ foreach (var s in _strings)
282
+ result += s;
283
+ return result;
284
+ }
285
+
286
+ [Benchmark]
287
+ public string ConcatWithStringBuilder()
288
+ {
289
+ var sb = new StringBuilder();
290
+ foreach (var s in _strings)
291
+ sb.Append(s);
292
+ return sb.ToString();
293
+ }
294
+
295
+ [Benchmark]
296
+ public string ConcatWithJoin() => string.Join("", _strings);
297
+ }
298
+
299
+ // Run: dotnet run -c Release
300
+ ```
@@ -1,35 +0,0 @@
1
- ---
2
- description: ⚡ Use external agentic tools to scout given directories
3
- argument-hint: [user-prompt] [scale]
4
- ---
5
-
6
- ## Purpose
7
-
8
- Utilize external agentic tools to scout given directories or explore the codebase for files needed to complete the task using a fast, token efficient agent.
9
-
10
- ## Variables
11
-
12
- USER_PROMPT: $1
13
- SCALE: $2 (defaults to 3)
14
- RELEVANT_FILE_OUTPUT_DIR: Use `Report:` from `## Naming` section
15
-
16
- ## Workflow:
17
- - Write a prompt for 'SCALE' number of agents to the `Task` tool that will immediately call the `Bash` tool to run these commands to kick off your agents to conduct the search:
18
- - `gemini -p "[prompt]" --model gemini-2.5-flash-preview-09-2025` (if count <= 3)
19
- - `opencode run "[prompt]" --model opencode/grok-code` (if count > 3 and count < 6)
20
- - if count >= 6, spawn `Explore` subagents to search the codebase in parallel
21
-
22
- **Why use external agentic tools?**
23
- - External agentic tools are faster and more efficient when using LLMs with large context windows (1M+ tokens).
24
-
25
- **How to prompt the agents:**
26
- - If `gemini` or `opencode` is not available, ask the user if they want to install it:
27
- - If **yes**, install it (if there are permission issues, instruct the user to install it manually, including authentication steps)
28
- - If **no**, use the default `Explore` subagents.
29
- - IMPORTANT: Kick these agents off in parallel using the `Task` tool, analyze and divide folders for each agent to scout intelligently and quickly.
30
- - IMPORTANT: These agents are calling OTHER agentic coding tools to search the codebase. DO NOT call any search tools yourself.
31
- - IMPORTANT: That means with the `Task` tool, you'll immediately call the Bash tool to run the respective agentic coding tool (gemini, opencode, claude, etc.)
32
- - IMPORTANT: Instruct the agents to quickly search the codebase for files needed to complete the task. This isn't about a full blown search, just a quick search to find the files needed to complete the task.
33
- - Instruct the subagent to use a timeout of 3 minutes for each agent's bash call. Skip any agents that don't return within the timeout, don't restart them.
34
- - **IMPORTANT:** Sacrifice grammar for the sake of concision when writing reports.
35
- - **IMPORTANT:** In reports, list any unresolved questions at the end, if any.
@@ -1,28 +0,0 @@
1
- ---
2
- description: ⚡⚡ Scout given directories to respond to the user's requests
3
- argument-hint: [user-prompt] [scale]
4
- ---
5
-
6
- ## Purpose
7
-
8
- Search the codebase for files needed to complete the task using a fast, token efficient agent.
9
-
10
- ## Variables
11
-
12
- USER_PROMPT: $1
13
- SCALE: $2 (defaults to 3)
14
- REPORT_OUTPUT_DIR: Use `Report:` from `## Naming` section
15
-
16
- ## Workflow:
17
-
18
- - Write a prompt for 'SCALE' number of agents to the `Task` tool that will immediately call the `Bash` tool to run these commands to kick off your agents to conduct the search: spawn many `Explore` subagents to search the codebase in parallel based on the user's prompt.
19
-
20
- **How to prompt the agents:**
21
- - IMPORTANT: Kick these agents off in parallel using the `Task` tool, analyze and divide folders for each agent to scout intelligently and quickly.
22
- - IMPORTANT: Instruct the agents to quickly search the codebase for files needed to complete the task. This isn't about a full blown search, just a quick search to find the files needed to complete the task.
23
- - Instruct the subagent to use a timeout of 3 minutes for each agent's bash call. Skip any agents that don't return within the timeout, don't restart them.
24
-
25
- **How to write reports:**
26
-
27
- - **IMPORTANT:** Sacrifice grammar for the sake of concision when writing reports.
28
- - **IMPORTANT:** In reports, list any unresolved questions at the end, if any.