| name | nexus-slop-killer |
| description | Dead code detection and removal skill for NEXUS. Finds and eliminates unused imports, orphan exports, ghost components, dead types, console.logs, commented code, unused dependencies, and stale TODO/FIXME comments. Three modes: audit (report only), clean (safe removals), deep (aggressive with confirmation). Always load nexus-core first. |
NEXUS Slop Killer — Dead Code Elimination (Layer 1)
Prerequisite: Load nexus-core kernel before running this skill.
Modes of Operation
Mode: audit (safe, read-only)
Scans and reports slop without touching any files. Produces a categorized report with file paths, line numbers, and confidence scores.
Mode: clean (safe removals)
Removes items that are definitively dead code:
- Unused imports
- Unused local variables
console.log / console.warn / console.error in production code
- Commented-out code blocks (>3 lines)
- Empty catch blocks
Mode: deep (aggressive, with confirmation)
Everything in clean plus:
- Orphan exports (exported but never imported anywhere)
- Ghost components (
.tsx files never referenced by any route or component)
- Dead types/interfaces (defined but never used)
- Unused dependencies in
package.json
- Stale TODO/FIXME/HACK comments
- Redundant files (
.bak, .old, Copy of...)
ALWAYS ask for confirmation before executing deep mode.
Detection Categories
1. Dead Imports
Search pattern: For each .ts/.tsx file, check if every named import is referenced at least once below the import line.
2. Orphan Exports
Exceptions — do NOT flag:
- Exports from
index.ts barrel files
- Types exported for external consumers (API contracts)
- Components in
src/ui/components/common/ (may be used in future)
- Store actions (used via
useStore.getState())
3. Ghost Components
Verification: Before flagging, also check:
React.lazy(() => import('./...')) patterns in App.tsx
- Dynamic imports anywhere in the codebase
- Storybook or test files that reference it
4. Dead Types/Interfaces
5. Console Statements
CRITICAL EXCEPTION: Never remove console.error inside catch blocks that re-throw — these are intentional error logging.
6. Commented Code
7. Stale TODO/FIXME/HACK
8. Unused Dependencies
9. Duplicate/Stale Files
Safety Rules
NEVER remove:
- Anything in RED ZONE files (see nexus-core File Zones) without running protocol-integrity
- Exports from service files — may be used by Cloud Functions or tests
- Types from
PatientTypes.ts — single source of truth, used across entire codebase
- Barrel exports (
index.ts re-exports) — breaking these breaks downstream
- Store actions — may be called via
getState() which grep won't find
- Firestore collection names — hardcoded strings, not import references
- CSS classes — Tailwind purges unused classes at build time already
- Test files or test utilities — even if they seem unused
console.error in catch blocks that re-throw
- Data files in
src/data/ — static catalogs referenced by variable name
ALWAYS verify after removal:
npx tsc --noEmit
npx vite build
npx vitest run
Report Format
After running in any mode, produce this report:
## Slop Killer Report — [DATE]
**Mode:** audit | clean | deep
**Scope:** [file | module | all]
### Summary
| Category | Found | Removed | Skipped |
|----------|-------|---------|---------|
| Dead imports | X | X | X |
| Orphan exports | X | — | X |
| Ghost components | X | — | X |
| Dead types | X | — | X |
| Console statements | X | X | X |
| Commented code | X | X | X |
| TODO/FIXME | X | — | X |
| Unused deps | X | — | X |
| Stale files | X | — | X |
### Top Offenders (files with most slop)
1. `path/to/file.ts` — X issues
2. ...
### Details per Category
[itemized list with file:line for each finding]
### Verification
- tsc --noEmit: PASS/FAIL
- vite build: PASS/FAIL
- vitest run: PASS/FAIL (X/Y tests)
Integration with Quality Gates
After clean or deep mode:
- Run
regression-shield (Layer 2) to verify no tests broke
- If protocols were touched, run
protocol-integrity (Layer 2)
- Compare build size before/after (slop removal should reduce bundle)