skills/quality/code-analysis/SKILL.md
Use when configuring Roslyn analyzers, StyleCop, or EditorConfig for static analysis.
npx skillsauth add faysilalshareef/dotnet-ai-kit code-analysisInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
.editorconfig enforces consistent code style across the teamDirectory.Build.props enables analyzers for all projectsTreatWarningsAsErrors in CI prevents degradationEnforceCodeStyleInBuild enables style warnings during build# .editorconfig (solution root)
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = crlf
charset = utf-8-bom
trim_trailing_whitespace = true
insert_final_newline = true
[*.cs]
# Namespace
csharp_style_namespace_declarations = file_scoped:warning
# Using directives
dotnet_sort_system_directives_first = true
csharp_using_directive_placement = outside_namespace:warning
# var preferences
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion
# Expression-bodied members
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
csharp_style_expression_bodied_properties = true:suggestion
# Null checking
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
# Naming conventions
dotnet_naming_rule.private_fields.symbols = private_fields
dotnet_naming_rule.private_fields.style = _camelCase
dotnet_naming_rule.private_fields.severity = warning
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_style._camelCase.required_prefix = _
dotnet_naming_style._camelCase.capitalization = camel_case
# Analyzer severity
dotnet_diagnostic.CA1062.severity = warning # Validate arguments
dotnet_diagnostic.CA1822.severity = suggestion # Mark static
dotnet_diagnostic.CA2007.severity = none # ConfigureAwait
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.182">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
// stylecop.json (solution root)
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"companyName": "{Company}",
"xmlHeader": false,
"documentInterfaces": false,
"documentPrivateElements": false
},
"orderingRules": {
"usingDirectivesPlacement": "outsideNamespace"
}
}
}
// Targeted suppression (prefer over global)
[SuppressMessage("Style", "IDE0057",
Justification = "Range operator less readable here")]
public string GetPrefix(string value) => value.Substring(0, 3);
// Global suppression file
// GlobalSuppressions.cs
[assembly: SuppressMessage("Design", "CA1062",
Scope = "namespaceanddescendants",
Target = "~N:{Company}.{Domain}.Tests")]
| Anti-Pattern | Correct Approach | |---|---| | Disabling all warnings | Fix warnings or suppress with justification | | No .editorconfig | Create one at solution root | | Analyzers only in CI | Enable in IDE and build | | Global suppressions without justification | Always include Justification |
# Find .editorconfig
find . -name ".editorconfig" -type f
# Find analyzer packages
grep -r "StyleCop\|Meziantou\|Roslynator" --include="*.csproj" .
grep -r "StyleCop\|Meziantou\|Roslynator" --include="*.props" .
# Find TreatWarningsAsErrors
grep -r "TreatWarningsAsErrors" --include="*.props" --include="*.csproj" .
.editorconfig — extend, don't replaceDirectory.Build.propsTreatWarningsAsErrors without fixing existing warningsdotnet format to auto-fix formatting issuesdata-ai
Use when about to claim work is complete, fixed, passing, or ready — before committing, creating PRs, or moving to the next task. Requires running verification commands and confirming output before making any success claims.
development
Use when encountering any bug, test failure, build error, or unexpected behavior — before proposing fixes or making changes.
development
Use when checkpointing, wrapping up, or handing off an AI-assisted development session.
development
Use when following the Specification-Driven Development lifecycle from plan through ship.