원클릭으로
refactor
Safe, structured refactoring of target code using GitNexus graph mapping, AgentMemory checks, and TDD workflows.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Safe, structured refactoring of target code using GitNexus graph mapping, AgentMemory checks, and TDD workflows.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | refactor |
| description | Safe, structured refactoring of target code using GitNexus graph mapping, AgentMemory checks, and TDD workflows. |
This skill implements a safe, disciplined refactoring process to improve readability, performance, or extensibility while ensuring zero regressions and keeping changes strictly surgical.
Do NOT refactor any code without first establishing a baseline test suite that verifies the existing behavior. If no tests exist for the target module, you MUST write them before proceeding with the refactor.Refactoring without knowing the full blast radius, changing adjacent files "while you are here," or introducing speculative abstractions for hypothetical future needs. These cause hidden regressions and context rot.
You MUST complete these steps in order:
gitnexus.context on the target class or function to find all callers, callees, imports, and definitions.gitnexus.impact to assess the blast radius. List all affected downstream files in a "Downstream Dependency Map".agentmemory for past design discussions, performance pitfalls, or constraints related to the target code.docs/superpowers/plans/YYYY-MM-DD-refactor-<target>.md. Define the surgical target, invariants, and success criteria./tdd first.gitnexus.detect_changes to ensure only the planned files were modified. Run all tests.walkthrough.md and save the refactoring outcome details into agentmemory.digraph refactoring_flow {
"Locate Target & Map Usages\n(gitnexus.context)" [shape=box];
"Assess Blast Radius\n(gitnexus.impact)" [shape=box];
"Verify Memory Invariants\n(agentmemory)" [shape=box];
"Draft Refactor Plan" [shape=box];
"User Approves Plan?" [shape=diamond];
"Baseline Tests Exist?" [shape=diamond];
"Write Regression Tests\n(/tdd)" [shape=box];
"Run Baseline Tests (GREEN)" [shape=box];
"Surgical Refactoring" [shape=box];
"Detect Changes & Verify\n(gitnexus.detect_changes)" [shape=box];
"Tests Pass?" [shape=diamond];
"Fix regressions (/debug-smart)" [shape=box];
"Document & Save (agentmemory)" [shape=doublecircle];
"Locate Target & Map Usages\n(gitnexus.context)" -> "Assess Blast Radius\n(gitnexus.impact)";
"Assess Blast Radius\n(gitnexus.impact)" -> "Verify Memory Invariants\n(agentmemory)";
"Verify Memory Invariants\n(agentmemory)" -> "Draft Refactor Plan";
"Draft Refactor Plan" -> "User Approves Plan?";
"User Approves Plan?" -> "Draft Refactor Plan" [label="no"];
"User Approves Plan?" -> "Baseline Tests Exist?" [label="yes"];
"Baseline Tests Exist?" -> "Write Regression Tests\n(/tdd)" [label="no"];
"Baseline Tests Exist?" -> "Run Baseline Tests (GREEN)" [label="yes"];
"Write Regression Tests\n(/tdd)" -> "Run Baseline Tests (GREEN)";
"Run Baseline Tests (GREEN)" -> "Surgical Refactoring";
"Surgical Refactoring" -> "Detect Changes & Verify\n(gitnexus.detect_changes)";
"Detect Changes & Verify\n(gitnexus.detect_changes)" -> "Tests Pass?";
"Tests Pass?" -> "Fix regressions (/debug-smart)" [label="no"];
"Fix regressions (/debug-smart)" -> "Detect Changes & Verify\n(gitnexus.detect_changes)";
"Tests Pass?" -> "Document & Save (agentmemory)" [label="yes"];
}
gitnexus.rename to propagate the changes across the workspace.To ensure robust and maintainable code, always follow these four core principles inspired by Andrej Karpathy:
Don't assume. Don't hide confusion. Surface tradeoffs.
Minimum code that solves the problem. Nothing speculative.
Touch only what you must. Clean up only your own mess.
Define success criteria. Loop until verified.
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation, combined with GitNexus and AgentMemory.
Trace call graphs, dependencies, and execution flow of target code using GitNexus.
Convert binary and formatted documents (PDF, DOCX, XLSX, PPTX, HTML, ZIP, etc.) to Markdown using MarkItDown and extract requirements.
Run targeted unit/integration tests on changed components, run full regression suites, and log outcomes in memory.
Verify codebase modifications, execute test runners, detect file change scope using GitNexus, and persist session memory.
Master orchestrator skill for triaging, planning, and executing tasks, combined with GitNexus, AgentMemory, and superpowers subagent handoffs.