AugmentClaude

Add Analyzer

Add a new Roslyn diagnostic rule with metadata, code fix, and tests.

Installation

  1. Make sure Claude is on your device and in your terminal.

    Skills load from ~/.claude/skills/ when Claude Code starts up β€” so you need it on your machine first. If you don't have it yet, install it once with the command below, then run claude in any terminal to verify.

    One-time setup
    npm i -g @anthropic-ai/claude-code

    Already have it? Skip ahead.

  2. Paste into Claude Code or into your terminal.

    This copies the whole skill folder into ~/.claude/skills/add-analyzer-dotnet/ β€” the SKILL.md plus any scripts, reference docs, or templates the skill ships with. Safe default: works for every skill.

    Faster alternative (instruction-only skills)

    Skips the clone and grabs only the SKILL.md file. Don't use this if the skill ships Python scripts, reference markdowns, or asset templates β€” they won't be downloaded and the skill will fail when it tries to load them.

    Quick install (SKILL.md only)
    Sign up to copy
  3. Restart Claude Code.

    Quit and reopen Claude Code (or any other agent that loads from ~/.claude/skills/). New skills are picked up on startup.

  4. Just ask Claude.

    Skills auto-activate when your request matches the skill's description β€” no slash command needed. Trigger phrases live in the skill's own frontmatter; you can read them in the β€œWhat this skill does” section above.

Prefer to read the source first? Open on GitHub.

When Claude uses it

Use when adding a new RCS#### diagnostic in roslynator (RCS0 formatting, RCS1 general, RCS9 code-analysis), wiring roslynator_* EditorConfig options, or when docs say CHANGELOG.md, XunitDiagnosticVerifier, or analyzers-testing.md β€” those are wrong for in-repo contribution.

What this skill does

Add Analyzer

Overview

Roslynator analyzers are metadata-driven: edit Analyzers.xml, codegen, implement analyzer + code fix, test, changelog. New analyzers never set <Status> β€” only IsEnabledByDefault.

When to Use

  • New RCS0 / RCS1 / RCS9 rule requested in an approved issue
  • Analyzer needs a new or existing roslynator_* config option
  • Picking package: RCS0 β†’ Formatting, RCS1 β†’ Analyzers, RCS9 β†’ CodeAnalysis.Analyzers

Not for: deprecating rules (deprecate-analyzer-or-refactoring), bug fixes (fix-analyzer-bug), refactorings (add-refactoring).

Gate: CONTRIBUTING.md requires an approved GitHub issue before implementation.

Read this skill and references/implementation.md before writing tests. Published analyzers-testing.md targets NuGet consumers β€” copying it produces code that does not compile in this repo.

Confirm metadata parameters (hard gate)

STOP. Do NOT edit Analyzers.xml, run codegen, or implement until the user has confirmed every required parameter below. Do not invent defaults when the user (or issue) did not state them.

Use AskQuestion when available; otherwise ask conversationally. Batch related choices.

ParameterRequired?Allowed / notes
IdproposeCompute next free RCS0 / RCS1 / RCS9 id from Analyzers.xml; do not ask unless the issue conflicts or multiple ids are plausible
IdentifieryesPascalCase; drives generated names
TitleyesShort description
DefaultSeverityyesHidden, Info, Warning, or Error β€” always ask
IsEnabledByDefaultyestrue / false β€” always ask (RCS0 often false)
MessageFormatif message has {n} placeholdersOtherwise omit (same as Title)
Code fix?yesStrongly recommended; confirm yes/no
SupportsFadeOut / fade-out analyzernoAsk only if unused-code style
MinLanguageVersionnoAsk only if C# version-gated
Config optionnoSee config-options.md

When proposing Id, state the chosen value in your plan/summary (e.g. β€œusing next free RCS9012”). Skip asking other parameters only when the approved issue or the user's message already states the value explicitly.

Quick Reference

StepLocation / command
Metadatasrc/Analyzers.xml β€” see analyzer-schema.md
Config optionsrc/ConfigOptions.xml β€” see config-options.md
Codegencd tools && pwsh ./generate_code.ps1
AnalyzerRCS1 β†’ Analyzers/CSharp/Analysis/; RCS0 β†’ Formatting.Analyzers/CSharp/; RCS9 β†’ CodeAnalysis.Analyzers/CSharp/
Code fixmatching *.CodeFixes/CSharp/CodeFixes/
Testssrc/Tests/<Package>.Tests/RCS####IdentifierTests.cs
ChangelogCHANGELOG.md under ## [Unreleased]

Implementation

  1. Confirm metadata parameters (hard gate above).
  2. Add <Analyzer> entry; schema in references/analyzer-schema.md. Use docs-site analyzer-metadata, not Template.Analyzers.xml.
  3. Optional config option before codegen β€” references/config-options.md.
  4. Codegen from tools/ (required cwd β€” see Common Mistakes).
  5. Implement analyzer, code fix (if confirmed), tests β€” references/implementation.md.

Changelog line:

- Add analyzer "TITLE" ([RCS1234](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1234)) ([#PR](https://github.com/dotnet/roslynator/pull/PR))

Verify:

cd tools && pwsh ./generate_code.ps1
cd src && dotnet build Roslynator.sln
cd src && dotnet test Roslynator.sln --no-build --filter "FullyQualifiedName~RCS####"
cd src && dotnet format Roslynator.sln --no-restore --verify-no-changes --severity info

Common Mistakes

MistakeFix
Guess DefaultSeverity / IsEnabledByDefaultAsk β€” hard gate above
Follow analyzers-testing.md verbatimIn-repo: AbstractCSharpDiagnosticVerifier + Descriptor = DiagnosticRules.X
pwsh tools/generate_code.ps1 from repo rootRun cd tools && pwsh ./generate_code.ps1 β€” generator uses ../src relative to cwd
<Status> on new analyzerUse only IsEnabledByDefault; lifecycle is deprecate-analyzer-or-refactoring
context.ReportDiagnosticUse DiagnosticHelpers.ReportDiagnostic
Lazy SupportedDiagnostics field initializerUse Immutable.InterlockedInitialize pattern

Related skills