modern-csharp
Skill1 starsChanged 5 months agoMITView on GitHub
Modern C# style guidance for Bendex and MicroSea code changes, including primary constructors, expression-bodied members, var usage, target-typed new, lambdas, and pattern matching.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- codewithmukesh/dotnet-claude-kittheir own version, first seen Jul 22, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- codewithmukesh/dotnet-claude-kit★ 750same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository71 other files it gives its agents.
- unsafe-checker/AGENTS.mdAGENTS.md
- activity-tracingSkill
- beadsSkill
- code-analysis-warningsSkill
- coding-guidelinesSkill
- compiler-warningsSkill
- core-actionbookSkill
- core-agent-browserSkill
- core-dynamic-skillsSkill
- core-fix-skill-docsSkill
- csharp-compiler-warningsSkill
- csharp-object-designSkill
- domain-cliSkill
- domain-cloud-nativeSkill
- domain-embeddedSkill
- domain-fintechSkill
- domain-iotSkill
- domain-mlSkill
- domain-webSkill
- dotnet-pinvokeSkill
- dreamSkill
- gitSkill
- ide-warningsSkill
- karpathy-guidelinesSkill
- m01-ownershipSkill
- m02-resourceSkill
- m03-mutabilitySkill
- m04-zero-costSkill
- m05-type-drivenSkill
- m06-error-handlingSkill
- m07-concurrencySkill
- m09-domainSkill
- m10-performanceSkill
- m11-ecosystemSkill
- m12-lifecycleSkill
- m13-domain-errorSkill
- m14-mental-modelSkill
- m15-anti-patternSkill
- mermaidSkill
- meta-cognition-parallelSkill
- msbuild-warningsSkill
- mx-creative-keypadSkill
- nuget-warningsSkill
- nullability-warningsSkill
- rcs-warningsSkill
- renpySkill
- rust-call-graphSkill
- rust-code-navigatorSkill
- rust-dailySkill
- rust-deps-visualizerSkill
- rust-learnerSkill
- rust-object-designSkill
- rust-refactor-helperSkill
- rust-routerSkill
- rust-skill-creatorSkill
- rustSkill
- rust-symbol-analyzerSkill
- rust-trait-explorerSkill
- translationsSkill
- understand-chatSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
31 rules. About 0 are common, 26 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈26
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill when writing or refactoring C# in Bendex or MicroSea projects.
- Distinctive: line 13
Keep changes local to the feature, bug fix, or warning cleanup in progress.
- Distinctive: line 14
Do not perform broad style-only rewrites unless the user explicitly asks for that cleanup.
- Distinctive: line 15
Prefer the existing style in the surrounding file when it conflicts with a rule here.
- Very specific: line 16
Do not modernize generated code, *.Designer.cs, or resource output unless the relevant specialized skill says it is safe.
- Distinctive: line 20
Use file-scoped namespaces in new C# files.
- Distinctive: line 21
Use primary constructors when constructor parameters are only used for initialization or dependency capture.
- Very specific: line 22
Prefer var when the type is obvious from the right-hand side.
- Very specific: line 23
Prefer target-typed new() when the target type is visible and readability remains clear.
- Distinctive: line 24
Prefer object and collection initializers over repeated assignment after construction.
- Distinctive: line 25
Prefer null-propagation, null-coalescing, and throw expressions when they make the intent clearer.
- Distinctive: line 26
Prefer pattern matching over separate type checks and casts.
- Distinctive: line 27
Prefer switch expressions for simple value mapping.
- Distinctive: line 28
Prefer expression-bodied members for single-expression properties, accessors, operators, conversions, lambdas, and short local functions.
- Distinctive: line 30
Write calls, constructors, and primary constructors with multiple arguments as a vertical argument list.
- Distinctive: line 31
Keep Allman braces for block-bodied code, including single-line blocks.
- Very specific: line 37
Add [DoNotPruneType] to service classes that are resolved through dependency injection.
- Distinctive: line 39
Keep the service interface visible in the declaration instead of relying only on concrete type registration.
- Distinctive: line 43
Use a primary constructor when it removes boilerplate without making lifetime or validation behavior less obvious.
- Distinctive: line 62
Keep a normal constructor when:
- Distinctive: line 69
If a constructor parameter is stored in a field because the field name improves readability, keep the field.
- Distinctive: line 73
Write multiple arguments top-to-bottom instead of left-to-right.
- Distinctive: line 92
Prefer expression-bodied form for one-expression members:
- Distinctive: line 102
Keep a block body when:
- Distinctive: line 130
When returning a newly constructed value whose type is the same as the method return type, use target-typed construction:
- Distinctive: line 141
Avoid repeating the return type:
- Distinctive: line 154
Check the target framework and language version before using newer syntax such as collection expressions, list patterns, required members, …
- Distinctive: line 156
Do not change public API shape only for style.
- Distinctive: line 157
Do not change serialization names, constructor binding, reflection behavior, dependency injection registration, or XAML/WinForms designer …
- Distinctive: line 162
Run focused tests when behavior could have changed.
- Very specific: line 163
Run .\BuildScripts\Update-FileLineEndings.ps1 -Git after editing files in Bendex or MicroSea repositories.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Modern C# style
Use this skill when writing or refactoring C# in Bendex or MicroSea projects. This skill is for intentional code style and modernization decisions. When a specific IDE* diagnostic is the trigger, also use ../ide-warnings/SKILL.md for the diagnostic-specific fix.
Scope
- Modernize code you are already touching.
- Keep changes local to the feature, bug fix, or warning cleanup in progress.
- Do not perform broad style-only rewrites unless the user explicitly asks for that cleanup.
- Prefer the existing style in the surrounding file when it conflicts with a rule here.
- Do not modernize generated code,
*.Designer.cs, or resource output unless the relevant specialized skill says it is safe.
Core rules
- Use file-scoped namespaces in new C# files.
- Use primary constructors when constructor parameters are only used for initialization or dependency capture.
- Prefer
varwhen the type is obvious from the right-hand side; keep explicit types when they improve readability or the right-hand side is not enough context. - Prefer target-typed
new()when the target type is visible and readability remains clear. - Prefer object and collection initializers over repeated assignment after construction.
- Prefer null-propagation, null-coalescing, and throw expressions when they make the intent clearer.
- Prefer pattern matching over separate type checks and casts.
- Prefer switch expressions for simple value mapping.
- Prefer expression-bodied members for single-expression properties, accessors, operators, conversions, lambdas, and short local functions.
- For ordinary methods, use an expression body only when it stays readable and does not hide important control flow.
- Write calls, constructors, and primary constructors with multiple arguments as a vertical argument list.
- Keep Allman braces for block-bodied code, including single-line blocks.
Services
Services in this project are commonly resolved by dependency injection and must remain visible to tooling that prunes unused types.
- Add
[DoNotPruneType]to service classes that are resolved through dependency injection. - Implement the service or base interface used for registration and resolution.
- Keep the service interface visible in the declaration instead of relying only on concrete type registration.
Primary constructors
Use a primary constructor when it removes boilerplate without making lifetime or validation behavior less obvious.
Good candidates:
[DoNotPruneType]
public sealed class CustomerService(
IRepository repository,
ILogger<CustomerService> logger)
: ICustomerService
{
public Customer Load(int id)
{
logger.LogDebug("Loading customer {CustomerId}", id);
return repository.Get(id);
}
}Keep a normal constructor when:
- Constructor logic has meaningful branching, validation, or exception messages.
- Several overloads delegate to one canonical constructor.
- XML documentation on constructor parameters is important and would become less readable.
- The type is serialized, reflected, designer-created, or framework-created and constructor shape is part of a contract.
If a constructor parameter is stored in a field because the field name improves readability, keep the field. Otherwise, use the primary constructor parameter directly.
Argument lists
Write multiple arguments top-to-bottom instead of left-to-right. This keeps diffs stable and avoids long lines.
Prefer:
var result = factory.Create(
customerId,
machineId,
cancellationToken);Avoid:
var result = factory.Create(customerId, machineId, cancellationToken);Expression bodies and lambdas
Prefer expression-bodied form for one-expression members:
public bool IsEnabled => _settings.Enabled;
public string GetDisplayName() => $"{FirstName} {LastName}";
items.Select(item => item.Name);Keep a block body when:
- The body has more than one statement.
- The expression needs comments to be understood.
- Debugging, tracing, or exception handling is clearer with statements.
- The expression would wrap awkwardly or obscure the domain operation.
For lambdas, prefer expression form for a single returned expression. Use a block lambda when there are multiple statements, logging, tracing, local variables, or deliberate side effects.
Implicit typing
C# methods require explicit return types. Do not invent implicit method return types. Use implicit typing for locals and lambdas where the language supports it and the result remains obvious.
Prefer:
var result = new MachineState(); // or: MachineState result = new();
Func<int, bool> isValid = value => value > 0;Avoid:
var result = GetValue();when GetValue() does not make the type or domain role clear.
When returning a newly constructed value whose type is the same as the method return type, use target-typed construction:
public MachineState CreateState()
{
return new(
machineId,
settings);
}Avoid repeating the return type:
public MachineState CreateState()
{
return new MachineState(
machineId,
settings);
}Compatibility boundaries
- Check the target framework and language version before using newer syntax such as collection expressions, list patterns, required members, or raw string literals.
- Be careful in
net472and mixed-framework projects where analyzers may allow syntax that older tooling, generators, or designers handle poorly. - Do not change public API shape only for style.
- Do not change serialization names, constructor binding, reflection behavior, dependency injection registration, or XAML/WinForms designer activation as a side effect of modernization.
Verification
- Build the smallest relevant project or solution after modernization.
- Run focused tests when behavior could have changed.
- Run
.\BuildScripts\Update-FileLineEndings.ps1 -Gitafter editing files in Bendex or MicroSea repositories.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

