prune-unused-code

Delete unused imports, dead functions, and commented-out blocks from Python modules.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/foolishimp/ai_sdlc_method --skill prune-unused-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prune-unused-code
Source: https://github.com/foolishimp/ai_sdlc_method/tree/main/plugins/code-skills/skills/debt/prune-unused-code
Command: npx skills add https://github.com/foolishimp/ai_sdlc_method --skill prune-unused-code

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Manually removing unused imports, dead code, and commented-out blocks is tedious, risky, and often deferred, leading to a bloated codebase. This skill automates the cleanup safely.

Core Features & Use Cases

  • Automated Deletion: Safely removes unused imports, dead functions, and commented-out code identified by detect-unused-code.
  • Safety Checks: Runs all tests before and after pruning, with automatic rollback on failure, ensuring no regressions are introduced.
  • Git Integration: Cleans up the codebase, preparing it for a clean, lean commit that enforces "No Legacy Baggage."
  • Use Case: After detect-unused-code identifies 5 unused imports and 2 dead functions, invoke this skill to automatically remove them, run tests to confirm no regressions, and prepare a commit.

Quick Start

Prune unused code from 'auth_service.py' based on the latest tech debt report, ensuring all tests pass afterwards.

Frequently Asked Questions about prune-unused-code

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

FAQPage Schema
How do I remove unused imports and dead code from my Python project?

Unused code removal deletes unreferenced imports, dead functions, and commented-out blocks automatically. Run this skill after `detect-unused-code` identifies unused code targets to safely prune them while preserving active code and running tests to confirm no regressions occur.

Can I safely delete dead code without breaking my application?

Yes. The skill runs all tests before and after pruning, with automatic rollback on failure. It performs line-level deletions and import edits based on detection reports, preserves used code, backs up changes, and generates deletion logs for full traceability.

What happens if pruning breaks a test?

The skill automatically rolls back changes if any test fails after pruning. This safety check ensures no regressions are introduced and your codebase remains stable throughout the cleanup process.

How do I prepare my repository for dead code removal?

Run `detect-unused-code` first to generate a tech debt report identifying unused imports, dead functions, and commented-out blocks. The skill then uses this report to target and remove the unused code safely.

Can this skill work with codebases that have incomplete test coverage?

The skill requires tests to run before and after pruning to validate no regressions occur. Codebases with minimal or no test coverage cannot guarantee safe removal, so establishing tests first is a prerequisite.

What's the best way to manage technical debt from commented-out code?

Dead code removal addresses technical debt by eliminating commented-out blocks, unused imports, and orphaned functions identified in detection reports. Automating cleanup prevents gradual codebase bloat and keeps repositories lean.