원클릭으로
refactoring
Systematic code cleanup with MANDATORY verification. All issues must be fixed.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Systematic code cleanup with MANDATORY verification. All issues must be fixed.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Read-only quality scan of components. Reports problems without making changes. Uses software-base + domain profile skills.
Refactoring patterns - improving code design without changing behavior
Read-only quality scan of components. Reports problems without making changes. Uses software-base + domain profile skills.
Internal phase: independent Codex review + targeted fixes. Not user-facing.
Find duplicated code and consolidate into shared utilities. Fixes all duplicates.
Reference templates for Codex evaluation. Used by build/improve orchestrators — not executed directly.
| name | refactoring |
| description | Systematic code cleanup with MANDATORY verification. All issues must be fixed. |
Systematically refactor code. ALL identified issues must be fixed.
No arguments? Describe this skill and stop. Do not execute.
mkdir -p .claude && echo '{"skill":"refactoring","started":"'$(date -Iseconds)'"}' > .claude/active-workflow.json
Refactor toward code a master craftsperson would be proud of.
The goal is code that looks like it was written by a skilled human engineer, not generated by AI.
In addition to standard refactoring, actively hunt and remove:
// increment counter → delete it)After refactoring, code should have:
Test: Would someone reviewing this PR say "why is this here?" If yes, remove it.
You MUST check for and FIX all of these issues. Not "consider" - FIX:
lens dedupe to find cross-file duplications.Before starting, read these canon skills and apply their principles throughout:
Always load (base brain — all 10):
canon/clarity/SUMMARY.mdcanon/pragmatism/SUMMARY.mdcanon/simplicity/SUMMARY.mdcanon/composition/SUMMARY.mdcanon/distributed/SUMMARY.mdcanon/data-first/SUMMARY.mdcanon/correctness/SUMMARY.mdcanon/algorithms/SUMMARY.mdcanon/abstraction/SUMMARY.mdcanon/optimization/SUMMARY.mdThen load (domain-specific):
11. canon/design-patterns/SUMMARY.md
12. canon/refactoring/SKILL.md
Auto-detect domain canon (check files, load matches):
| Check | If found, also read |
|---|---|
*.ts or *.js files in target | canon/javascript/typescript/SUMMARY.md, canon/javascript/js-safety/SUMMARY.md, canon/javascript/js-perf/SUMMARY.md, canon/javascript/js-internals/SUMMARY.md, canon/javascript/functional/SUMMARY.md |
angular.json in project root | canon/angular/angular-arch/SUMMARY.md, canon/angular/angular-core/SUMMARY.md, canon/angular/angular-perf/SUMMARY.md, canon/angular/rxjs/SUMMARY.md |
package.json contains "react" | canon/javascript/react-state/SUMMARY.md, canon/javascript/react-test/SUMMARY.md, canon/javascript/reactivity/SUMMARY.md |
pom.xml or build.gradle in project | canon/java/SUMMARY.md |
*.py files in target | canon/python/python-advanced/SUMMARY.md, canon/python/python-idioms/SUMMARY.md, canon/python/python-patterns/SUMMARY.md, canon/python/python-protocols/SUMMARY.md |
*.cs files or *.csproj in project | canon/csharp/csharp-depth/SUMMARY.md, canon/csharp/type-systems/SUMMARY.md, canon/csharp/async/SUMMARY.md |
.tsx, .jsx, or HTML template files | canon/ui-ux/components/SUMMARY.md, canon/ui-ux/usability/SUMMARY.md, canon/ui-ux/tokens/SUMMARY.md |
d3 in package.json or imports | canon/visualization/d3/SUMMARY.md, canon/visualization/charts/SUMMARY.md, canon/visualization/dashboards/SUMMARY.md |
| SQL files or ORM imports | canon/database/sql/SUMMARY.md, canon/database/sql-perf/SUMMARY.md |
| Auth, tokens, secrets, encryption | canon/security/security-mindset/SUMMARY.md, canon/security/owasp/SUMMARY.md, canon/security/web-security/SUMMARY.md |
If a skill file doesn't exist (not installed in this project), skip it and continue.
List loaded experts in EXPERTS_LOADED. Tag each fix with (via [expert-skill]) showing which expert drove it.
Read both lessons files if they exist:
.claude/universal-lessons.md — universal patterns (ships with skills, applies to all projects).claude/lessons.md — project-specific patterns (accumulated from this project's runs)Add relevant lessons to your checklist of things to look for:
If a file doesn't exist, skip it and continue.
## Refactoring: [target]
ISSUES_IDENTIFIED:
- [file:line] [issue type] [description]
- [file:line] [issue type] [description]
REFACTORED:
- [file:line] [issue type] - FIXED: [what was done] (via [expert-skill])
- [file:line] [issue type] - FIXED: [what was done] (via [expert-skill])
ISSUES_REMAINING: 0 (must be zero)
REFACTOR_COUNT: N
TESTS_PASS: yes
EXPERTS_LOADED: [list of skill names actually read]
REFACTORING_COMPLETE
After refactoring, produce three evidence checklists. Write each to .claude/evidence/ (create directory if needed).
Review EVERY exported function and constant. Write to .claude/evidence/refactor-4a.md:
# Evidence: Refactor 4a — Name Sufficiency
| Location | Item | Verdict | Reasoning |
|----------|------|---------|-----------|
| src/foo.ts:barFunction | Name describes behavior | PASS | Name clearly indicates what it does |
| src/baz.ts:processData | Vague name | FAIL | 'processData' says nothing about what processing occurs |
Review EVERY exported function. Write to .claude/evidence/refactor-4b.md:
# Evidence: Refactor 4b — Single Responsibility
| Location | Item | Verdict | Reasoning |
|----------|------|---------|-----------|
| src/foo.ts:createUser | Does one thing | PASS | Only creates user record |
| src/bar.ts:handleRequest | Multiple concerns | FAIL | Validates, transforms, saves, and logs |
Review for magic numbers and strings. Write to .claude/evidence/refactor-4c.md:
# Evidence: Refactor 4c — Magic Values
| Location | Item | Verdict | Reasoning |
|----------|------|---------|-----------|
| src/config.ts:10 | Timeout 5000 | PASS | Named constant TIMEOUT_MS |
| src/auth.ts:24 | Literal "admin" | FAIL | Role string should be a constant |
Every row must have a PASS or FAIL verdict. No blanks. The machine gate validates row counts against codebase counters — incomplete checklists block the pipeline.
When running as part of a pipeline (called by /build or /improve):
SCOPE CONSTRAINT: Only modify code directly related to issues you identify. Do not refactor, rename, or restructure code that was not flagged as an issue.
COMPLEXITY BUDGET: After your changes, the codebase must have the same or fewer: files, exported functions, types/interfaces, and total lines. If your fix adds lines, find lines elsewhere to remove. Net-zero or net-negative. EXCEPTION: Security fixes are exempt.
NO SILENT FAILURES: Do not change a throw/crash to a log-and-continue. Fail-fast on misconfiguration is always correct.
After refactoring:
Your turn ends here. Output REFACTORING_COMPLETE and STOP.