This rule file summarizes the C#-specific policies for this repository.
Toolchain
Formatting — CSharpier: All C# source files must be formatted with CSharpier. Do not use dotnet format. Run dotnet tool restore first when the manifest tool has not been restored. Apply formatting with dotnet tool run csharpier format . and verify read-only with dotnet tool run csharpier check .. Always invoke through dotnet tool run so the manifest-pinned CSharpier version is used.
Linting — .NET Analyzers: C# code must pass Roslyn/.NET analyzer diagnostics. Command: msbuild TaskMaster.sln /t:Rebuild /m /p:Configuration=Debug "/p:Platform=Any CPU" /p:EnableNETAnalyzers=true /p:EnforceCodeStyleInBuild=true. /t:Rebuild is intentional for a warm local worktree: /t:Build can skip CoreCompile through MSBuild incrementality and exit 0 without running analyzers. CI may retain /t:Build on a cold checkout.
Type Checking — Nullable Analysis: Compiler and nullable-flow diagnostics must pass with warnings as errors. Command: msbuild TaskMaster.sln /t:Rebuild /m /p:Configuration=Debug "/p:Platform=Any CPU" /p:TreatWarningsAsErrors=true. /t:Rebuild is required locally so compiler and nullable-flow diagnostics actually run. Projects opt into nullable per file with #nullable enable; do not pass /p:Nullable=enable, which opts every unannotated file in at once.
Run the toolchain in order: format → lint → type-check → test. Restart from step 1 if any step fails or changes files.
Coding Standards
Naming: PascalCase for types and public members. camelCase for locals and private fields/parameters.
Null safety: Keep nullable reference types enabled. Model optional values with nullable annotations and guard clauses.
Composition over inheritance: Keep classes cohesive and scoped to one responsibility. Favor composition unless polymorphism is a clear requirement.
Async/await: Use async/await for I/O-bound operations. Prefer using/await using for disposable resources.
Exceptions: Fail fast with explicit exceptions. Avoid broad catch (Exception) unless at a defined boundary with added context.
Public surface: Keep public API surface intentional and minimal. Prefer internal for non-public APIs.
XML docs: Public APIs should include XML documentation comments when behavior or contract is non-obvious.
Testing Standards
Use MSTest (Microsoft.VisualStudio.TestTools.UnitTesting) as the test framework.
Use Moq for mocking.
Prefer FluentAssertions for assertions; use MSTest Assert only when FluentAssertions is not practical.
Use [TestClass] and [TestMethod] attributes.
Follow Arrange–Act–Assert structure.
No external dependencies in unit tests.
Repository-wide line coverage must remain >= 80%.
Any new module, class, or method must reach >= 90% coverage.
Coverage regression on changed lines is a blocking finding.
Deterministic Test Rules
Unit tests must not depend on network, mutable machine PATH or profile state, implicit working-directory assumptions, or external services. Use seam-based mocking for all external boundaries (processes, HTTP, filesystem, clocks). Tests must produce identical results in the IDE test runner and in CLI runs so local and CI behavior agree.
DI Seams
Introduce the smallest seam that enables reliable unit testing. Apply in this order of preference:
Interface seam (preferred) — extract boundary calls into narrow purpose-specific interfaces (for example, IProcessRunner, IFileSystem, IClock). Keep interfaces minimal.
Injectable delegate seam — use a narrow Func<>/Action<> delegate for a single call path when a full interface is excessive. Default behavior must remain safe and deterministic.
Adapter seam for static or third-party APIs — wrap the static or third-party call behind a small adapter so tests can mock the adapter with Moq.
Prohibited Behaviors
Broad refactors across unrelated projects or files.
Introducing heavy generic abstraction frameworks without need.
Creating analyzer debt and deferring cleanup.
Weakening assertions or relaxing test expectations to make tests pass.
Adding sleeps, retries, or timing hacks to mask flaky behavior.
Reporting success without running the required toolchain.
1---2name: csharp-23description: C#-specific toolchain and coding standards.4---56# C# Code Standards78Legacy C# variant resource for Codex push-down.910This rule file summarizes the C#-specific policies for this repository.1112## Toolchain13141. **Formatting — CSharpier**: All C# source files must be formatted with CSharpier. Do not use `dotnet format`. Run `dotnet tool restore` first when the manifest tool has not been restored. Apply formatting with `dotnet tool run csharpier format .` and verify read-only with `dotnet tool run csharpier check .`. Always invoke through `dotnet tool run` so the manifest-pinned CSharpier version is used.152. **Linting — .NET Analyzers**: C# code must pass Roslyn/.NET analyzer diagnostics. Command: `msbuild TaskMaster.sln /t:Rebuild /m /p:Configuration=Debug "/p:Platform=Any CPU" /p:EnableNETAnalyzers=true /p:EnforceCodeStyleInBuild=true`. `/t:Rebuild` is intentional for a warm local worktree: `/t:Build` can skip `CoreCompile` through MSBuild incrementality and exit 0 without running analyzers. CI may retain `/t:Build` on a cold checkout.163. **Type Checking — Nullable Analysis**: Compiler and nullable-flow diagnostics must pass with warnings as errors. Command: `msbuild TaskMaster.sln /t:Rebuild /m /p:Configuration=Debug "/p:Platform=Any CPU" /p:TreatWarningsAsErrors=true`. `/t:Rebuild` is required locally so compiler and nullable-flow diagnostics actually run. Projects opt into nullable per file with `#nullable enable`; do not pass `/p:Nullable=enable`, which opts every unannotated file in at once.174. **Testing — MSTest + Moq + FluentAssertions**: Run tests with: `vstest.console.exe <test-assembly-paths> /EnableCodeCoverage`1819Run the toolchain in order: format → lint → type-check → test. Restart from step 1 if any step fails or changes files.2021## Coding Standards2223- **Naming**: `PascalCase` for types and public members. `camelCase` for locals and private fields/parameters.24- **Null safety**: Keep nullable reference types enabled. Model optional values with nullable annotations and guard clauses.25- **Composition over inheritance**: Keep classes cohesive and scoped to one responsibility. Favor composition unless polymorphism is a clear requirement.26- **Async/await**: Use `async`/`await` for I/O-bound operations. Prefer `using`/`await using` for disposable resources.27- **Exceptions**: Fail fast with explicit exceptions. Avoid broad `catch (Exception)` unless at a defined boundary with added context.28- **Public surface**: Keep public API surface intentional and minimal. Prefer `internal` for non-public APIs.29- **XML docs**: Public APIs should include XML documentation comments when behavior or contract is non-obvious.3031## Testing Standards3233- Use **MSTest** (`Microsoft.VisualStudio.TestTools.UnitTesting`) as the test framework.34- Use **Moq** for mocking.35- Prefer **FluentAssertions** for assertions; use MSTest `Assert` only when FluentAssertions is not practical.36- Use `[TestClass]` and `[TestMethod]` attributes.37- Follow Arrange–Act–Assert structure.38- No external dependencies in unit tests.39- Repository-wide line coverage must remain >= 80%.40- Any new module, class, or method must reach >= 90% coverage.41- Coverage regression on changed lines is a blocking finding.4243## Deterministic Test Rules4445Unit tests must not depend on network, mutable machine PATH or profile state, implicit working-directory assumptions, or external services. Use seam-based mocking for all external boundaries (processes, HTTP, filesystem, clocks). Tests must produce identical results in the IDE test runner and in CLI runs so local and CI behavior agree.4647## DI Seams4849Introduce the smallest seam that enables reliable unit testing. Apply in this order of preference:50511. **Interface seam (preferred)** — extract boundary calls into narrow purpose-specific interfaces (for example, `IProcessRunner`, `IFileSystem`, `IClock`). Keep interfaces minimal.522. **Injectable delegate seam** — use a narrow `Func<>`/`Action<>` delegate for a single call path when a full interface is excessive. Default behavior must remain safe and deterministic.533. **Adapter seam for static or third-party APIs** — wrap the static or third-party call behind a small adapter so tests can mock the adapter with Moq.5455## Prohibited Behaviors5657- Broad refactors across unrelated projects or files.58- Introducing heavy generic abstraction frameworks without need.59- Creating analyzer debt and deferring cleanup.60- Weakening assertions or relaxing test expectations to make tests pass.61- Adding sleeps, retries, or timing hacks to mask flaky behavior.62- Reporting success without running the required toolchain.
Run npx skillmds@latest add drmoisan/csharp-2 in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
C#-specific toolchain and coding standards. It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
drmoisan (@drmoisan) published this skill. Their other Agent Skills are listed on their SkillMD profile.