본문으로 건너뛰기
Skillpedia
일반 코딩6.5k · #14188

codebase-refactoring

하는 일

프로젝트 전체를 위한 단계별 정리 계획입니다. 반복되는 코드, 사용되지 않는 코드, 지나치게 복잡한 파일을 다룹니다. 유지보수 작업을 줄이려는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓팀이 프로젝트를 정리하거나 기술 부채를 줄이자고 요청할 때.
  • ✓개발자가 코드베이스의 어느 부분을 가장 먼저 손봐야 할지 알고 싶을 때.
  • ✓팀이 정리 전후의 프로젝트 건강 점수를 측정하려 할 때.

스킬 링크

https://github.com/kucherenko/jscpd/blob/master/skills/codebase-refactoring/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/kucherenko/jscpd/blob/master/skills/codebase-refactoring/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 프로젝트를 정리해 주세요. 가장 큰 문제부터 시작하고, 끝나면 건강 점수를 보여 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

스킬은 코드 분석 도구로 문제의 우선순위를 매기고, AI가 중복, 사용되지 않는 코드, 복잡한 파일을 고치도록 안내합니다. 마지막에는 점수를 다시 측정합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

codebase-refactoring

A guided pass over a codebase's three biggest maintenance costs — duplicated code, dead code, and complexity — using jscpd to find each and a strategy to fix it. Use this skill when asked to "clean up", "improve", "refactor" or "pay down tech debt in" a codebase, rather than to fix one specific bug.

Start here: measure, then prioritize

npx jscpd --health --reporters ai <path>
health 74 B (duplication 75, dead-code 72, complexity 76; 93 code lines)

The health score is a weighted mix of three sub-scores, each a share of the code lines — high is good, 100 is clean. The lowest of the three names where the codebase actually hurts most; if it isn't the order below, do that dimension first instead. n/a on a dimension (e.g. dead code n/a) means jscpd could not measure it — dead-code detection needs JavaScript, TypeScript or Python to be a real share of the code — skip that step rather than treating it as clean.

For the full picture behind that score — largest duplicated formats, most complex files, largest dead-code findings, all in one screen — run npx jscpd --dashboard instead. Its console output (the default) is the only reporter with that per-file detail; --reporters ai on --dashboard prints the same one-line summary shown above, not the breakdown, so don't reach for it expecting more than the score. Use --reporters json on --dashboard if you need the detail in a parseable form.

The three passes below are otherwise independent and safe to run in any order; duplication → dead code → complexity is the default because fixing duplication first means step 2 isn't wasting effort tracing call sites that a later extract-function pass will move anyway, and clearing dead code before step 3 means the files ranked for simplification are ones actually worth simplifying, not ones about to be deleted.

Step 1 — Duplicated code

npx jscpd --reporters ai --summary <path>

Find and read each clone, decide whether it is a real copy worth merging, and apply the matching refactoring strategy (extract function, parameterize, extract a shared module or constant, or a base class/template for structural duplication). Full guided workflow, triage rules for renamed/near-miss clones, and worked examples per clone kind:

→ dry-refactoring — run this now, then come back here for steps 2 and 3. Its own --summary hotspot ranking is the same one the health score's duplication dimension reads from, so a file it flags as a duplication hotspot is the same file that dragged the score down.

Step 2 — Dead code

npx jscpd --dead-code --reporters ai <path>
basta dead code report — 18 findings across 30 files (22.1% of 272 lines)
Confidence is 0-100; anything below 90 has a listed reason it may be wrong. Verify a finding before deleting the code.
unused-file typescript/src/legacy-export.ts:1:1 confidence=95 typescript/src/legacy-export.ts is never imported and is not an entry point
unused-export typescript/src/invoice.ts:21:17 confidence=85 exported function `renderReceipt` is never imported
unused-symbol typescript/src/invoice.ts:29:10 confidence=90 function `describeTotal` is never used in typescript/src/invoice.ts
unused-import typescript/src/invoice.ts:2:10 confidence=100 `roundToCents` is imported but never used

This is a graph traversal from the project's entry points (package.json main/bin/exports/scripts, pyproject.toml scripts, framework conventions, or --entry <glob>), not a reference count — a helper whose only caller is itself dead is reported too, so deleting one finding can make another true that wasn't reported yet. Covers JavaScript, TypeScript, JSX, TSX, Vue, Svelte, Astro and Python.

The four categories, and what to do with each

Category Meaning Usual fix
unused-file Never imported anywhere, not an entry point Delete the file
unused-export Exported, but no other file imports it Delete it, or drop the export keyword if something in the same file still uses it
unused-symbol A module-private declaration nothing in its own file references Delete it
unused-import Imported but never referenced in the file Delete the import line

Workflow

  1. Run with --reporters ai (add --dead-code-categories to focus on one category, --include-tests if test-only usage shouldn't count as "used", `--i
자주 묻는 질문

무엇을 먼저 고칠지 어떻게 정하나요?

중복, 사용되지 않는 코드, 복잡성을 아우르는 건강 점수를 사용하며, 점수가 가장 낮은 항목부터 시작합니다.

모든 언어에서 작동하나요?

사용되지 않는 코드 탐지는 코드의 상당 부분이 JavaScript, TypeScript 또는 Python이어야 합니다.

버그를 고치나요?

특정 버그가 아니라 유지보수 문제를 대상으로 합니다.

상세 정보

작성자의 원본 설명

Three-part workflow to improve overall codebase health with jscpd — find and fix duplicated code, find and remove or refactor dead code, then find and simplify the largest/most complex files. Starts from --dashboard/--health to prioritize and ends by re-measuring the score.

repo: kucherenko/jscpd

인기도

GitHub 스타
6.5k
순위
#14188
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬