Dead Code Sweep logo

Dead Code Sweep

Organization
zenobi-us
dead-code-sweep

This skill should be used when cleaning up codebases that have accumulated dead code, redundant implementations, and orphaned artifacts — especially codebases maintained by coding agents. Triggers on "find dead code", "clean up unused code", "remove redundant code", "prune this codebase", "dead code sweep", "code cleanup", or when a codebase has gone through multiple agent-driven refactors and likely contains overlooked remnants. Systematically identifies cruft, categorizes findings, and removes confirmed dead code with user approval.

Overview

Publisherzenobi-us
Repositorydotfiles
Skill namedead-code-sweep
Stars
67
Forks
6
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by zenobi-us on GitHub. Read the source before you install it.

Installation

Install the Dead Code Sweep AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/zenobi-us/dotfiles.git /tmp/dotfiles
mkdir -p .claude/skills
cp -r /tmp/dotfiles/files/devtools/agent/bundles/developer/skills/devtools/dead-code-sweep .claude/skills/dead-code-sweep
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Dead Code Sweep in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Dead Code Sweep on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Dead Code Sweep is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Dead Code Sweep

Systematic identification and removal of dead code, redundant implementations, and orphaned artifacts in codebases — particularly those maintained by coding agents with limited context windows.

Why Agent-Maintained Codebases Accumulate Cruft

Coding agents operate within narrow context windows. When refactoring, they often:

  • Re-implement functionality without finding and removing the original
  • Leave compatibility shims for interfaces that no longer exist
  • Abandon helper functions after inlining their logic
  • Create new files without deleting the ones they replace
  • Duplicate type definitions across module boundaries
  • Leave imports for symbols they stopped using mid-refactor

This cruft compounds. Each orphaned artifact misleads the next agent (or human), who wastes context budget reading code that does nothing.

Workflow

Phase 1: Scope and Inventory

Determine the analysis boundary.

If the user provides a scope (directory, file pattern, module), constrain all analysis to that scope.

If no scope is provided, analyze the full codebase. Start by reading the project structure:

  1. Identify the primary language(s) and framework(s)
  2. Map entry points (main files, route definitions, exported modules, test runners)
  3. Note the build system and dependency configuration
  4. Check for monorepo structure — analyze each package as a unit

Produce a brief inventory:

Language(s): TypeScript, Python
Entry points: src/index.ts, src/cli.ts
Build: esbuild via package.json scripts
Packages: 1 (single package)
Estimated LOC: ~4,200

Phase 2: Detection

Launch parallel sub-agents to scan for different categories of dead code. Read references/cruft-patterns.md for the full catalog of detection patterns.

Organize detection into these parallel tracks:

TrackWhat It Finds
Orphaned filesFiles not imported, required, or referenced by any other file
Unused exportsExported symbols (functions, classes, types, constants) never imported elsewhere
Redundant implementationsMultiple functions/classes doing the same thing under different names
Stale compatibility codeShims, adapters, wrappers, and re-exports that bridge interfaces that no longer differ
Dead branchesConditional paths that can never execute (always-true/false guards, unreachable returns)
Orphaned testsTest files testing functions or modules that no longer exist
Orphaned dependenciesPackages in dependency manifests not imported anywhere in source

For each track, the sub-agent should:

  1. Read references/cruft-patterns.md for detection strategies specific to that track
  2. Search the codebase using Grep and Glob
  3. Verify each candidate by tracing references — a symbol is only dead if zero live code paths reach it 3b. Search CI scripts and shell test fixtures for path references to the candidate: rg <filename> -- scripts/ tests/ .github/. Files consumed as ratchet-check arguments or Bats test fixtures are NOT dead even if zero source files import them.
  4. Record findings with file path, line range, and evidence

Verification is critical. Common false positives to watch for:

  • Symbols used via dynamic dispatch, reflection, or string-based lookups
  • Framework-magic exports (e.g., Next.js page components, pytest fixtures, Rails conventions)
  • Public API surface intended for external consumers
  • Conditional imports behind feature flags or environment checks
  • Decorator-registered or plugin-registered handlers
  • CLI entry points referenced in package.json bin fields
  • CSS class names referenced in templates or JSX as dynamic strings
  • CI scripts and shell test fixtures that reference files by path — e.g., check_file_contains "name" "path/to/file" in scripts/ci/, or cat "$PROJECT_ROOT/path/to/file" in tests/**/*.bats. These are string arguments, not imports, so import-tracing tools miss them entirely.

When uncertain, mark as "needs review" rather than "confirmed dead."

Phase 3: Report

Consolidate all findings into a structured report at .claude/dead-code-report.md.

Organize findings by confidence level, then by category:

markdown
# Dead Code Sweep Report

**Scope:** [full codebase | specific path]
**Date:** [date]
**Estimated removable lines:** [count]

## Confirmed Dead (high confidence)

### Orphaned Files
- `src/utils/old-parser.ts` — Not imported anywhere. Superseded by `src/parser/index.ts`.
- ...

### Unused Exports
- `formatDate()` in `src/helpers.ts:42-58` — Exported but zero imports across codebase.
- ...

[...other categories...]

## Needs Review (uncertain)

### Possibly Dynamic
- `handleLegacyEvent()` in `src/events.ts:91` — No static imports, but may be registered dynamically.
- ...

For each finding, include:

  • File path and line range
  • What it is (function, class, file, type, constant, dependency)
  • Why it appears dead (no imports, no references, superseded by X)
  • Confidence (confirmed / needs review)

Phase 4: Cleanup with Approval

Present the report summary to the user and ask for approval before removing anything.

Use AskUserQuestion to present findings by category:

Found 12 confirmed dead items and 3 needing review.

Confirmed dead by category:
- 3 orphaned files (~280 lines)
- 5 unused exports (~120 lines)
- 2 redundant implementations (~90 lines)
- 2 orphaned dependencies

Which categories should I clean up?

Options: Remove all confirmed / Select categories / Review each item / Skip cleanup

For each approved category:

  1. Remove the dead code
  2. Clean up any imports that referenced the removed code
  3. Remove empty files left after cleanup
  4. Remove orphaned dependencies from the manifest
  5. Run the project's lint/typecheck/build commands to verify nothing broke

If any removal causes a build or type error, immediately revert that specific removal and move the item to "needs review."

After cleanup, update the report with what was removed and what was kept.

Detection Principles

Trace from entry points, not from suspects

Start from known entry points and trace what's reachable, rather than starting from a suspect symbol and trying to prove it's used. The reachability approach has fewer false negatives.

Respect the module boundary

A symbol exported from a package's public API may be consumed by external code not visible in this repository. When analyzing libraries or packages with external consumers, only flag internal (non-public-API) dead code as "confirmed." Flag public API dead code as "needs review."

Look for clusters, not just individuals

Agent-generated cruft tends to cluster. When one dead function is found, examine its neighbors — the agent likely abandoned the entire section during a refactor. A dead file often has sibling dead files created in the same commit.

Use git history as a signal

When available, check when suspect code was last meaningfully modified. Code untouched across several refactor commits is more likely dead. Use git log --follow to trace renames and detect superseded files.

Check CI and test infrastructure, not just source code

Files may have zero source-code references but be consumed by CI scripts (scripts/ci/, .github/workflows/), shell test fixtures (tests/**/*.bats), or verification tooling (.verifier/). These references appear as string arguments to shell functions — invisible to import tracing. Always run rg <filename> -- scripts/ tests/ .github/ before classifying a file as orphaned.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Dead Code Sweep AI skill do?

This skill should be used when cleaning up codebases that have accumulated dead code, redundant implementations, and orphaned artifacts — especially codebases maintained by coding agents. Triggers on "find dead code", "clean up unused code", "remove redundant code", "prune this codebase", "dead code sweep", "code cleanup", or when a codebase has gone through multiple agent-driven refactors and likely contains overlooked remnants. Systematically identifies cruft, categorizes findings, and removes confirmed dead code with user approval.

Why use Dead Code Sweep on TypingMind?

Because you install it once and use it with any model. Dead Code Sweep is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Dead Code Sweep in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/zenobi-us/dotfiles/tree/master/files/devtools/agent/bundles/developer/skills/devtools/dead-code-sweep. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Dead Code Sweep?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Dead Code Sweep?

As many as you like. As long as a model supports skills, you can use Dead Code Sweep with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Dead Code Sweep AI skill free?

Yes. It is published on GitHub by zenobi-us under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇