skills/refactoring-csharp/SKILL.md
Rename and refactor C# symbols in a .NET solution or multi-solution monorepo with a one-shot Roslyn CLI. Use when the user asks to rename a symbol, preview impact, update references across a solution, or refactor shared projects across several solutions.
npx skillsauth add codealive-ai/agents-reflection-skills refactoring-csharpInstall 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.
This skill ships a Roslyn-based C# rename CLI in src/. It is intentionally one-shot and
stateless: one call resolves the target, validates the request, and returns either a preview
or an applied rename. There is no public prepare step.
If the skill was installed by install.sh, prefer the prebuilt CLI:
bin/csharp-refactor rename-symbol <sln|slnx|directory> <file> <line> <oldName> <newName> [dryRun=false|true]
Otherwise run the bundled source CLI from the skill directory:
dotnet run --project src/CSharpRefactoring.Cli -- rename-symbol <sln|slnx|directory> <file> <line> <oldName> <newName> [dryRun=false|true]
When invoked from outside the skill directory, use an absolute project path:
/<skill-dir>/bin/csharp-refactor rename-symbol <sln|slnx|directory> <file> <line> <oldName> <newName> [dryRun=false|true]
# or, if no prebuilt binary is installed:
dotnet run --project /path/to/refactoring-csharp/src/CSharpRefactoring.Cli -- rename-symbol <sln|slnx|directory> <file> <line> <oldName> <newName> [dryRun=false|true]
The tool project may create normal bin/ and obj/ directories under the skill. That is
expected and useful: it lets repeated runs reuse the .NET build cache instead of rebuilding
the CLI from scratch.
The target solution is not redirected to a temporary build output. The CLI opens the solution
from the solution directory and lets Roslyn/MSBuild use the target project's normal build
cache (obj/, bin/, or the repository's configured artifacts layout). This is intentional:
it avoids creating a second cache tree for the project being refactored and lets repeated
renames benefit from the project's existing MSBuild/Roslyn design-time build cache.
| Field | Required | Default | Notes |
| --- | --- | --- | --- |
| solution_path | yes | - | Absolute path to the .sln/.slnx file, or a repository directory for monorepo-wide refactoring. |
| file_path | yes | - | Absolute path to a file inside the solution. |
| line_number | yes | - | 1-based line number. Use the value reported by rg -n. |
| old_name | yes | - | Exact current identifier on that line. This is the anchor. |
| new_name | yes | - | Must be a valid C# identifier. |
| dry_run | no | false | Apply changes by default. Preview only when explicitly set to true. |
| rename_overloads | no | false | Keep overloads unchanged by default. |
| rename_in_strings | no | false | String literals stay untouched by default. |
| rename_in_comments | no | true | Comments are renamed by default. |
| rename_file | no | true | Safe file move for supported named types. Never recreate the file as delete+add. |
rg -n to locate the symbol and copy the 1-based line number directly.rename-symbol once without the dryRun argument for normal rename requests. This applies the rename.dryRun=true only when the user explicitly asks for preview, when the target is ambiguous, or when the rename is unusually broad/risky and applying immediately would be irresponsible. The CLI also accepts true, --dry-run, dryRun=false, false, and --no-dry-run; invalid values fail fast and must never silently apply.Use directory mode only when a repository contains multiple .sln/.slnx files or shared
projects that are not all present in one normal solution. For ordinary repositories, pass the
specific solution file because it is faster and avoids scanning unrelated projects.
When solution_path is a directory:
solution_path.file_path as the absolute path to the target source file..sln, .slnx, and supported project files under the directory..slnx, opens that aggregate solution, performs the rename, and deletes the temporary solution directory before returning.solution_path is a directory, the tool scans it recursively, merges discovered .sln, .slnx, and project files into one temporary .slnx, opens that solution, runs the rename, and deletes the temporary solution directory before returning..sln/.slnx input, the tool runs Roslyn from the target solution directory. For a directory input, it runs Roslyn from that directory while opening the temporary aggregate solution. In both modes, project files stay in place and use the target project's normal MSBuild outputs.file_path, line_number, and old_name.old_name is mandatory because it disambiguates the target when a line contains more than one renameable identifier.bin/ and obj/ cache unless the user explicitly asks for a clean/no-cache run.Treat these as supported rename targets when the Roslyn symbol is source-backed and
CanBeReferencedByName:
NamedTypeMethodPropertyFieldEventParameterLocalTypeParameterNamespaceDo not rename constructors, destructors, static constructors, or indexers.
rename_file=true is a convenience default, but it only produces a real safe move when the
symbol is a single-declaration named type and the file stem matches the current type name.
If the tool does not return file_move_from_path and file_move_to_path, the symbol rename is still valid,
but the file itself was not moved. Do not claim a file rename happened unless the tool reports it.
This is intentionally conservative so git sees a tracked rename instead of a delete+add pair.
Use the tool's error codes as actionable guidance:
| Error code | Meaning | What to do |
| --- | --- | --- |
| invalid_solution_path | Solution path is missing, does not exist, or is neither .sln/.slnx nor a directory. | Ask for a real solution path or repository directory. |
| invalid_file_path | File path is missing or not present on disk. | Ask for the correct file path. |
| file_not_in_solution | The file is not part of the loaded solution. | Ask for the correct file or solution. |
| invalid_line_number | Line number is outside file bounds or not 1-based. | Ask for the correct line. |
| invalid_old_name | old_name was empty or whitespace. | Ask for the exact current name. |
| old_name_not_found_on_line | No renameable symbol with that name exists on the line. | Ask for a better line or file. |
| ambiguous_old_name_on_line | More than one renameable symbol matches that name on the line. | Narrow the target or use a different line. |
| unsupported_symbol_kind | Roslyn found a symbol, but this kind is not renameable here. | Move to a supported symbol kind. |
| symbol_not_in_source | The symbol is not declared in source. | Pick a source-backed target. |
| invalid_new_name | new_name is not a valid C# identifier. | Propose a valid identifier. |
| same_name | New name equals the current name. | Ask for a different name. |
| no_changes | Roslyn produced no text edits. | Re-check the target or the new name. |
| apply_failed | Workspace apply failed. | Treat as a runtime failure and retry only if the state is unchanged. |
| operation_timeout | The rename timed out. | Retry with a larger timeout or a narrower target. |
A rename workflow is complete when:
line_number + old_name.development
Use this skill when the user asks to plan, design, scope, estimate, or implement a feature, bug fix, refactor, migration, integration, API change, UI change, or other project modification. Enforces a planning gate before editing code — investigate project context, analyze the task, surface ambiguities, contradictions, risks, dependencies, and blockers, ask focused questions, produce an evidence-based step-by-step plan, and implement only after explicit user approval. Not for trivial one-line edits, pure questions about the codebase, or changes the user has already reviewed and approved for direct implementation.
tools
Hands-on playbook for Windows 11 disk cleanup, dev-machine optimization, and proactive health alerting. Use when the PC is full or slow, when a BSOD / Kernel-Power 41 / crash dump / commit-memory pressure happened, when the user asks to free disk space, audit storage, set up disk/memory alerts, or restore the same monitoring on a new PC. Built around native Microsoft-supported tooling (Storage Sense, cleanmgr, DISM, pnputil, vssadmin, wevtutil, powercfg) as the safety floor, a drift-protected HTML cleanup UI, and a Task Scheduler + BurntToast alerter. Covers dev machines with heavy AI/Docker/WSL workloads. Not for general Windows support, hardware diagnostics, GPU/driver troubleshooting, antivirus/malware removal, Windows Update repair, networking, or app-specific performance problems unrelated to disk or memory pressure.
tools
Search, find, discover, install, remove, update, review, list, move, optimise, and iterate on skills for AI coding agents. Use when user asks "find a skill for X", "search for a skill", "is there a skill for X", "install skill", "remove skill", "update skills", "list skills", "review skill quality", "move skill", "check for updates", "optimise skill", "train skill on tasks", "iterate skill", "audit skill edits", "log skill edit", "diff skill versions", "trigger test skill", "transfer skill across agents", or "how do I do X" where X might have an existing skill. THE tool for skill discovery, ecosystem search, and SkillOpt-style training loops. Do not use for creating skills from scratch (use /skill-creator instead).
development
First Principles Framework (FPF) — thinking amplifier. Use when user wants to think through a complex problem, architect a system, evaluate alternatives, decompose complexity, classify problems, define quality attributes, plan rigorously, make decisions under uncertainty, establish causality, reason about time and trends, describe architecture or structural views, check mathematical model fit, or improve pattern quality. Also triggers on: FPF, bounded contexts, SoTA packs, assurance calculus, decision theory, causal reasoning, temporal reasoning, architecture description, quality gates, FPF Parts A-K. Not for simple task planning, general philosophy, or Agile unrelated to FPF.