Skip to content
FunCoding

add-refactoring

Official

Use when adding a new RR#### refactoring in roslynator, editing Refactorings.xml, registering in RefactoringContext, or when refactorings-testing.md shows XunitRefactoringVerifier — in-repo uses AbstractCSharpRefactoringVerifier and CHANGELOG.md.

Star
3,506
Last commit
Nov 1, 2026

.claude/skills/add-refactoring/SKILL.md

View on GitHub

Add Refactoring

Overview

Refactorings are metadata-driven: Refactorings.xml → codegen → register in RefactoringContext → implement → test → changelog.

When to Use

  • New RR#### refactoring in an approved issue
  • Registering a refactoring action on a syntax kind
  • <OptionKey> required on every refactoring entry

Not for: analyzers (add-analyzer), compiler fixes (add-compiler-diagnostic-fix), deprecation (deprecate-analyzer-or-refactoring).

Gate: approved GitHub issue (CONTRIBUTING.md).

Read references/implementation.md before writing tests — public refactorings-testing.md uses XunitRefactoringVerifier, which does not match in-repo tests.

Confirm metadata parameters (hard gate)

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

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

ParameterRequired?Notes
IdproposeCompute next free RR#### from Refactorings.xml; do not ask unless the issue conflicts or multiple ids are plausible
IdentifieryesPascalCase; drives generated names
TitleyesShort description (light-bulb text)
OptionKeyyesEditorConfig key segment → roslynator_refactoring.<key>.enabled
Syntaxes / Spanyes for docsWhere it can be invoked (documentation only; registration is in code)
Summary / samplesrecommendedConfirm if not in the issue

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

Quick Reference

StepLocation / command
Metadatasrc/Refactorings.xml
Codegencd tools && pwsh ./generate_code.ps1
RegisterRefactoringContext.cs or helper under Refactorings/CSharp/Refactorings/
Implementsame folder
Testssrc/Tests/Refactorings.Tests/RR####IdentifierTests.cs
ChangelogCHANGELOG.md under ## [Unreleased]

Implementation

  1. Confirm metadata parameters (hard gate above).
  2. Details and examples: references/implementation.md.

Changelog:

- Add refactoring "TITLE" ([RR####](https://josefpihrt.github.io/docs/roslynator/refactorings/RR####)) ([#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 Tests/Refactorings.Tests --no-build --filter "FullyQualifiedName~RR####"
cd src && dotnet format Roslynator.sln --no-restore --verify-no-changes --severity info

Common Mistakes

MistakeFix
Guess Title / OptionKey / IdentifierAsk — hard gate above
Follow refactorings-testing.md verbatimIn-repo: AbstractCSharpRefactoringVerifier + RefactoringId override
Missing <OptionKey>Required — EditorConfig id for enable/disable
Codegen from repo rootcd tools && pwsh ./generate_code.ps1
`[...
Only <Syntaxes> / <Span>Documentation-only; registration is in code

Similar Skills

rea-analysis-optimization

MOmorluto/rea485k9,215 new stars in the last 7 days

codebase-design

MAmattpocock/skills336k5,004 new stars in the last 7 days

Featured

diagnosing-bugs

Diagnose hard bugs and performance regressions by building a feedback loop with tests or scripts.

MAmattpocock/skills336k5,004 new stars in the last 7 days

setup-ts-deep-modules

MAmattpocock/skills336k5,004 new stars in the last 7 days

code-review

MAmattpocock/skills336k5,004 new stars in the last 7 days

implement

MAmattpocock/skills336k5,004 new stars in the last 7 days