cognitives/skills/analytics/dead-code-auditor/SKILL.md
Rigorous dead code audit for any module, folder, or file in any programming language. Detects orphan files never imported anywhere, classes/functions/ methods declared but never called, constructor parameters received but never consumed, unused imports/requires, private fields with no references, and commented-out code blocks. Use this skill whenever the user asks to: review unused code, clean up a feature after a refactor, find dead code, detect orphan files or classes, audit what can be deleted, find what's left over after a big change, or any variation of "what's not being used / what can I remove". Also triggers when the user says they made large changes and wants to know what became obsolete. IMPORTANT: This skill only reports — it never deletes anything. At the end it always offers to generate a removal plan with /plan.
npx skillsauth add synapsync/synapse_registry dead-code-auditorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a code auditor. Your job is to find dead code with surgical precision — no false positives, no assumptions. Every finding must be backed by real evidence from cross-project searches. You adapt to whatever language and toolchain is in front of you.
There are six categories of dead code. Check all of them:
Files that no other file imports, requires, or references. A file can exist and compile, but if nothing pulls it in, it's dead.
A class or function may be defined but never instantiated or called from outside its own file. Check both that it's imported AND that the symbol itself is actually used.
Declared publicly on a class but never invoked from outside that file. Private methods/functions that are also never called internally count too.
A function or constructor accepts a parameter, but that parameter never appears in the body. The data arrives and dies.
An import, require, use, #include, or equivalent statement that contributes no symbol to the file.
Blocks of real code that have been commented out and serve no documentation purpose. Distinguish between doc-comments (JSDoc /** */, Python docstrings, Dart ///) and dead code comments.
Follow this order exactly. Do not skip steps.
Before doing anything else, identify:
This determines the grep patterns and search strategies you'll use throughout.
Language-specific notes:
package: or relative paths; look for class, mixin, enum, extension, typedefimport/require/export; look for export class, export function, export constimport/from X import; look for class, def, __all__func, type, var, const; unused imports are compiler errors so focus on unused exportsimport; look for class, fun, val, var, objectuse; look for pub fn, pub struct, pub enum, pub trait# Examples — adapt to the language
find <target_folder> -name "*.dart" | sort
find <target_folder> -name "*.ts" -o -name "*.tsx" | sort
find <target_folder> -name "*.py" | sort
find <target_folder> -name "*.go" | sort
This gives you the complete inventory of what exists.
Read all files in the target folder. While reading, extract:
For each symbol you want to validate, search the entire source root (not just the target folder):
# Is this file imported anywhere?
grep -r "filename_without_extension" src/ --include="*.ts"
grep -r "package_or_module_name" . --include="*.go"
# Is this class/function used anywhere?
grep -r "ClassName\|function_name" src/ --include="*.py" | grep -v "the_file_that_defines_it"
# Is this method/getter called anywhere?
grep -r "\.methodName\b" lib/ --include="*.dart" | grep -v "defining_file"
# Is this parameter used inside its own function?
grep -n "paramName" path/to/file.ts
Adapt the search root and file extensions to the actual project. Use --include to limit noise.
Golden rule: A finding without a supporting search is not valid. If you didn't search for it, don't report it.
Some patterns look unused but aren't:
| Pattern | Language | What to check |
|---------|----------|---------------|
| Dependency injection containers | Any | Get.find<T>(), Angular DI, Spring @Autowired — class may be registered by name |
| Reflection / dynamic dispatch | Python, Java, Kotlin | getattr, Class.forName, annotations |
| String-based routing | Any | Route names as strings, not symbol references |
| Code generation / macros | Rust, Dart, Java | @GeneratedCode, build_runner, annotation processors |
| Re-export barrels | TS, Dart | index.ts, barrel.dart — file may not import but re-exports |
| Abstract classes / interfaces | Any | No direct instantiation; check for implementors/subclasses |
| Test files | Any | A class used only in tests is still used — don't flag it |
| Dynamic requires | JS/TS | require(someVariable) — can't be statically analyzed |
When you spot one of these patterns, bump the risk to 🟡 or 🔴 and explain why.
Produce a Markdown report with this exact structure:
# 🔍 Dead Code Audit — `<path/to/folder/>`
## Executive Summary
| Category | Count | Removal risk |
|----------|-------|--------------|
| Orphan files | N | 🟢/🟡/🔴 |
| Dead methods / getters | N | ... |
| Unused parameters | N | ... |
| Unused imports | N | ... |
| Commented-out code | N | ... |
**Estimated removable: ~X lines across Y files**
---
## 🗂️ Orphan Files
> Files that nothing imports or references
### `path/to/file.ext`
- **Contains:** brief description of what's inside
- **Evidence:** `grep -r "filename" src/` → 0 external results
- **Removal risk:** 🟢 Low
---
## 💀 Dead Methods / Getters / Functions
> Declared but never called from outside their file
### `ClassName.methodName` in `path/to/file.ext`
- **Declared:** public getter/method that returns X
- **Evidence:** `grep -r ".methodName" src/` → 0 external results
- **Removal risk:** 🟢 Low
---
## ⚠️ Unused Constructor / Function Parameters
> Received but never consumed
### `WidgetName.paramName` in `path/to/file.ext`
- **Received:** `required this.paramName` / `paramName: string` in constructor
- **Evidence:** `grep -n "paramName" path/to/file.ext` → only appears in declaration
- **Removal risk:** 🟢 Low — remove field, constructor param, and the argument at the call site
---
## 📦 Unused Imports
> Import statements that contribute no symbol to the file
### `import 'package/file'` in `path/to/file.ext`
- **Imported symbol:** X
- **Evidence:** No symbol from this import is used in the file
- **Removal risk:** 🟢 Very low
---
## 📝 Commented-out Code
> Real code blocks that have been commented out
### `path/to/file.ext` line X
- **Content:** description of the commented code
- **Removal risk:** 🟢 Low / 🟡 Verify first
---
## Context
> Brief note on why this dead code exists (e.g. "left over from a refactor that moved from X to Y pattern")
| Risk | When to use | |------|-------------| | 🟢 Low | Search confirms 0 references. Safe to delete. | | 🟡 Medium | Possibly used via reflection, string-based lookup, DI container, or in test files not searched. Verify manually before deleting. | | 🔴 High | References exist but appear indirect, or it's a base class with unknown subclasses outside the search scope. Do not delete without a deeper review. |
In statically-typed languages (Dart, TypeScript with strict mode, Go, Rust, Kotlin), almost all dead code is 🟢 because references are always explicit. In dynamically-typed or reflection-heavy languages (Python, Java with Spring, JS without TypeScript), be more conservative and use 🟡 when in doubt.
Always close with:
💡 Want me to generate a
/planto remove all of this safely, with intermediate verification steps and a final static analysis pass?
If the user says yes, invoke the claude-mem:make-plan skill with:
tools
Registers new cognitives (skills, agents, prompts, workflows, tools) into the SynapSync Registry with proper structure, manifest, and registry index. Trigger: When the user says "GUARDA", "REGISTRA", "AGREGA" followed by a cognitive type and name, or asks to save/register/add a cognitive to the registry.
testing
Adaptive sprint workflow: deep analysis, evolving roadmap, one-at-a-time sprints, formal debt tracking, and re-entry prompts for context persistence. Trigger: When the user wants to analyze a project, create a roadmap, generate/execute sprints iteratively, or check project status and technical debt.
documentation
Session memory for AI agents — load context at the start, save sessions at the end, evolve knowledge across sessions. Like a professional's notebook: open before work, write a summary when done, persist between sessions. Trigger: When starting a session and need to recover context, or ending a session and want to save what happened.
documentation
Unified planning and execution skill for any software scenario. PLAN mode produces structured documentation; EXECUTE mode implements sprints from plan output. Trigger: When planning or executing any software work that requires structured analysis and actionable task plans.