{"id":"fac7cf27-4f42-4997-8116-61e1aa38d97c","shortId":"TPvNzK","kind":"skill","title":"refactoring-csharp","tagline":"Rename and refactor C# symbols in a solution with a one-shot Roslyn CLI. Use when the user asks to rename a symbol, preview impact, or update references across a .NET solution.","description":"# Refactoring C# Symbols\n\nThis skill ships a Roslyn-based C# rename CLI in `src/`. It is intentionally one-shot and\nstateless: one call resolves the target, validates the request, and returns either a preview\nor an applied rename. There is no public prepare step.\n\n## Canonical CLI\n\nIf the skill was installed by `install.sh`, prefer the prebuilt CLI:\n\n```bash\nbin/csharp-refactor rename-symbol <sln> <file> <line> <oldName> <newName> [dryRun=false|true]\n```\n\nOtherwise run the bundled source CLI from the skill directory:\n\n```bash\ndotnet run --project src/CSharpRefactoring.Cli -- rename-symbol <sln> <file> <line> <oldName> <newName> [dryRun=false|true]\n```\n\nWhen invoked from outside the skill directory, use an absolute project path:\n\n```bash\n/<skill-dir>/bin/csharp-refactor rename-symbol <sln> <file> <line> <oldName> <newName> [dryRun=false|true]\n# or, if no prebuilt binary is installed:\ndotnet run --project /path/to/refactoring-csharp/src/CSharpRefactoring.Cli -- rename-symbol <sln> <file> <line> <oldName> <newName> [dryRun=false|true]\n```\n\nThe tool project may create normal `bin/` and `obj/` directories under the skill. That is\nexpected and useful: it lets repeated runs reuse the .NET build cache instead of rebuilding\nthe CLI from scratch.\n\nThe target solution is not redirected to a temporary build output. The CLI opens the solution\nfrom the solution directory and lets Roslyn/MSBuild use the target project's normal build\ncache (`obj/`, `bin/`, or the repository's configured artifacts layout). This is intentional:\nit avoids creating a second cache tree for the project being refactored and lets repeated\nrenames benefit from the project's existing MSBuild/Roslyn design-time build cache.\n\n## Contract\n\n| Field | Required | Default | Notes |\n| --- | --- | --- | --- |\n| `solution_path` | yes | - | Absolute path to the `.sln` or `.slnx` file. |\n| `file_path` | yes | - | Absolute path to a file inside the solution. |\n| `line_number` | yes | - | 1-based line number. Use the value reported by `rg -n`. |\n| `old_name` | yes | - | Exact current identifier on that line. This is the anchor. |\n| `new_name` | yes | - | Must be a valid C# identifier. |\n| `dry_run` | no | `false` | Apply changes by default. Preview only when explicitly set to `true`. |\n| `rename_overloads` | no | `false` | Keep overloads unchanged by default. |\n| `rename_in_strings` | no | `false` | String literals stay untouched by default. |\n| `rename_in_comments` | no | `true` | Comments are renamed by default. |\n| `rename_file` | no | `true` | Safe file move for supported named types. Never recreate the file as delete+add. |\n\n## How To Use It\n\n1. Use `rg -n` to locate the symbol and copy the 1-based line number directly.\n2. Call `rename-symbol` once without the `dryRun` argument for normal rename requests. This applies the rename.\n3. Use `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.\n4. Do not run a dry run just because the tool supports it. The tool loads the solution on every call, so preview+apply doubles the cost on large projects.\n5. Summarize the result by reporting the original name, new name, changed document count, total text changes, changed files, and any file move.\n\n## Important Behavioral Rules\n\n- The tool is stateless. It loads the solution on every call.\n- A preview does not reserve state. If the workspace changes between preview and apply, rerun the preview.\n- Prefer one apply call over preview+apply when the user already asked to perform the rename.\n- The tool runs Roslyn from the target solution directory and uses the target project's normal MSBuild outputs. Do not pass properties that redirect the target project's `BaseIntermediateOutputPath`, `BaseOutputPath`, or `ArtifactsPath` unless the user explicitly asks for isolated build outputs.\n- Do not invent a session or hidden prepare state.\n- Do not ask for a column number. The tool resolves from `file_path`, `line_number`, and `old_name`.\n- `old_name` is mandatory because it disambiguates the target when a line contains more than one renameable identifier.\n- The bundled source requires .NET 10 and restores NuGet packages on first run.\n- Let the tool keep its own normal `bin/` and `obj/` cache unless the user explicitly asks for a clean/no-cache run.\n- If the tool returns a preview, say preview. If it returns applied changes, say applied.\n- Keep responses concise and action-oriented. Tell the user what changed and whether a file move happened.\n\n## Supported Targets\n\nTreat these as supported rename targets when the Roslyn symbol is source-backed and\n`CanBeReferencedByName`:\n\n- `NamedType`\n- `Method`\n- `Property`\n- `Field`\n- `Event`\n- `Parameter`\n- `Local`\n- `TypeParameter`\n- `Namespace`\n\nDo not rename constructors, destructors, static constructors, or indexers.\n\n## File Rename Nuance\n\n`rename_file=true` is a convenience default, but it only produces a real safe move when the\nsymbol is a single-declaration named type and the file stem matches the current type name.\n\nIf the tool does not return `file_move_from_path` and `file_move_to_path`, the symbol rename is still valid,\nbut the file itself was not moved. Do not claim a file rename happened unless the tool reports it.\n\nThis is intentionally conservative so git sees a tracked rename instead of a delete+add pair.\n\n## Error Handling\n\nUse the tool's error codes as actionable guidance:\n\n| Error code | Meaning | What to do |\n| --- | --- | --- |\n| `invalid_solution_path` | Solution path is missing or not a `.sln`/`.slnx` file. | Ask for a real solution path. |\n| `invalid_file_path` | File path is missing or not present on disk. | Ask for the correct file path. |\n| `file_not_in_solution` | The file is not part of the loaded solution. | Ask for the correct file or solution. |\n| `invalid_line_number` | Line number is outside file bounds or not 1-based. | Ask for the correct line. |\n| `invalid_old_name` | `old_name` was empty or whitespace. | Ask for the exact current name. |\n| `old_name_not_found_on_line` | No renameable symbol with that name exists on the line. | Ask for a better line or file. |\n| `ambiguous_old_name_on_line` | More than one renameable symbol matches that name on the line. | Narrow the target or use a different line. |\n| `unsupported_symbol_kind` | Roslyn found a symbol, but this kind is not renameable here. | Move to a supported symbol kind. |\n| `symbol_not_in_source` | The symbol is not declared in source. | Pick a source-backed target. |\n| `invalid_new_name` | `new_name` is not a valid C# identifier. | Propose a valid identifier. |\n| `same_name` | New name equals the current name. | Ask for a different name. |\n| `no_changes` | Roslyn produced no text edits. | Re-check the target or the new name. |\n| `apply_failed` | Workspace apply failed. | Treat as a runtime failure and retry only if the state is unchanged. |\n| `operation_timeout` | The rename timed out. | Retry with a larger timeout or a narrower target. |\n\n## Success Criteria\n\nA rename workflow is complete when:\n\n- The target was resolved from `line_number` + `old_name`.\n- The user approved the rename, or explicitly requested a dry run only.\n- The tool returned changed documents, total text changes, and any file move details.\n- The final answer makes the applied scope clear enough for the user to trust the change.\n\n## Recommended Output Style\n\n- For previews, say what would change and that nothing was applied.\n- For applied changes, say what changed and whether the file was moved.\n- If the file move fields are present, mention them explicitly.\n- If the tool returned an error code, echo the code and the human-readable reason.","tags":["refactoring","csharp","driven","development","codealive-ai","agent-safety","agent-skills","ai-coding","ai-driven-development","ai-safety","antigravity","bash"],"capabilities":["skill","source-codealive-ai","skill-refactoring-csharp","topic-agent-safety","topic-agent-skills","topic-ai-coding","topic-ai-driven-development","topic-ai-safety","topic-antigravity","topic-bash","topic-claude-code","topic-codex-cli","topic-cursor","topic-developer-tools","topic-gemini-cli"],"categories":["ai-driven-development"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/CodeAlive-AI/ai-driven-development/refactoring-csharp","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add CodeAlive-AI/ai-driven-development","source_repo":"https://github.com/CodeAlive-AI/ai-driven-development","install_from":"skills.sh"}},"qualityScore":"0.483","qualityRationale":"deterministic score 0.48 from registry signals: · indexed on github topic:agent-skills · 67 github stars · SKILL.md body (7,879 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T18:57:07.344Z","embedding":null,"createdAt":"2026-05-11T18:57:19.442Z","updatedAt":"2026-05-18T18:57:07.344Z","lastSeenAt":"2026-05-18T18:57:07.344Z","tsv":"'/bin/csharp-refactor':138 '/path/to/refactoring-csharp/src/csharprefactoring.cli':155 '1':297,397,408,952 '10':677 '2':413 '3':431 '4':486 '5':516 'absolut':134,275,286 'accept':464 'across':33 'action':725,876 'action-ori':724 'add':392,865 'alreadi':580 'also':463 'ambigu':447,997 'anchor':320 'answer':1179 'appli':75,334,428,456,485,509,566,572,576,716,719,1102,1105,1182,1206,1208 'approv':1154 'argument':422 'artifact':234 'artifactspath':617 'ask':23,440,581,622,638,700,897,915,934,954,968,990,1081 'avoid':240 'back':753,1056 'base':46,298,409,953 'baseintermediateoutputpath':614 'baseoutputpath':615 'bash':96,114,137 'behavior':540 'benefit':255 'better':993 'bin':168,228,692 'bin/csharp-refactor':97 'binari':149 'bound':949 'broad/risky':454 'build':187,205,225,265,625 'bundl':107,673 'c':7,38,47,328,1067 'cach':188,226,244,266,695 'call':61,414,506,552,573 'canbereferencedbynam':755 'canon':83 'chang':335,527,532,533,562,717,731,1087,1167,1171,1192,1201,1209,1212 'check':1095 'claim':841 'clean/no-cache':703 'clear':1184 'cli':18,49,84,95,109,193,208,462 'code':874,879,1235,1238 'column':641 'comment':367,370 'complet':1141 'concis':722 'configur':233 'conserv':854 'constructor':768,771 'contain':666 'contract':267 'conveni':782 'copi':406 'correct':918,937,957 'cost':512 'count':529 'creat':166,241 'criteria':1136 'csharp':3 'current':312,808,972,1079 'declar':799,1049 'default':270,337,353,364,374,783 'delet':391,864 'design':263 'design-tim':262 'destructor':769 'detail':1176 'differ':1019,1084 'direct':412 'directori':113,131,171,215,594 'disambigu':660 'disk':914 'document':528,1168 'dotnet':115,152 'doubl':510 'dri':330,467,475,491,1161 'dry-run':466 'dryrun':101,122,142,159,421,433,469 'echo':1236 'edit':1092 'either':70 'empti':965 'enough':1185 'equal':1077 'error':867,873,878,1234 'event':760 'everi':505,551 'exact':311,971 'exist':260,986 'expect':177 'explicit':341,439,621,699,1158,1228 'fail':479,1103,1106 'failur':1111 'fals':102,123,143,160,333,348,358,470,471 'fast':480 'field':268,759,1223 'file':282,283,290,376,380,389,534,537,647,735,774,778,804,817,822,834,843,896,904,906,919,921,926,938,948,996,1174,1216,1221 'final':1178 'first':683 'found':977,1025 'git':856 'guidanc':877 'handl':868 'happen':737,845 'hidden':633 'human':1242 'human-read':1241 'identifi':313,329,671,1068,1072 'immedi':457 'impact':29 'import':539 'index':773 'insid':291 'instal':89,151 'install.sh':91 'instead':189,861 'intent':54,238,853 'invalid':477,884,903,941,959,1058 'invent':629 'invok':126 'irrespons':460 'isol':624 'keep':349,688,720 'kind':1023,1030,1040 'larg':514 'larger':1129 'layout':235 'let':181,217,252,685 'line':294,299,316,410,649,665,942,944,958,979,989,994,1001,1012,1020,1148 'liter':360 'load':501,547,932 'local':762 'locat':402 'make':1180 'mandatori':657 'match':806,1007 'may':165 'mean':880 'mention':1226 'method':757 'miss':890,909 'move':381,538,736,791,818,823,838,1035,1175,1218,1222 'msbuild':602 'msbuild/roslyn':261 'must':324,482 'n':307,400 'name':309,322,384,524,526,653,655,800,810,961,963,973,975,985,999,1009,1060,1062,1074,1076,1080,1085,1101,1151 'namedtyp':756 'namespac':764 'narrow':1013,1133 'net':35,186,676 'never':386,483 'new':321,525,1059,1061,1075,1100 'no-dry-run':473 'normal':167,224,424,601,691 'note':271 'noth':1204 'nuanc':776 'nuget':680 'number':295,300,411,642,650,943,945,1149 'obj':170,227,694 'old':308,652,654,960,962,974,998,1150 'one':15,56,60,571,669,1004 'one-shot':14,55 'open':209 'oper':1120 'orient':726 'origin':523 'otherwis':104 'output':206,603,626,1194 'outsid':128,947 'overload':346,350 'packag':681 'pair':866 'paramet':761 'part':929 'pass':606 'path':136,273,276,284,287,648,820,825,886,888,902,905,907,920 'perform':583 'pick':1052 'prebuilt':94,148 'prefer':92,570 'prepar':81,634 'present':912,1225 'preview':28,72,338,442,508,554,564,569,575,710,712,1197 'produc':787,1089 'project':117,135,154,164,222,248,258,515,599,612 'properti':607,758 'propos':1069 'public':80 're':1094 're-check':1093 'readabl':1243 'real':789,900 'reason':1244 'rebuild':191 'recommend':1193 'recreat':387 'redirect':201,609 'refactor':2,6,37,250 'refactoring-csharp':1 'refer':32 'renam':4,25,48,76,99,120,140,157,254,345,354,365,372,375,416,425,430,451,585,670,744,767,775,777,828,844,860,981,1005,1033,1123,1138,1156 'rename-symbol':98,119,139,156,415 'repeat':182,253 'report':304,521,849 'repositori':231 'request':67,426,1159 'requir':269,675 'rerun':567 'reserv':557 'resolv':62,645,1146 'respons':721 'restor':679 'result':519 'retri':1113,1126 'return':69,708,715,816,1166,1232 'reus':184 'rg':306,399 'roslyn':17,45,589,748,1024,1088 'roslyn-bas':44 'roslyn/msbuild':218 'rule':541 'run':105,116,153,183,331,468,476,489,492,588,684,704,1162 'runtim':1110 'safe':379,790 'say':711,718,1198,1210 'scope':1183 'scratch':195 'second':243 'see':857 'session':631 'set':342 'ship':42 'shot':16,57 'silent':484 'singl':798 'single-declar':797 'skill':41,87,112,130,174 'skill-refactoring-csharp' 'sln':279,894 'slnx':281,895 'solut':11,36,198,211,214,272,293,503,549,593,885,887,901,924,933,940 'sourc':108,674,752,1044,1051,1055 'source-back':751,1054 'source-codealive-ai' 'src':51 'src/csharprefactoring.cli':118 'state':558,635,1117 'stateless':59,545 'static':770 'stay':361 'stem':805 'step':82 'still':830 'string':356,359 'style':1195 'success':1135 'summar':517 'support':383,497,738,743,1038 'symbol':8,27,39,100,121,141,158,404,417,749,794,827,982,1006,1022,1027,1039,1041,1046 'target':64,197,221,445,592,598,611,662,739,745,1015,1057,1097,1134,1144 'tell':727 'temporari':204 'text':531,1091,1170 'time':264,1124 'timeout':1121,1130 'tool':163,496,500,543,587,644,687,707,813,848,871,1165,1231 'topic-agent-safety' 'topic-agent-skills' 'topic-ai-coding' 'topic-ai-driven-development' 'topic-ai-safety' 'topic-antigravity' 'topic-bash' 'topic-claude-code' 'topic-codex-cli' 'topic-cursor' 'topic-developer-tools' 'topic-gemini-cli' 'total':530,1169 'track':859 'treat':740,1107 'tree':245 'true':103,124,144,161,344,369,378,434,465,779 'trust':1190 'type':385,801,809 'typeparamet':763 'unchang':351,1119 'unless':618,696,846 'unsupport':1021 'untouch':362 'unusu':453 'updat':31 'use':19,132,179,219,301,395,398,432,596,869,1017 'user':22,438,579,620,698,729,1153,1188 'valid':65,327,831,1066,1071 'valu':303,478 'whether':733,1214 'whitespac':967 'without':419 'workflow':1139 'workspac':561,1104 'would':458,1200 'yes':274,285,296,310,323","prices":[{"id":"1d9c0241-aac3-42a2-837a-dc024ca3bd7e","listingId":"fac7cf27-4f42-4997-8116-61e1aa38d97c","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"CodeAlive-AI","category":"ai-driven-development","install_from":"skills.sh"},"createdAt":"2026-05-11T18:57:19.442Z"}],"sources":[{"listingId":"fac7cf27-4f42-4997-8116-61e1aa38d97c","source":"github","sourceId":"CodeAlive-AI/ai-driven-development/refactoring-csharp","sourceUrl":"https://github.com/CodeAlive-AI/ai-driven-development/tree/main/skills/refactoring-csharp","isPrimary":false,"firstSeenAt":"2026-05-11T18:57:19.442Z","lastSeenAt":"2026-05-18T18:57:07.344Z"}],"details":{"listingId":"fac7cf27-4f42-4997-8116-61e1aa38d97c","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"CodeAlive-AI","slug":"refactoring-csharp","github":{"repo":"CodeAlive-AI/ai-driven-development","stars":67,"topics":["agent-safety","agent-skills","ai-coding","ai-driven-development","ai-safety","antigravity","bash","claude-code","codex-cli","cursor","developer-tools","gemini-cli","hooks","mcp","multi-agent","opencode","plugins","prompt-engineering","skills","subagents"],"license":"mit","html_url":"https://github.com/CodeAlive-AI/ai-driven-development","pushed_at":"2026-05-12T20:04:46Z","description":"Practices, protocols, and skills for AI-driven software development. 18 skills + 1 Bash safety hook for Claude Code, Codex CLI, OpenCode, Cursor, Gemini CLI, Antigravity, and any agent supporting the Agent Skills standard.","skill_md_sha":"2cfedb729949e087d1c0150d98680a35c996c735","skill_md_path":"skills/refactoring-csharp/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/CodeAlive-AI/ai-driven-development/tree/main/skills/refactoring-csharp"},"layout":"multi","source":"github","category":"ai-driven-development","frontmatter":{"name":"refactoring-csharp","description":"Rename and refactor C# symbols in a solution with a one-shot Roslyn CLI. Use when the user asks to rename a symbol, preview impact, or update references across a .NET solution."},"skills_sh_url":"https://skills.sh/CodeAlive-AI/ai-driven-development/refactoring-csharp"},"updatedAt":"2026-05-18T18:57:07.344Z"}}