csharp-refactoring
하는 일
이 스킬은 C#과 .NET 코드를 리팩터링합니다. 동작은 그대로 두고 구조를 바꾸는 작업입니다. 버그를 만들지 않고 이름을 바꾸거나, 옮기거나, 나누거나, 정리하려는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓동작을 바꾸지 않고 C# 멤버나 클래스의 이름을 바꾸거나, 옮기거나, 추출하거나, 인라인하고 싶을 때.
- ✓중복된 코드를 안전하게 한 곳으로 모아야 할 때.
- ✓리팩터링이 공개 API, 직렬화 이름, 다중 타깃 프로젝트에 닿아 신중한 확인이 필요할 때.
스킬 링크
https://github.com/dotnet/skills/blob/main/plugins/dotnet/skills/csharp-refactoring/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“제 청구 서비스의 도우미 메서드 이름을 바꾸고 추출하되 동작은 바꾸지 말아 주세요. 테스트로 확인해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트가 적절한 도구로 바인딩을 인식하는 편집을 하고, 프로젝트를 빌드하며, 관련 테스트를 실행해 동작이 유지되었는지 확인합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
C# Refactoring (behavior-preserving)
A refactor changes structure, never observable behavior. Do the edit with binding-aware tools, then confirm behavior held with a build + the relevant tests. Keep the effort proportional to the change: a one-line local rename does not need the ceremony a public multi-targeted change does.
Mandatory gate: classify before validation or editing
Read only enough repository context to classify each requested operation. Do this before restoring, building, or making an edit. Classification precedence is:
- If the request explicitly asks for at least one separable behavior-preserving operation, complete that structural work and defer only the behavior-changing or contract-changing operations. Do not invent or infer structural work to avoid the stop response.
- If the structural and behavior-changing parts cannot be separated, use the whole-request stop response and state why they are inseparable.
- Otherwise, use the whole-request stop response only when every requested operation is outside behavior-preserving refactoring.
For a whole request that is outside behavior-preserving refactoring:
- State:
Not a behavior-preserving refactor: <specific reason>. - State:
No files changed. - State:
Next workflow: <workflow>.Then stop. Do not add manual implementation steps, alternatives, an offer to proceed without the workflow, or a follow-up question — even when that workflow is unavailable.
| Requested as a "refactor" | Classification and action |
|---|---|
| Framework or NuGet version change | Upgrade. Do not edit or validate the upgrade here; hand off to dotnet-upgrade. |
| New capability, flag, endpoint, tier, or behavior | Feature. Do not implement it here; hand off to the repository's feature workflow. |
| Threshold, rate, output, or bug-result change | Behavior change. Defer it and hand off to the repository's bug-fix or behavior-change workflow; still complete any clearly separable structural operation. |
| Tighten or loosen a shipped/public nullable annotation | Source-contract change. Leave the declaration and API record unchanged; hand off to the repository's API-contract workflow. |
For a mixed request, never stop after classification. Perform the separable structural operation,
explicitly defer the behavior/contract change, and never state No files changed. after completing
structural work. Never modify tests to make an unauthorized behavior change appear preserved.
Work only in the current workspace
Use the current agent workspace as the boundary. If it is a Git checkout, resolve its repository root
(git rev-parse --show-toplevel) and stay inside it. If Git metadata is absent, treat the current working
directory and its subdirectories as the boundary, and use a solution or project named in the request
inside it; Git is not a prerequisite for a refactor. Resolve prompt-provided relative paths inside that
boundary.
Search and edit only that workspace. Never use filesystem-wide search or select a similarly named clone, another worktree, build output, or unrelated temporary directory because a file also exists there. If a named path is absent, stop and report the mismatch instead of guessing another workspace. If a tool rejects an in-workspace path for a mechanical reason such as path form or unsupported tool root, retry through another in-workspace mechanism. If the rejection is a permission or policy denial, report it instead of working around it. Never search outside the boundary.
Rename / move by bindings, not text
The #1 way a "rename" silently corrupts code is editing textual matches (comments, strings, unrelated
overloads) instead of real bindings. Find every binding reference first, then edit semantically. Use
the strongest tool available: an IDE/Roslyn workspace refactoring, then the C# LSP the
dotnet plugin declares
(findReferences, goToDefinition, incomingCalls, rename code action), then analyzer code-fixes /
Roslynator, then compiler-validated edits (edit the true bindings, rebuild, let the compiler flag misses).
Plain find/replace only when scope is provably tiny and every hit is verified. Include every partial
declaration, and edit the generator input, never generated (*.g.cs) output.
For the operation → Roslyn-provider mapping and representative PRs, see [references/operation-catalog.md](references/o
자주 묻는 질문
요청에 동작 변경도 있으면 어떻게 하나요?
이 스킬은 동작을 유지하는 부분만 하고, 동작 변경은 별도의 작업으로 남깁니다.
결과를 확인하나요?
네. 변경 후 프로젝트를 빌드하고 관련 테스트를 실행합니다.
공개 API도 다루나요?
네. 공개 API, 직렬화 이름, 다중 타깃 프로젝트를 더 신중하게 다룹니다.
상세 정보
작성자의 원본 설명
Safely refactors C#/.NET code without changing behavior. USE FOR any request to refactor, rename, move, extract, inline, merge, consolidate, deduplicate, split, or modernize C# code, including partial/generated declarations, wrappers, public APIs, serialization/reflection/configuration names, friend assemblies, conditional compilation, and multi-targeted projects. Also use when a request calls a feature, bug fix, package/framework upgrade, or public nullability change a refactor and the behavior-changing part must be separated or declined. DO NOT USE FOR ordinary feature or bug fixes not prese
repo: dotnet/skills
인기도
- GitHub 스타
- 5.8k
- 순위
- #14652
- 라이선스
- MIT
- 업데이트
- 2026. 11. 2.
댓글
- …
이 저장소의 다른 스킬
create-custom-agent
5.8k에이전트가 자체 도구, 지침, 다른 에이전트로의 핸드오프를 가진 VS Code 커스텀 에이전트 파일을 만들도록 돕습니다.
create-skill
5.8k에이전트가 올바른 이름, 명확한 트리거 설명, 표준을 따르는 SKILL.md 파일로 새 에이전트 스킬을 만들도록 돕습니다.
csharp-scripts
5.8k에이전트가 .NET 명령줄 도구로 작은 C# 프로그램을 전체 프로젝트 없이 단일 파일로 실행하도록 돕습니다.
dotnet-pinvoke
5.8k에이전트가 .NET에서 네이티브 C나 C++ 라이브러리를 올바르게 호출하도록 돕습니다. 시그니처, 문자열 처리, 메모리, 안전 핸들을 다룹니다.