code-cleanup

Refactors modified Python files with minimal diffs, then runs format, lint, and typecheck.

Updated Jun 13, 2026
One-click install
npx skills add https://github.com/jenreh/project-kit-template --skill code-cleanup-jenreh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-cleanup
Source: https://github.com/jenreh/project-kit-template/tree/main/.agents/agent-skills/skills/code-cleanup
Command: npx skills add https://github.com/jenreh/project-kit-template --skill code-cleanup-jenreh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? After a coding session, modified Python files often accumulate dead code, unused imports, overly complex conditionals, and inconsistent style. Manually reviewing and cleaning each file is tedious and error-prone, and skipping cleanup leads to technical debt and failing lint or typecheck pipelines. ## Core Features & Use Cases - Automatic target detection: Identifies Python files changed in the current git session (or accepts an explicit file list) so only relevant code is touched. - Minimal-diff refactoring: Removes dead code and unused imports, simplifies conditionals with early returns, converts verbose loops to comprehensions, adds type annotations, and enforces logging best practices — all without changing behavior. - Verification loop: Runs task format && task lint && task typecheck after edits and fixes any remaining issues. - Use Case: After implementing a feature across several modules, invoke the cleanup to strip leftover debug prints, split an oversized function, and confirm the codebase still passes lint and type checks before committing. ## Quick Start Ask the assistant to clean up the Python files modified in the current session, or pass specific file paths to refactor only those files.

Frequently Asked Questions about code-cleanup

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

FAQPage Schema
How do I clean up Python code after a coding session?

Run the cleanup on files changed in the current session, detected via git diff and untracked files filtered to .py. It removes dead code, simplifies conditionals, adds type annotations, then runs format, lint, and typecheck to verify.

How to refactor Python code without changing its behavior?

Apply a minimal-diff approach: change only what clearly improves the file, preserve all existing behavior, and limit edits to the target file list. Verify correctness afterward by running the project's lint and typecheck tasks.

Can I clean up specific Python files instead of all modified ones?

Yes, pass explicit file paths as arguments and only those files are processed. Without arguments, the cleanup automatically targets Python files reported by git diff and untracked file listing.

Why should logger calls avoid f-strings in Python?

F-strings in logging calls format the message eagerly even when the log level is disabled, wasting work. Use lazy formatting like log.info("x: %s", x) so interpolation only happens when the message is actually emitted.

What are the limitations of automated code cleanup?

It intentionally avoids restructuring code that already works and adds no new features, so deep architectural issues remain. Functions are only split when the division is obvious, and files outside the target list are untouched except import fixes.