find-dead-code

Identify unused code in Python projects and report cleanup candidates.

71|88|Updated Nov 8, 2023
One-click install
npx skills add https://github.com/openshift/lightspeed-service --skill find-dead-code-openshift
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: find-dead-code
Source: https://github.com/openshift/lightspeed-service/tree/main/.cursor/skills/find-dead-code
Command: npx skills add https://github.com/openshift/lightspeed-service --skill find-dead-code-openshift

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Scan a codebase to identify unused functions, classes, imports, and unreachable code paths so teams can safely prune bloat and improve maintainability.

Core Features & Use Cases

  • Static analysis identifies dead code in production paths while excluding test code unless explicitly requested.
  • False positive handling: classifies findings to minimize unnecessary removals and prompts for review before cleanup.
  • Use Case: You are preparing a codebase for refactoring and want a concise report of removable items without touching tests or dynamic imports.

Quick Start

Run a targeted dead-code scan on the ols/ directory and review the generated report before any changes.

Frequently Asked Questions about find-dead-code

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

FAQPage Schema
How do I find dead code in a Python project for safer cleanup?

Finding dead code in a Python project involves running static analysis on production paths to identify unused functions, classes, and imports. This Skill scans directories like ols/ and generates a concise report of removable items to safely prune bloat.

How does static analysis handle false positives when identifying unused code?

Static analysis handles false positives by classifying findings and cross-checking results using vulture and pylint unused checks. It filters potential false positives before suggesting removals, prompting for human review to minimize unnecessary code deletion.

Can I scan test code for dead code alongside production paths?

Scanning test code for dead code is possible but excluded by default unless explicitly requested. The analysis focuses on production paths within directories like ols/ to ensure refactoring targets main application logic without touching test suites.

What's the best way to prepare a Python codebase for refactoring and removing dead code?

Preparing a Python codebase for refactoring involves running a targeted dead-code scan on production directories to report cleanup candidates. Leveraging vulture and pylint identifies unused imports and unreachable paths while filtering false positives before changes.

What are the limitations of using vulture for dead code detection?

A limitation of using vulture for dead code detection is potential false positives from dynamic imports or runtime code generation. This Skill mitigates limitations by cross-checking with pylint and classifying results to filter inaccuracies before prompting for removal review.