cleanup-unnecessary-variables

Identify and remove unnecessary local variables while preserving behavior.

5|Updated Jan 14, 2025
One-click install
npx skills add https://github.com/timmo001/dotfiles --skill cleanup-unnecessary-variables
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup-unnecessary-variables
Source: https://github.com/timmo001/dotfiles/tree/main/agents/.config/opencode/skills/cleanup-unnecessary-variables
Command: npx skills add https://github.com/timmo001/dotfiles --skill cleanup-unnecessary-variables

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides guidance on safely identifying and removing unnecessary or redundant variables in code, aiding developers during review and refactoring processes.

Core Features & Use Cases

  • Code Cleanup Guidance: Advises on inlining, dropping, or aliasing variables to improve code clarity and efficiency.
  • Refactoring Recommendations: Ensures evaluation order and behavior are preserved while simplifying codebases.
  • Use Case: When refactoring a JavaScript module, use this skill to identify temporary variables that can be inlined or eliminated without affecting functionality.

Quick Start

Use this skill to evaluate your code and identify variables that can be safely removed or inlined.

Frequently Asked Questions about cleanup-unnecessary-variables

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

FAQPage Schema
How do I safely remove redundant variables during code refactoring?

To safely remove redundant variables during code refactoring, you must evaluate each variable to ensure it has no side effects and is not shared, preserving the original evaluation order and behavior.

What is the best way to inline temporary variables in a JavaScript module?

The best way to inline temporary variables in a JavaScript module is to alias or drop them while enforcing safety rules that prevent accidental removal of side-effectful or shared variables.

Can I use automated cleanup on local non-exported variables in larger projects?

Yes, you can apply cleanup to local, non-exported variables in larger projects to reduce code complexity, provided you enforce safety rules to avoid removing variables with side effects.

When should I not eliminate unnecessary variables from my codebase?

You should not eliminate unnecessary variables if they produce side effects, are shared across scopes, or if removing them would alter the evaluation order and change the program's behavior.

How does variable cleanup reduce code complexity without altering behavior?

Variable cleanup reduces code complexity by inlining, dropping, or aliasing redundant local variables, while strictly preserving the original evaluation order and application behavior.