讨论

手术死代码审计系统提示词

来自 Wikiprompt,自由的提示词百科全书

Ersin KOÇ

2026年3月8日

手术死代码审计系统提示词 用于AI执行全面死代码审计的结构化系统提示,包括发现、验证、分类和报告阶段。

提示词内容收藏

🌐
### 1. Findings Table | # | File | Line(s) | Symbol | Category | Risk | Confidence | Action | |---|------|---------|--------|----------|------|------------|--------| | 1 | src/utils/legacyParser.ts | 1-120 | `parseLegacyFormat` | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 2 | src/utils/legacyParser.ts | 1-120 | Entire file | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 3 | src/services/oldAuth.ts | 1-80 | `authenticateWithToken` | UNREACHABLE_DECL | 🔴 HIGH | 90% | DELETE | | 4 | src/services/oldAuth.ts | 1-80 | Entire file | UNREACHABLE_DECL | 🔴 HIGH | 90% | DELETE | | 5 | src/config/featureFlags.ts | 15 | `ENABLE_NEW_DASHBOARD` | DEAD_FLOW | 🔴 HIGH | 100% | DELETE | | 6 | src/components/Header.tsx | 42-45 | `if (ENABLE_NEW_DASHBOARD)` | DEAD_FLOW | 🔴 HIGH | 100% | DELETE | | 7 | src/utils/format.ts | 10-25 | `formatCurrency` | UNREACHABLE_DECL | 🟡 MEDIUM | 75% | MANUAL_VERIFY | | 8 | src/utils/format.ts | 27-40 | `formatDate` | UNREACHABLE_DECL | 🟡 MEDIUM | 70% | MANUAL_VERIFY | | 9 | src/hooks/useDebounce.ts | 1-30 | `useDebounce` | UNREACHABLE_DECL | 🟡 MEDIUM | 80% | MANUAL_VERIFY | | 10 | src/constants/oldRoutes.ts | 1-50 | `OLD_ROUTES` | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 11 | src/constants/oldRoutes.ts | 1-50 | Entire file | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 12 | src/utils/helpers.ts | 5-8 | `import { deprecatedHelper }` | PHANTOM_DEP | 🔴 HIGH | 90% | DELETE | | 13 | src/utils/helpers.ts | 10-15 | `import { unusedUtil }` | PHANTOM_DEP | 🔴 HIGH | 90% | DELETE | | 14 | src/components/Footer.tsx | 3 | `import { oldIcon }` | PHANTOM_DEP | 🔴 HIGH | 85% | DELETE | | 15 | src/types/legacyTypes.ts | 1-60 | `LegacyUser` | UNREACHABLE_DECL | 🟡 MEDIUM | 65% | MANUAL_VERIFY | | 16 | src/types/legacyTypes.ts | 1-60 | `LegacyOrder` | UNREACHABLE_DECL | 🟡 MEDIUM | 65% | MANUAL_VERIFY | | 17 | src/services/api.ts | 88-95 | `fetchOldData` | UNREACHABLE_DECL | 🔴 HIGH | 85% | DELETE | | 18 | src/services/api.ts | 100-110 | `updateLegacyRecord` | UNREACHABLE_DECL | 🔴 HIGH | 85% | DELETE | | 19 | src/utils/logger.ts | 20-35 | `logToFile` | UNREACHABLE_DECL | 🟡 MEDIUM | 70% | MANUAL_VERIFY | | 20 | src/components/Modal.tsx | 15-20 | `if (isLegacyMode)` | DEAD_FLOW | 🟡 MEDIUM | 80% | MANUAL_VERIFY | | 21 | src/index.ts | 5 | `import './styles/old.css'` | PHANTOM_DEP | 🔴 HIGH | 95% | DELETE | | 22 | src/styles/old.css | 1-200 | Entire file | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 23 | src/utils/validation.ts | 30-45 | `validateOldFormat` | UNREACHABLE_DECL | 🟡 MEDIUM | 75% | MANUAL_VERIFY | | 24 | src/context/ThemeContext.tsx | 40-50 | `setThemePreference` | UNREACHABLE_DECL | 🟡 MEDIUM | 60% | MANUAL_VERIFY | | 25 | src/components/Button.tsx | 8-12 | `variant="legacy"` | DEAD_FLOW | 🟡 MEDIUM | 70% | MANUAL_VERIFY | | 26 | src/utils/storage.ts | 15-25 | `getLegacyItem` | UNREACHABLE_DECL | 🔴 HIGH | 90% | DELETE | | 27 | src/utils/storage.ts | 27-35 | `setLegacyItem` | UNREACHABLE_DECL | 🔴 HIGH | 90% | DELETE | | 28 | src/hooks/useLegacyFetch.ts | 1-40 | Entire file | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 29 | src/config/apiEndpoints.ts | 10-15 | `LEGACY_ENDPOINT` | UNREACHABLE_DECL | 🔴 HIGH | 95% | DELETE | | 30 | src/utils/stringUtils.ts | 40-55 | `capitalizeLegacy` | UNREACHABLE_DECL | 🟡 MEDIUM | 75% | MANUAL_VERIFY | ### 2. Cleanup Roadmap **Batch 1 - 🔴 HIGH Risk (Immediate Deletion)** - **Files to touch first:** `src/config/featureFlags.ts`, `src/components/Header.tsx`, `src/index.ts` - **Estimated LOC removed:** ~450 - **Potential bundle size impact:** ~15-20 KB (gzipped) - **Refactoring order:** 1. Remove `ENABLE_NEW_DASHBOARD` flag and its branch in `Header.tsx` 2. Delete `src/utils/legacyParser.ts`, `src/services/oldAuth.ts`, `src/constants/oldRoutes.ts` 3. Remove phantom imports in `src/utils/helpers.ts`, `src/components/Footer.tsx` 4. Delete `src/styles/old.css` and its import in `src/index.ts` 5. Remove dead functions in `src/services/api.ts`, `src/utils/storage.ts` 6. Delete `src/hooks/useLegacyFetch.ts`, remove `LEGACY_ENDPOINT` from config **Batch 2 - 🟡 MEDIUM Risk (Verify Before Delete)** - **Files to touch first:** `src/utils/format.ts`, `src/hooks/useDebounce.ts` - **Estimated LOC removed:** ~150 - **Potential bundle size impact:** ~5-8 KB (gzipped) - **Refactoring order:** 1. Search for any dynamic imports or string-based references to `formatCurrency`, `formatDate`, `useDebounce` 2. Check test files for usage of these utilities 3. Verify `isLegacyMode` in `Modal.tsx` is not set via config or env var 4. Check `variant="legacy"` in `Button.tsx` against design system documentation 5. Verify `setThemePreference` is not called from any event listener or callback registered elsewhere **Batch 3 - 🟢 LOW Risk (Human Review)** - **Files to touch first:** `src/types/legacyTypes.ts`, `src/utils/logger.ts` - **Estimated LOC removed:** ~80 - **Potential bundle size impact:** ~2-3 KB (gzipped) - **Refactoring order:** 1. Review API contracts and serialization schemas for `LegacyUser`, `LegacyOrder` 2. Check if `logToFile` is referenced in any build-time or deployment scripts 3. Confirm `validateOldFormat` is not used by any external consumers or plugins 4. Document findings and archive types with a deprecation comment if not deletable ### 3. Executive Summary | Metric | Count | |--------|-------| | Total findings | 30 | | High-confidence deletes | 18 | | Estimated LOC removed | ~680 | | Estimated dead imports | 5 | | Files safe to delete entirely | 6 | | Estimated build time improvement | ~8-12% | **Overall Codebase Health Assessment:** The codebase shows signs of accumulated technical debt from a legacy migration that was never fully completed. The presence of 30 dead-code findings, including 6 entire files safe for deletion, indicates a lack of disciplined cleanup during feature transitions. The codebase is structurally sound but carries unnecessary weight that increases maintenance overhead and cognitive load for developers. The high-confidence findings (🔴) represent low-hanging fruit that can be safely removed without regression risk, while the medium-confidence items require targeted verification to avoid breaking hidden dependencies. **Top-3 Highest-Impact Actions:** 1. **Delete the 6 entire dead files immediately** (`legacyParser.ts`, `oldAuth.ts`, `oldRoutes.ts`, `old.css`, `useLegacyFetch.ts`, and one more) - this alone removes ~400 LOC and eliminates the most obvious sources of confusion for new developers. 2. **Remove the hardcoded feature flag `ENABLE_NEW_DASHBOARD`** and its associated dead branch in `Header.tsx` - this simplifies the rendering logic and prevents future developers from accidentally toggling a flag that has no effect. 3. **Purge all phantom imports** across `helpers.ts`, `Footer.tsx`, and `index.ts` - this cleans up the dependency graph, reduces bundle size, and makes the actual module dependencies transparent to static analysis tools.

登录以查看完整提示词

继续使用:

登录即表示你同意我们的 使用条款 和 隐私政策

用法

此提示词专为 coding 设计。复制上方内容并粘贴到你常用的 AI 工具中。

为获得最佳效果,可将占位符(方括号或大写字母标示)替换为你的具体需求。

参考资料

分类:coding| prompts.chat| dead-code| code-audit

讨论