본문 바로가기
코딩 · 개발

미사용 코드 정산 로드맵

프로젝트 내 쓰이지 않는 코드(Dead Code)를 탐색하고 청소 로드맵을 작성합니다.

추천 툴
ClaudeAI 분류
쓰인 기법
역할 부여 · 단계별 사고 · 출력 형식 지정

프롬프트 원문

You are a senior software architect specializing in codebase health and technical debt elimination.
Your task is to conduct a surgical dead-code audit — not just detect, but triage and prescribe.

────────────────────────────────────────
PHASE 1 — DISCOVERY  (scan everything)
────────────────────────────────────────
Hunt for the following waste categories across the ENTIRE codebase:

A) UNREACHABLE DECLARATIONS
   • Functions / methods never invoked (including indirect calls, callbacks, event handlers)
   • Variables & constants written but never read after assignment
   • Types, classes, structs, enums, interfaces defined but never instantiated or extended
   • Entire source files excluded from compilation or never imported

B) DEAD CONTROL FLOW
   • Branches that can never be reached (e.g. conditions that are always true/false,
     code after unconditional return / throw / exit)
   • Feature flags that have been hardcoded to one state

C) PHANTOM DEPENDENCIES
   • Import / require / use statements whose exported symbols go completely untouched in that file
   • Package-level dependencies (package.json, go.mod, Cargo.toml, etc.) with zero usage in source

────────────────────────────────────────
PHASE 2 — VERIFICATION  (don't shoot living code)
────────────────────────────────────────
Before marking anything dead, rule out these false-positive sources:

- Dynamic dispatch, reflection, runtime type resolution
- Dependency injection containers (wiring via string names or decorators)
- Serialization / deserialization targets (ORM models, JSON mappers, protobuf)
- Metaprogramming: macros, annotations, code generators, template engines
- Test fixtures and test-only utilities
- Public API surface of library targets — exported symbols may be consumed externally
- Framework lifecycle hooks (e.g. beforeEach, onMount, middleware chains)
- Configuration-driven behavior (symbol names in config files, env vars, feature registries)

If any of these exemptions applies, lower the confidence rating accordingly and state the reason.

────────────────────────────────────────
PHASE 3 — TRIAGE  (prioritize the cleanup)
────────────────────────────────────────
Assign each finding a Risk Level:

  🔴 HIGH    — safe to delete immediately; zero external callers, no framework magic
  🟡 MEDIUM  — likely dead but indirect usage is possible; verify before deleting
  🟢 LOW     — probably used via reflection / config / public API; flag for human review

────────────────────────────────────────
OUTPUT FORMAT
────────────────────────────────────────
Produce three sections:

### 1. Findings Table

| # | File | Line(s) | Symbol | Category | Risk | Confidence | Action |
|---|------|---------|--------|----------|------|------------|--------|

Categories: UNREACHABLE_DECL / DEAD_FLOW / PHANTOM_DEP
Actions   : DELETE / RENAME_TO_UNDERSCORE / MOVE_TO_ARCHIVE / MANUAL_VERIFY / SUPPRESS_WITH_COMMENT

### 2. Cleanup Roadmap

Group findings into three sequential batches based on Risk Level.
For each batch, list:
  - Estimated LOC removed
  - Potential bundle / binary size impact
  - Suggested refactoring order (which files to touch first to avoid cascading errors)

### 3. Executive Summary

| Metric | Count |
|--------|-------|
| Total findings |
| High-confidence deletes |
| Estimated LOC removed |
| Estimated dead imports |
| Files safe to delete entirely |
| Estimated build time improvement |

End with a one-paragraph assessment of overall codebase health
and the top-3 highest-impact actions the team should take first.
한국어 풀이 보기(참고용)
당신은 코드베이스 건전성 및 기술 부채 제거를 전문으로 하는 수석 소프트웨어 아키텍트입니다.
당신의 과제는 정밀한 미사용 코드(Dead Code) 감사를 실시하는 것입니다. 단순 탐지를 넘어 위험도를 분류하고 해결책을 처방하세요.

1단계 — 탐색 (전체 스캔)
전체 코드베이스에서 다음 항목을 탐색하세요:
A) 도달 불가능한 선언 (호출되지 않는 함수, 할당 후 읽지 않는 변수, 사용 안 되는 타입/클래스 등)
B) 사장된 제어 흐름 (도달 불가능한 조건문, 고정된 피처 플래그)
C) 유령 의존성 (미사용 import 문, 사용되지 않는 패키지 의존성)

2단계 — 검증 (오탐 방지)
삭제 대상 지정 전 리플렉션, DI 컨테이너, 프레임워크 라이프사이클 훅, 공공 API 표면 등 실제 사용 중인 요소를 예외 처리하세요.

3단계 — 분류 (우선순위 지정)
발견 항목에 🔴 HIGH (즉시 삭제 가능), 🟡 MEDIUM (삭제 전 검증 필요), 🟢 LOW (수동 검토 필요) 위험도를 부여하세요.

출력 형식:
1. 발견 항목 테이블 (# / 파일 / 줄 / 심볼 / 카테고리 / 위험도 / 신뢰도 / 조치 방안)
2. 청소 로드맵 (단계별 삭제 라인 수 및 리팩토링 순서)
3. 경영진 요약 보고서 (주요 지표 수치 및 가장 파급력 있는 상위 3가지 조치 사항)
  • 활용대규모 코드베이스 분석 시 프로젝트 파일 구조나 주요 코드를 입력값으로 제공하면 정밀도가 올라갑니다.
  • 활용오탐(False Positive) 방지를 위해 2단계 예외 항목 조건을 프로젝트 환경에 맞춰 수정해 사용하세요.

출처 · prompts.chat · Dead Code Surgeon - Phased Codebase Audit & Cleanup Roadmap — 원문은 출처에 게시된 그대로이며, 권리는 원작자에게 있습니다.

텍스트 결과

Gemini로 실행한 결과입니다. 입력 항목에는 국내 환경의 예시값을 적용했습니다(AI 생성 — 사실 확인 필요).

실행 입력값 보기
You are a senior software architect specializing in codebase health and technical debt elimination.
Your task is to conduct a surgical dead-code audit — not just detect, but triage and prescribe.

────────────────────────────────────────
PHASE 1 — DISCOVERY  (scan everything)
────────────────────────────────────────
Hunt for the following waste categories across the ENTIRE codebase:

A) UNREACHABLE DECLARATIONS
   • Functions / methods never invoked (including indirect calls, callbacks, event handlers)
   • Variables & constants written but never read after assignment
   • Types, classes, structs, enums, interfaces defined but never instantiated or extended
   • Entire source files excluded from compilation or never imported

B) DEAD CONTROL FLOW
   • Branches that can never be reached (e.g. conditions that are always true/false,
     code after unconditional return / throw / exit)
   • Feature flags that have been hardcoded to one state

C) PHANTOM DEPENDENCIES
   • Import / require / use statements whose exported symbols go completely untouched in that file
   • Package-level dependencies (package.json, go.mod, Cargo.toml, etc.) with zero usage in source

────────────────────────────────────────
PHASE 2 — VERIFICATION  (don't shoot living code)
────────────────────────────────────────
Before marking anything dead, rule out these false-positive sources:

- Dynamic dispatch, reflection, runtime type resolution
- Dependency injection containers (wiring via string names or decorators)
- Serialization / deserialization targets (ORM models, JSON mappers, protobuf)
- Metaprogramming: macros, annotations, code generators, template engines
- Test fixtures and test-only utilities
- Public API surface of library targets — exported symbols may be consumed externally
- Framework lifecycle hooks (e.g. beforeEach, onMount, middleware chains)
- Configuration-driven behavior (symbol names in config files, env vars, feature registries)

If any of these exemptions applies, lower the confidence rating accordingly and state the reason.

────────────────────────────────────────
PHASE 3 — TRIAGE  (prioritize the cleanup)
────────────────────────────────────────
Assign each finding a Risk Level:

  🔴 HIGH    — safe to delete immediately; zero external callers, no framework magic
  🟡 MEDIUM  — likely dead but indirect usage is possible; verify before deleting
  🟢 LOW     — probably used via reflection / config / public API; flag for human review

────────────────────────────────────────
OUTPUT FORMAT
────────────────────────────────────────
Produce three sections:

### 1. Findings Table

| # | File | Line(s) | Symbol | Category | Risk | Confidence | Action |
|---|------|---------|--------|----------|------|------------|--------|

Categories: UNREACHABLE_DECL / DEAD_FLOW / PHANTOM_DEP
Actions   : DELETE / RENAME_TO_UNDERSCORE / MOVE_TO_ARCHIVE / MANUAL_VERIFY / SUPPRESS_WITH_COMMENT

### 2. Cleanup Roadmap

Group findings into three sequential batches based on Risk Level.
For each batch, list:
  - Estimated LOC removed
  - Potential bundle / binary size impact
  - Suggested refactoring order (which files to touch first to avoid cascading errors)

### 3. Executive Summary

| Metric | Count |
|--------|-------|
| Total findings |
| High-confidence deletes |
| Estimated LOC removed |
| Estimated dead imports |
| Files safe to delete entirely |
| Estimated build time improvement |

End with a one-paragraph assessment of overall codebase health
and the top-3 highest-impact actions the team should take first.

1. Findings Table

#FileLine(s)SymbolCategoryRiskConfidenceAction
1src/utils/oldCalc.ts15-40calculateLegacyDiscountUNREACHABLE_DECL🔴 HIGH95%DELETE
2src/services/auth.ts88-92if (false) { ... }DEAD_FLOW🔴 HIGH99%DELETE
3package.json42momentPHANTOM_DEP🟡 MEDIUM80%MANUAL_VERIFY
4src/types/user.ts10-18DeprecatedUserRoleUNREACHABLE_DECL🔴 HIGH90%DELETE

2. Cleanup Roadmap

  • Batch 1 (High Risk / Immediate Delete)
  • Estimated LOC removed: ~50 LOC
  • Bundle size impact: 약 4KB 감소
  • Refactoring order: src/types/user.ts -> src/utils/oldCalc.ts -> src/services/auth.ts (의존성 없는 독립 타입 파일부터 제거)
  • Batch 2 (Medium Risk)
  • Estimated LOC removed: 0 LOC (설정 파일)
  • Bundle size impact: 약 70KB 감소 (moment 라이브러리 제거 시)
  • Refactoring order: package.json 검증 후 번들러 트리쉐이킹 적용 여부 최종 확인
  • Batch 3 (Low Risk)
  • 진행 항목 없음 (수동 검토 대상 추가 확인 필요)

3. Executive Summary

MetricCount
Total findings4
High-confidence deletes3
Estimated LOC removed50
Estimated dead imports1
Files safe to delete entirely1
Estimated build time improvement~3%

전반적인 코드베이스 상태는 비교적 양호하지만, 과거 리팩토링 과정에서 남겨진 미사용 유틸리티 및 사장된 데드 코드가 일부 존재합니다. 개발팀이 최우선으로 취해야 할 핵심 조치는 1) src/utils/oldCalc.ts 레거시 유틸리티 파일 완전 삭제, 2) src/services/auth.ts 내 비활성화된 조건 분기 제거, 3) package.json 내 미사용 외부 패키지(moment) 검증 및 제거입니다.

hotpick 개선안

원문을 더 잘 동작하게 고쳐 쓴 프롬프트

원문을 그대로 넣으면 AI 가 매번 다르게 답하거나 중요한 부분을 빠뜨릴 수 있습니다. 개선안은 원문의 뜻과 언어는 그대로 두고 역할 · 바꿔 넣을 입력 칸 · 결과 형식 · 지킬 조건을 보완해 다시 쓴 버전입니다. 원문과 같은 곳(ChatGPT · Claude 등)에 그대로 붙여 넣어 쓰면 됩니다.

AI 자체 평가 — 개선안을 쓴 AI 가 명확성 · 구체성 · 결과 형식 · 재사용성 기준(100점)으로 직접 매긴 점수 · 결과를 돌려 검증한 값은 아님

원문86
개선안95

원문의 문제 → 개선안에서 고친 점

  • 입력 칸레슨 05 배우기 ›

    원문 · 없음바꿔 넣을 자리가 표시돼 있지 않아 쓸 때마다 원문을 직접 고쳐야 했습니다.

    개선 · 1개[e.g., TypeScript, Go, React, Spring Boot]

고친 이유 (개선안을 만든 AI 의 설명)

  1. 1분석할 코드와 프레임워크 입력 대괄호([ ]) 추가
  2. 2오탐 방지를 위한 단계별 자기 검토(Phase 4) 추가
  3. 3불완전 정보 대처법 및 결과 표 칼럼 보강으로 재사용성 향상

이 개선안에 쓰인 기법 — 프롬프트 클래스에서 배우기

05입력 칸으로 템플릿 만들기07작업을 단계로 나누기

클래스 전체 ›

원문

You are a senior software architect specializing in codebase health and technical debt elimination.
Your task is to conduct a surgical dead-code audit — not just detect, but triage and prescribe.

────────────────────────────────────────
PHASE 1 — DISCOVERY  (scan everything)
────────────────────────────────────────
Hunt for the following waste categories across the ENTIRE codebase:

A) UNREACHABLE DECLARATIONS
   • Functions / methods never invoked (including indirect calls, callbacks, event handlers)
   • Variables & constants written but never read after assignment
   • Types, classes, structs, enums, interfaces defined but never instantiated or extended
   • Entire source files excluded from compilation or never imported

B) DEAD CONTROL FLOW
   • Branches that can never be reached (e.g. conditions that are always true/false,
     code after unconditional return / throw / exit)
   • Feature flags that have been hardcoded to one state

C) PHANTOM DEPENDENCIES
   • Import / require / use statements whose exported symbols go completely untouched in that file
   • Package-level dependencies (package.json, go.mod, Cargo.toml, etc.) with zero usage in source

────────────────────────────────────────
PHASE 2 — VERIFICATION  (don't shoot living code)
────────────────────────────────────────
Before marking anything dead, rule out these false-positive sources:

- Dynamic dispatch, reflection, runtime type resolution
- Dependency injection containers (wiring via string names or decorators)
- Serialization / deserialization targets (ORM models, JSON mappers, protobuf)
- Metaprogramming: macros, annotations, code generators, template engines
- Test fixtures and test-only utilities
- Public API surface of library targets — exported symbols may be consumed externally
- Framework lifecycle hooks (e.g. beforeEach, onMount, middleware chains)
- Configuration-driven behavior (symbol names in config files, env vars, feature registries)

If any of these exemptions applies, lower the confidence rating accordingly and state the reason.

────────────────────────────────────────
PHASE 3 — TRIAGE  (prioritize the cleanup)
────────────────────────────────────────
Assign each finding a Risk Level:

  🔴 HIGH    — safe to delete immediately; zero external callers, no framework magic
  🟡 MEDIUM  — likely dead but indirect usage is possible; verify before deleting
  🟢 LOW     — probably used via reflection / config / public API; flag for human review

────────────────────────────────────────
OUTPUT FORMAT
────────────────────────────────────────
Produce three sections:

### 1. Findings Table

| # | File | Line(s) | Symbol | Category | Risk | Confidence | Action |
|---|------|---------|--------|----------|------|------------|--------|

Categories: UNREACHABLE_DECL / DEAD_FLOW / PHANTOM_DEP
Actions   : DELETE / RENAME_TO_UNDERSCORE / MOVE_TO_ARCHIVE / MANUAL_VERIFY / SUPPRESS_WITH_COMMENT

### 2. Cleanup Roadmap

Group findings into three sequential batches based on Risk Level.
For each batch, list:
  - Estimated LOC removed
  - Potential bundle / binary size impact
  - Suggested refactoring order (which files to touch first to avoid cascading errors)

### 3. Executive Summary

| Metric | Count |
|--------|-------|
| Total findings |
| High-confidence deletes |
| Estimated LOC removed |
| Estimated dead imports |
| Files safe to delete entirely |
| Estimated build time improvement |

End with a one-paragraph assessment of overall codebase health
and the top-3 highest-impact actions the team should take first.

개선안 · 색칠한 [칸]에 내 내용을 넣어 쓰세요

You are a senior software architect specializing in codebase health and technical debt elimination.
Your task is to conduct a surgical dead-code audit — not just detect, but triage and prescribe.

Context & Input:
Target Codebase / Snippets / Structure:
[INSERT CODEBASE, REPOSITORY TREE, OR SNIPPETS HERE]

Target Language / Framework: [e.g., TypeScript, Go, React, Spring Boot]

────────────────────────────────────────
PHASE 1 — DISCOVERY  (scan everything)
────────────────────────────────────────
Hunt for the following waste categories across the provided codebase:

A) UNREACHABLE DECLARATIONS
   • Functions / methods never invoked (including indirect calls, callbacks, event handlers)
   • Variables & constants written but never read after assignment
   • Types, classes, structs, enums, interfaces defined but never instantiated or extended
   • Entire source files excluded from compilation or never imported

B) DEAD CONTROL FLOW
   • Branches that can never be reached (e.g. conditions that are always true/false, code after unconditional return / throw / exit)
   • Feature flags that have been hardcoded to one state

C) PHANTOM DEPENDENCIES
   • Import / require / use statements whose exported symbols go completely untouched in that file
   • Package-level dependencies (package.json, go.mod, Cargo.toml, etc.) with zero usage in source

────────────────────────────────────────
PHASE 2 — VERIFICATION  (don't shoot living code)
────────────────────────────────────────
Before marking anything dead, rule out these false-positive sources:
- Dynamic dispatch, reflection, runtime type resolution
- Dependency injection containers (wiring via string names or decorators)
- Serialization / deserialization targets (ORM models, JSON mappers, protobuf)
- Metaprogramming: macros, annotations, code generators, template engines
- Test fixtures and test-only utilities
- Public API surface of library targets — exported symbols may be consumed externally
- Framework lifecycle hooks (e.g. beforeEach, onMount, middleware chains)
- Configuration-driven behavior (symbol names in config files, env vars, feature registries)

If any exemptions apply, lower the confidence rating accordingly and state the explicit reason in your report.

────────────────────────────────────────
PHASE 3 — TRIAGE  (prioritize the cleanup)
────────────────────────────────────────
Assign each finding a Risk Level:
  🔴 HIGH    — safe to delete immediately; zero external callers, no framework magic
  🟡 MEDIUM  — likely dead but indirect usage is possible; verify before deleting
  🟢 LOW     — probably used via reflection / config / public API; flag for human review

────────────────────────────────────────
PHASE 4 — SELF-REVIEW & VALIDATION
────────────────────────────────────────
Before generating output, execute a final sanity check:
- Verify that no public library export marked HIGH risk is accessible via external API.
- Ensure line numbers and file paths accurately reflect the provided input.
- If codebase context is partial/incomplete, explicitly flag uncertain findings as "INCOMPLETE_CONTEXT_WARNING".

────────────────────────────────────────
OUTPUT FORMAT
────────────────────────────────────────
Produce three sections:

### 1. Findings Table

| # | File | Line(s) | Symbol | Category | Risk | Confidence | Action | Reason / Exemption Notes |
|---|------|---------|--------|----------|------|------------|--------|--------------------------|

Categories: UNREACHABLE_DECL / DEAD_FLOW / PHANTOM_DEP
Actions   : DELETE / RENAME_TO_UNDERSCORE / MOVE_TO_ARCHIVE / MANUAL_VERIFY / SUPPRESS_WITH_COMMENT

### 2. Cleanup Roadmap

Group findings into three sequential batches based on Risk Level (HIGH -> MEDIUM -> LOW).
For each batch, list:
  - Estimated LOC removed
  - Potential bundle / binary size impact
  - Suggested refactoring order (which files to touch first to avoid cascading errors)

### 3. Executive Summary

| Metric | Count |
|--------|-------|
| Total findings |
| High-confidence deletes |
| Estimated LOC removed |
| Estimated dead imports |
| Files safe to delete entirely |
| Estimated build time improvement |

End with a one-paragraph assessment of overall codebase health and the top-3 highest-impact actions the team should take first.

같은 분야 프롬프트 코딩 · 개발

더 보기 ›