dead-code

Identify and verify unused TypeScript code artifacts before deletion.

217|7|Updated Dec 9, 2024
One-click install
npx skills add https://github.com/shift-editor/shift --skill dead-code-shift-editor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dead-code
Source: https://github.com/shift-editor/shift/tree/main/.claude/skills/dead-code
Command: npx skills add https://github.com/shift-editor/shift --skill dead-code-shift-editor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Dead code detection often produces false positives that break builds or runtime behavior, especially when usage happens indirectly through interfaces and dependency-injection patterns.

Core Features & Use Cases

  • Knip-based candidate discovery: Generates unused file/export/class-member candidates without auto-fixing.
  • AST-level and interface-tracing verification: Confirms or rejects each candidate before removal, with special handling for interface-mediated usage.
  • Risk-controlled cleanup workflow: Categorizes results (confirmed dead, likely dead, false positive) and enforces verification and safety protocol after changes.

Quick Start

Ask the skill to find and verify dead code by running the Knip candidate generators and then confirming each candidate with reference tracing and interface-contract checks before you remove anything.

Frequently Asked Questions about dead-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely remove unused TypeScript code without breaking interface contracts?

Unused TypeScript code is safely removed by generating Knip candidates without auto-fixing, then verifying each candidate with AST-level reference tracing and interface contract validation before deletion. This prevents false positives that break builds.

Why does Knip report interface-mediated class members as unused code?

Knip misclassifies interface-mediated class members as unused code because it cannot trace indirect usage through dependency injection and interface patterns. AST-level reference tracing resolves this by verifying interface contracts before any deletion.

What's the best way to clean up dead code in a TypeScript project?

The best way to clean up dead code is a verification-first workflow: run Knip to discover unused file, export, and class member candidates, then confirm or reject each candidate with AST analysis and interface tracing before removing anything.

Can I use Knip --fix to automatically remove unused exports and files?

No, using Knip --fix is forbidden because it auto-removes code without verification. You must manually verify each unused file, export, and class member candidate with AST-level reference checks and interface contract validation to avoid breaking builds.

How are dead code removal candidates categorized during AST reference tracing?

During AST reference tracing, dead code removal candidates are categorized as confirmed dead, likely dead, or false positive. This risk-controlled workflow enforces verification and safety protocols before any code deletion occurs.

When do I need AST analysis for dead code detection in TypeScript?

AST analysis is needed for dead code detection when your TypeScript project uses interfaces and dependency-injection patterns, because standard tools like Knip can produce false positives by failing to trace indirect usage through interface contracts.