Prompt Details
Model
Chat - (gpt-5.6)
Token size
2,580
Example input
[CODEBASE_STRUCTURE]: ecommerce-platform/ βββ apps/ β βββ api/ β βββ worker/ β βββ admin/ βββ packages/ β βββ auth/ β βββ payments/ β βββ notifications/ β βββ legacy-payment/ β βββ utils/ βββ scripts/ βββ tests/ βββ config/
[SOURCE_CODE_OR_REPOSITORY_DATA]: packages/utils/formatLegacyDate() has no direct references. - packages/utils/formatCurrency() is used by payments and admin. - packages/legacy-payment/StripeV1Adapter is referenced only by an old migration script. - packages/notifications/EmailNotifier is used by worker. - packages/payments/PaymentService has a dynamic provider loader: loadProvider(process.env.PAYMENT_PROVIDER)
[DEPENDENCY_MANIFESTS_AND_LOCKFILES]: Production: - express - stripe - nodemailer - lodash Dev: - jest - eslint Possible issue: - moment appears in package.json but no obvious source import exists.
[TESTS_AND_COVERAGE_DATA]: Payments: 92% coverage - Notifications: 86% - Utils: 71% - Legacy payment: 15% - No tests specifically cover dynamic payment-provider loading.
[KNOWN_CONSTRAINTS_AND_CRITICAL_COMPONENTS]: Payment processing is business-critical. - Do not remove payment providers without rollback capability. - Migration scripts must remain available until migration completion is confirmed. - Zero production payment downtime allowed.
Example output
π Phase 1 β Codebase Inventory
Component Type Production Criticality
API Application π΄ Critical
Worker Background service π High
Payments Library/module π΄ Critical
Notifications Library/module π High
Utils Shared library π‘ Medium
Legacy Payment Compatibility module π‘ Medium
Admin Application π‘ Medium
Finding: Payment functionality is the highest-risk cleanup area.
---
π Phase 2 β Entry-Point Analysis
Identified roots:
API startup
β
PaymentService
β
Dynamic Provider Loader
β
Stripe Provider
And:
Worker
β
Notification Job
β
EmailNotifier
Important: StripeV1Adapter cannot be considered dead simply because it has few references because migration scripts can execute it.
---
π§© Phase 3 β Dead-Code Findings
Candidate 1: formatLegacyDate()
Evidence:
No direct source references.
No runtime usage in 90-day telemetry.
Not used by known entry points.
No configuration reference discovered.
Utility has no known registration mechanism.
Classification: π’ Likely unused
Confidence: 95%
Risk: π’ Low
Recommendation: REMOVE
Required validation
1. Repository-wide search
2. TypeScript/compiler validation
3. Utils test suite
4. API/admin build
5. Application smoke test
---
π¦ Phase 4 β Dependency Audit
moment
Evidence:
Present in dependency manifest.
No obvious application imports.
No production runtime usage found.
Need to check build scripts, configuration and transitive assumptions.
Classification: π‘ Possibly unused
Confidence: 80%
Recommendation: VALIDATE FIRST
Do not immediately remove it.
Required checks:
npm/yarn/pnpm dependency analysis
Build plugin inspection
Configuration search
Test/build execution
Lockfile regeneration
Application startup test
---
π§© Phase 5 β Hidden Dependency Analysis
Payment Provider
The code contains:
loadProvider(process.env.PAYMENT_PROVIDER)
Therefore static references may not reveal the complete dependency graph.
Configuration currently contains:
PAYMENT_PROVIDER=stripe
but an old staging configuration contains:
PAYMENT_PROVIDER=paypal
Finding:
PayPal appears unused in production, but its runtime capability cannot yet be classified as removable.
Classification: π‘ Validate First
Risk: π΄ Critical
Reason:
Configuration-driven dynamic loading can bypass static dependency analysis.
---
π°οΈ Phase 6 β Legacy Component Analysis
StripeV1Adapter
Evidence:
Only referenced by migration tooling.
No production calls in 90 days.
Migration scripts are not part of normal deployment.
Migration completion status is not explicitly provided.
Classification: π‘ Potentially obsolete
Confidence: 75%
Recommendation: DEFER / VALIDATE
Do not remove yet.
Required evidence:
- Confirm migration completion
- Confirm no remaining data requires migration
- Execute migration test in isolated environment
- Verify rollback procedure
- Search CI/CD for migration execution
---
π Phase 7 β Redundant Implementation Analysis
Suppose the audit discovers:
packages/utils/formatCurrency()
packages/payments/formatPaymentAmount()
Both appear to perform currency formatting.
Comparison:
Factor formatCurrency formatPaymentAmount
Consumers 8 1
Tests High Low
Production use High High
Behavior Generic Payment-specific
Risk Low Medium
Recommendation:
KEEP formatCurrency()
MIGRATE formatPaymentAmount()
Then remove the second implementation only after regression tests pass.
---
β οΈ Phase 8 β Blast-Radius Assessment
Candidate Risk Action
formatLegacyDate() π’ Low Remove
moment π‘ Medium Validate
StripeV1Adapter π High Validate migration
PayPal provider π΄ Critical Preserve until proven unnecessary
PaymentService π΄ Critical Do not remove
EmailNotifier π High Preserve
---
π§ͺ Phase 9 β Verification Tests
Before Removal
- Repository-wide reference scan
- Dependency graph analysis
- Build validation
- Relevant unit tests
- Configuration search
- Runtime telemetry review
During Removal
For formatLegacyDate():
1. Delete function.
2. Run utility tests.
3. Run API build.
4. Run admin build.
5. Run integration tests.
After Removal
- Deploy to staging
- Execute application smoke tests
- Verify API health
- Verify worker startup
- Monitor errors
- Compare runtime behavior
---
πͺ Phase 10 β Safe Removal Order
Step 1 β Remove formatLegacyDate()
Reason:
Isolated
No known consumers
No runtime usage
Low blast radius
Step 2 β Validate moment
Determine whether it is genuinely unused.
If validation confirms no usage:
Remove moment
β
Regenerate lockfile
β
Build
β
Run tests
β
Deploy staging
Step 3 β Consolidate duplicate utilities
Migrate consumers first.
formatPaymentAmount()
β
formatCurrency()
β
remove old implementation
Step 4 β Validate StripeV1Adapter
Only remove after migration completion is proven.
Step 5 β Reassess PayPal
Require evidence that:
Production = no usage
Staging = no required usage
Config = obsolete
Migration = complete
Rollback = unnecessary
Only then consider removing it.
---
π Final Cleanup Priority Matrix
Candidate Dead-Code Confidence Risk Priority Recommendation
formatLegacyDate() 95% Low π₯ Remove First REMOVE
moment 80% Medium π Validate First VALIDATE
Duplicate formatter 90% Medium π High MIGRATE + REMOVE
StripeV1Adapter 75% High π Defer VALIDATE
PayPal provider 60% Critical π Do Not Remove PRESERVE
PaymentService 0% Critical π Do Not Remove PRESERVE
EmailNotifier 0% High π Do Not Remove PRESERVE
---
π£οΈ Cleanup Roadmap
Phase A β Low-Risk Cleanup
Target: formatLegacyDate()
Action: Remove
Verification: Unit + build + smoke tests
Risk: π’ Low
Rollback: Git revert
---
Phase B β Dependency Cleanup
Target: moment
Prerequisite: Confirm no dynamic/build/config usage
Action: Remove dependency and regenerate lockfile
Risk: π‘ Medium
Rollback: Restore manifest + lockfile
---
Phase C β Redundancy Reduction
Target: Duplicate currency formatter
Prerequisite: Consumer migration
Action: Migrate β test β remove duplicate
Risk: π‘ Medium
---
Phase D β Legacy Removal
Target: StripeV1Adapter
Prerequisite: Migration completion evidence
Action: Remove migration-only adapter
Risk: π High
Rollback: Restore adapter from version control
---
Phase E β Architectural Cleanup
Target: Dynamic provider architecture
Action: Simplify provider registration only after proving which providers are genuinely required.
Risk: π΄ Critical
Recommendation: Perform last.
---
π Expected Benefits
These are estimates based only on the sample data, not measured results:
Lines of code: Small reduction initially
Dependencies: Potentially 1 fewer production dependency
Maintenance: Reduced legacy utility and duplicate implementation burden
Build complexity: Potentially lower after dependency cleanup
Upgrade benefits: Fewer obsolete packages to maintain
Operational benefits: Simpler code paths and fewer legacy components
Final Audit Verdict
The safest strategy is not to aggressively delete everything that looks unused.
The recommended sequence is:
formatLegacyDate
β
moment validation
β
duplicate formatter migration
β
StripeV1Adapter migration validation
β
PayPal/provider reassessment
β
high-risk architectural cleanup
Key lesson from this test: static reference absence is evidence of possible dead code, not proof of dead code. Dynamic loading, migration scripts, configuration, plugins, and runtime behavior must be checked before removal.
By purchasing this prompt, you agree to our terms of service
GPT-5.6
Large codebases accumulate unused functions, unreachable code, obsolete dependencies, and redundant modules that increase maintenance cost and hidden breakage risk.
π Find dead & unreachable code
π¦ Detect obsolete and unused dependencies
π§© Identify redundant modules
β οΈ Discover hidden dependency risks
π‘οΈ Assess potential cleanup breakage
π§ͺ Design verification tests
π£οΈ Generate a safe removal roadmap
Turn messy legacy code into a safer, prioritized cleanup plan. π
...more
Added 1 week ago
