From clean-builds
This skill guides developers through achieving zero-warning builds, consistent code style, and NuGet package version consistency. It provides a comprehensive workflow combining Roslynator analyzer integration (200+ code analyzers), code formatting, build quality checks, and package version validation. This skill should be used when preparing code for commit, validating build quality, fixing code style issues, ensuring all warnings are addressed, or consolidating package versions before merging.
How this skill is triggered — by the user, by Claude, or both
Slash command
/clean-builds:clean-buildsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**All script paths in this skill are relative to the skill's base directory, which is provided when this skill is invoked.**
README.mdexamples/complete-workflow.mdexamples/first-time-setup.mdexamples/fixing-warnings-bulk.mdexamples/package-version-fixes.mdexamples/roslynator-auto-fix.mdreferences/best-practices.mdreferences/one-time-setup-guide.mdreferences/package-version-management.mdreferences/roslynator-setup.mdreferences/scripts/build-and-group-errors.mdreferences/scripts/configure-roslynator-editorconfig.mdreferences/scripts/enable-roslynator-analyzers.mdreferences/scripts/format-code.mdreferences/scripts/validate-code-style-enforcement.mdreferences/scripts/validate-package-versions.mdreferences/troubleshooting.mdreferences/warning-codes-guide.mdscripts/build_and_group_errors_and_warnings.ps1scripts/configure-roslynator-editorconfig.ps1All script paths in this skill are relative to the skill's base directory, which is provided when this skill is invoked.
When you see paths like:
scripts/format-code.ps1 → Prepend the skill's base path provided in the tool responsereferences/troubleshooting.md → Located at <skill_base_path>/references/troubleshooting.mdHow to invoke scripts:
Base Path: B:\sources\DOC_Project_2025\.claude\skills\clean-builds\)Example: If base path is B:\sources\DOC_Project_2025\.claude\skills\clean-builds\ and user is in their project root:
# Construct full path to script using base path
pwsh B:\sources\DOC_Project_2025\.claude\skills\clean-builds\scripts\format-code.ps1
# Script runs in current directory (project root), but is invoked from skill directory
# User stays in their project root: B:\their-project\
Critical: Never cd to the skill directory. Always run scripts FROM the skill's base path while staying IN the user's project directory.
This skill enables developers to achieve zero-warning builds, consistent code style, and NuGet package version consistency through a proven three-step workflow:
Use this skill to:
Invoke this skill when you need to:
Before first use, complete the one-time setup:
# NOTE: Prepend skill base path to all script references below
# Run from user's project directory, not from skill directory
# Step 1: Enable code style enforcement
pwsh <skill_base_path>/scripts/validate-code-style-enforcement.ps1 -Enforce
# Step 2: Enable Roslynator analyzers
pwsh <skill_base_path>/scripts/enable-roslynator-analyzers.ps1 -ExcludeSubmodules
# Step 3: Configure .editorconfig
pwsh <skill_base_path>/scripts/configure-roslynator-editorconfig.ps1 -Severity warning
# Step 4: Validate package versions
pwsh <skill_base_path>/scripts/validate-package-versions.ps1
📖 Detailed Guide: One-Time Setup Guide
Execute before every commit:
# NOTE: Prepend skill base path to all script references
# Run from user's project directory
# 1. Validate packages
pwsh <skill_base_path>/scripts/validate-package-versions.ps1
# 2. Format code
pwsh <skill_base_path>/scripts/format-code.ps1
# 3. Build and check
pwsh <skill_base_path>/scripts/build_and_group_errors_and_warnings.ps1
# 4. Fix warnings (if any)
# 5. Repeat 2-3 until clean
📖 Detailed Guide: Complete Workflow Example
Step 1: Run the Formatter
# Prepend skill base path to script reference
pwsh <skill_base_path>/scripts/format-code.ps1
What happens:
using statements (IDE0005)Expected output:
[INFO] Formatting codebase...
[INFO] Running dotnet format style...
[SUCCESS] dotnet format completed
[INFO] Running Roslynator fixes...
[SUCCESS] Roslynator completed (45 fixes applied)
[INFO] Running ReSharper cleanup...
[SUCCESS] Complete!
Step 2: Identify Remaining Warnings
pwsh <skill_base_path>/scripts/build_and_group_errors_and_warnings.ps1
Expected output:
=====================================
Build Summary
=====================================
Total Errors: 0
Total Warnings: 12
Unique Error Codes: 0
Unique Warning Codes: 3
=====================================
Warnings by Code
=====================================
[CA1826] Use property instead of Linq method (8 occurrences)
src/Services/UserService.cs:42
src/Services/MessageService.cs:18
src/Services/ChatService.cs:35
...
[CA1859] Use concrete types when possible for improved performance (3 occurrences)
src/Models/ChatContext.cs:15
...
[IDE0052] Remove unread private members (1 occurrence)
src/Services/LegacyService.cs:33
Step 3: Fix Warnings
For CA1826 (Use property instead of LINQ):
// Before (warning)
var first = users.Where(u => u.IsActive).FirstOrDefault();
// After (fixed)
var first = users.FirstOrDefault(u => u.IsActive);
For CA1859 (Use concrete types):
// Before (warning)
IEnumerable<string> names = GetNames();
// After (fixed)
List<string> names = GetNames(); // If GetNames() returns List<string>
For IDE0052 (Remove unread members):
// Before (warning)
private string _unused = "never read";
// After (fixed)
// Simply delete the unused field
Step 4: Re-run Format and Build
# Format again to ensure consistency
pwsh <skill_base_path>/scripts/format-code.ps1
# Build and verify
pwsh <skill_base_path>/scripts/build_and_group_errors_and_warnings.ps1
Success output:
Total Errors: 0
Total Warnings: 0
✅ Build is clean!
Step 1: Validate Packages
pwsh <skill_base_path>/scripts/validate-package-versions.ps1
If you see CRITICAL issues:
🔴 Microsoft.Orleans.Core
Versions: 9.0.0, 9.2.1
Impact: Orleans framework version mismatch can cause runtime failures
Projects:
- server/AIChat.LoadTesting/AIChat.LoadTesting.csproj (9.0.0)
- server/AIChat.Server/AIChat.Server.csproj (9.2.1)
Recommended: Update all to version 9.2.1
Step 2: Fix the Mismatch
Open server/AIChat.LoadTesting/AIChat.LoadTesting.csproj and update:
<!-- Before -->
<PackageReference Include="Microsoft.Orleans.Core" Version="9.0.0" />
<!-- After -->
<PackageReference Include="Microsoft.Orleans.Core" Version="9.2.1" />
Step 3: Re-validate
pwsh <skill_base_path>/scripts/validate-package-versions.ps1
Success output:
Total Packages: 152
Inconsistent Packages: 0
CRITICAL issues: 0
✅ All packages consistent!
Complete workflow before every commit:
# NOTE: Prepend skill base path to all script references
# Run from user's project directory
# 1. Validate packages (fix CRITICAL issues if found)
pwsh <skill_base_path>/scripts/validate-package-versions.ps1
# 2. Format code
pwsh <skill_base_path>/scripts/format-code.ps1
# 3. Build and check
pwsh <skill_base_path>/scripts/build_and_group_errors_and_warnings.ps1
# 4. If warnings found, fix them and repeat steps 2-3
# 5. When clean, commit
git add .
git commit -m "Your commit message"
If you have many warnings after enabling Roslynator:
# Auto-fix what can be automated
roslynator fix DOC_Project_2025.sln --ignore-compiler-errors --format
Expected output:
Analyzing solution...
Fixed 312 diagnostics in 45 files
RCS1002: 45 fixes (Remove unnecessary braces)
RCS1036: 89 fixes (Remove unnecessary blank line)
RCS1080: 12 fixes (Use Count/Length property)
...
Then verify:
pwsh <skill_base_path>/scripts/build_and_group_errors_and_warnings.ps1
Note: All scripts are located in the
scripts/directory relative to the skill's base path. Prepend the base path when invoking scripts.
| Script | Purpose | Documentation |
|---|---|---|
build_and_group_errors_and_warnings.ps1 | Build & group warnings by code IMPORTANT | [→ Details](<skill_base_path>/references/scripts/build-and-group-errors.md) |
format-code.ps1 | Auto-fix code style issues IMPORTANT | [→ Details](<skill_base_path>/references/scripts/format-code.md) |
validate-package-versions.ps1 | Detect NuGet version mismatches | [→ Details](<skill_base_path>/references/scripts/validate-package-versions.md) |
enable-roslynator-analyzers.ps1 | Add Roslynator to all projects | [→ Details](<skill_base_path>/references/scripts/enable-roslynator-analyzers.md) |
configure-roslynator-editorconfig.ps1 | Configure .editorconfig rules | [→ Details](<skill_base_path>/references/scripts/configure-roslynator-editorconfig.md) |
validate-code-style-enforcement.ps1 | Enable code style during build | [→ Details](<skill_base_path>/references/scripts/validate-code-style-enforcement.md) |
When you run build_and_group_errors_and_warnings.ps1, warnings are grouped by code for efficient batch fixing.
IDE0005: Remove unnecessary using directive
Auto-fixed by format-code.ps1:
// Before
using System;
using System.Collections.Generic; // ← Not used, will be removed
using System.Linq;
// After (auto-fixed)
using System;
using System.Linq;
CA1826: Use property instead of Linq method
Manual fix required:
// Before (warning)
var first = users.Where(u => u.IsActive).FirstOrDefault();
// After (fixed)
var first = users.FirstOrDefault(u => u.IsActive);
CA1859: Use concrete types when possible
Manual fix:
// Before (warning)
IEnumerable<string> names = new List<string>();
// After (fixed)
List<string> names = new List<string>();
IDE0052: Remove unread private members
Manual fix - delete the unused field:
// Before (warning)
private string _unused = "never read";
// After (fixed)
// Simply delete it
RCS1036: Remove unnecessary blank line
Auto-fixed by Roslynator:
roslynator fix DOC_Project_2025.sln --ignore-compiler-errors --format
Run build and identify warnings:
pwsh <skill_base_path>/scripts/build_and_group_errors_and_warnings.ps1
Fix auto-fixable warnings first:
pwsh <skill_base_path>/scripts/format-code.ps1
Review grouped output - Warnings are grouped by code (e.g., all CA1826 together)
Fix one warning type at a time - Use IDE find/replace for patterns
Re-run build to verify fixes
Repeat until zero warnings
📖 Detailed Guide: [Warning Codes Guide](<skill_base_path>/references/warning-codes-guide.md)
🔴 CRITICAL (must fix immediately):
🟡 WARNING (should review):
📖 Detailed Guide: [Package Version Management](<skill_base_path>/references/package-version-management.md)
Common issues and solutions:
EnforceCodeStyleInBuild📖 Detailed Guide: [Troubleshooting Guide](<skill_base_path>/references/troubleshooting.md)
Core Principles:
📖 Detailed Guide: [Best Practices](<skill_base_path>/references/best-practices.md)
Roslynator provides 200+ code analyzers that run during every build.
Benefits:
Setup (one-time):
# NOTE: Prepend skill base path to script references
# Add analyzers
pwsh <skill_base_path>/scripts/enable-roslynator-analyzers.ps1 -ExcludeSubmodules
# Configure severity
pwsh <skill_base_path>/scripts/configure-roslynator-editorconfig.ps1 -Severity warning
# Auto-fix issues
roslynator fix DOC_Project_2025.sln --ignore-compiler-errors --format
Expected impact:
📖 Detailed Guide: [Roslynator Setup Guide](<skill_base_path>/references/roslynator-setup.md)
roslynator fix commandAfter achieving a clean build:
git diffRemember: Zero warnings before commit is the goal! IMPORTANT!!: MUST use scripts from within the clean-builds SKILL base directory. Always start with build_and_group_errors_and_warnings.ps1 scripts, you'll know what to do next.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub gautam-achieveai/claudeplugins --plugin clean-builds