Quick Summary
- What: Dead Code Séance is a CLI tool that theatrically identifies unused functions and methods in your codebase, treating the process like a supernatural investigation.
The Problem: Your Codebase is a Digital Graveyard
Every codebase over six months old is less of a project and more of an archaeological dig site. You have layers. The 'MVP' layer, written in a caffeine-fueled sprint. The 'We Got Funding' layer, where someone decided we needed microservices. And the bottom layer—the crypt—where functions named utils_v2_final_REALLYFINAL.js lie in wait.
The problem isn't that the code is old. The problem is you have no idea if it's dead old or undead old. Is that 400-line monster in the /legacy folder truly unused, or is it secretly invoked via a dynamic import in a dependency you forgot you had? Manually tracing this is like trying to find a specific ghost in a haunted mansion using a candle. You waste hours grepping, checking import maps, and running test coverage, only to give up and leave the creepy function there, just in case. It's the software equivalent of keeping your weird uncle's urn on the mantel because you're not sure where else to put it.
And the consequences? Bloated bundle sizes. Slower CI times as your linter sighs over thousands of lines of irrelevant code. The constant, low-grade anxiety that one day you'll delete something and a critical, once-a-year payroll batch job will fail, and you'll have to explain to the CFO that you 'disturbed the ancient spirits of the codebase.'
The Solution: A Séance for the Static Analysis Age
I got tired of the guesswork and the fear. So, I built Dead Code Séance to solve this. Instead of a dry, soul-crushing static analysis report, it frames the hunt for dead code as what it truly is: a supernatural investigation into your project's past.
Under the hood, it's using serious AST (Abstract Syntax Tree) parsing to map every function declaration, method, and import in your project. It cross-references calls and builds a dependency graph. The magic (or, you know, the computer science) is in accurately determining what's truly orphaned. But on the surface, it's a full-blown paranormal experience. Why? Because deleting code should be fun, not terrifying.
The tool is genuinely useful—it gives you a high-confidence list of candidates for deletion and can even generate the removal script. The theatrical presentation just makes the medicine go down easier. It turns a chore into a ceremony.
How to Use It: Conducting Your First Code Séance
Getting started is easier than explaining to your manager why you need a sage smudge stick for your laptop. It's a Node.js CLI tool.
Installation:
npm install -g dead-code-seance
# or
npx dead-code-seance@latest initiate
Basic Usage: Navigate to your project's root and invoke the spirits:
cd /path/to/your/tech-debt
seance scan --drama-level high
This kicks off the scan. You'll see a dramatic ASCII 'spirit detection' animation as it parses your files. When it's done, it doesn't just spit out a list. It presents an Ouija-board-style interface in your terminal, showing 'messages from beyond'—these are the potentially dead code entities and any faint, possible connections (like dynamic imports or reflection) that might be keeping them anchored to this realm.
Here's a tiny snippet from the core scanning logic that shows the playful yet functional approach:
// From the main scanner - the 'Ectoplasmic Tracker'
function detectEctoplasmicTraces(astNode, projectGraph) {
const name = astNode.id?.name || 'Anonymous Apparition';
// Serious analysis happens here
const isOrphaned = !projectGraph.hasConnections(name);
// Theatrical reporting
if (isOrphaned) {
console.log(`👻 Entity "${name}" detected. Strength: FADING.`);
return { name, status: 'likely-dead' };
}
return null;
}
Check out the full source code on GitHub to see the complete spooky symphony.
Key Features: More Than Just a Parlor Trick
- Dramatic 'Spirit Detection' Animations: No boring progress bars. Watch as swirling ASCII art 'scans' your codebase. It makes the wait for the AST parse feel like a main event.
- Ouija-Board-Style Output: The final report isn't a JSON blob. It's an interactive terminal session that presents 'messages' (unused functions) and 'echoes' (potential, obscure dependencies). It visually highlights high-confidence deletions vs. 'maybe haunted' code.
- Ritualistic 'Banishing Ceremony' Script: Once you've confirmed the dead code, don't just delete it. Run
seance banish --confirm. It generates a shell script (e.g.,banish_ghosts.sh) that contains all thegit rmcommands, wrapped in ceremonial comments. You can review it before running, making the deletion intentional and safe. It's version control with gravitas.
Conclusion: Give Your Codebase a Proper Burial
Dead Code Séance won't just clean up your repository; it will change your relationship with legacy code. It replaces anxiety with a sense of ritual and closure. You're not just deleting old code—you're laying digital spirits to rest, making room for new, living features to flourish.
The benefits are real: a cleaner, more maintainable codebase, faster build times, and the profound satisfaction of finally deleting handleButtonClickVariantA() knowing it won't come back to haunt you.
Try it out: https://github.com/BoopyCode/dead-code-séance
Go on. Open your terminal. It's time to stop being afraid of the dark corners in your src/ folder. After all, the only thing scarier than a ghost in the machine is 500KB of unused JavaScript following your users home.
💬 Discussion
Add a Comment