code-clean

Refactor research codebases with behavior-preserving, risk-tiered cleanup.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/UnaryLab/ai-for-research --skill code-clean
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-clean
Source: https://github.com/UnaryLab/ai-for-research/tree/main/skills/code-clean
Command: npx skills add https://github.com/UnaryLab/ai-for-research --skill code-clean

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Clean up an existing codebase safely by removing dead code, debug cruft, and style issues while preserving behavior and outputs.

Core Features & Use Cases

  • Behavior-preserving cleanup with an explicit safety-net (tests or golden/characterization snapshots) and verify-after-each-batch discipline.
  • Risk-tiered refactoring that treats any changed outputs (especially numerical results) as regressions to revert.
  • Evidence-based dead-code removal using tool detection plus reference checks, while avoiding deletion of entry points, public APIs, or dynamically dispatched code.
  • Use cases: presenting experiment code, removing unused imports and debug prints, extracting hardcoded paths/hyperparameters into config, and preparing code for release or handoff.

Quick Start

Run behavior-preserving cleanup for the codebase on your branch by first capturing a baseline (tests or a golden outputs snapshot) and then applying safe formatting/lint fixes followed by evidence-backed dead-code removal.

Frequently Asked Questions about code-clean

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

FAQPage Schema
How do I clean up research code without changing numerical outputs?

To clean up research code without changing outputs, apply behavior-preserving refactoring using an explicit safety net like tests or golden snapshots, verifying after each batch and reverting any changes that alter numerical results.

What is the safest way to remove dead code and debug prints before release?

The safest way to remove dead code and debug prints is evidence-based deletion using tool detection and reference checks, while keeping a deletion log and avoiding removal of entry points, public APIs, or dynamically dispatched code.

Do I need tests or snapshots before refactoring experiment code?

Yes, you need a pre-change safety net of tests or golden characterization snapshots before refactoring experiment code to capture a baseline, apply incremental verified edits, and prevent regressions during cleanup.

How to extract hardcoded paths and hyperparameters into config for code handoff?

To extract hardcoded paths and hyperparameters into config for handoff, perform risk-tiered refactoring that treats any changed outputs as regressions to revert, ensuring identical behavior while tidying the codebase structure.

When should I not use automated linting and dead code removal on my codebase?

You should avoid automated linting and dead code removal when you lack a pre-change safety net of tests or golden snapshots, as conservative deletion requires baseline verification to prevent behavior regressions.