Most code should be deleted
Codebases get worse the longer they live unless someone is actively pruning.
Be that someone.
The natural state of code is accumulation. Every feature added is code added. Every fix is code added. Every refactor is, often, more code added.
The codebase grows. The complexity grows. The maintenance burden grows. The number of places a new bug can hide grows. The new engineer's onboarding time grows.
Almost nobody removes code. Removing code is unpaid, unrecognized, and risky. It feels like reducing the surface area of the company. It is. That's the point.
The good codebases I've worked in had someone whose ongoing job was to delete things. Not their official job. Their actual ongoing concern. They kept noticing what wasn't being used and quietly removing it.
Three things to delete:
Features that nobody uses. Check the analytics. The features with zero usage in the last quarter are taxing your codebase for no benefit. Cut them.
Code paths that exist for cases that don't happen. The defensive programming for the edge case that never occurs. The backwards compatibility for the version you no longer support. Cut them.
Dead branches. Unused functions. Imports that aren't referenced. The small junk that compounds.
The deleted code can't have bugs. It can't be exploited. It can't confuse the next engineer. It can't slow down the build.
Code is a liability. Working code is a slightly smaller liability. Deleted code is no liability.
Most teams have codebases that are at least 15 percent larger than they need to be.
Find the 15 percent. Cut it.