remove-single-use-functions

Detect local, non-exported functions used once and guide inline refactoring.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill assists developers in refactoring codebases by providing guidance on safely identifying and removing functions that are used only once, reducing unnecessary code complexity.

Core Features & Use Cases

  • Function Identification: Detect local, non-exported functions used exactly once within code for cleaner, more maintainable code.
  • Refactoring Guidance: Offer step-by-step instructions to inline and remove such functions while preserving behavior, types, and style.
  • Use Case: During a code cleanup, a developer wants to eliminate redundant helper functions to improve readability without altering functionality.

Quick Start

Ask the AI to review your code and remove single-use functions safely for cleaner code.

Frequently Asked Questions about remove-single-use-functions

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

FAQPage Schema
How do I safely remove single-use functions during code refactoring?

To safely remove single-use functions during code refactoring, identify local non-exported functions used exactly once, then inline their logic directly into the calling code to preserve behavior, types, and style.

When should I inline a helper function to clean up my codebase?

You should inline a helper function to clean up your codebase when it is a local, non-exported function used only once, eliminating unnecessary code complexity while maintaining the original program functionality.

What is the best way to eliminate redundant helper functions without altering functionality?

The best way to eliminate redundant helper functions without altering functionality is to inline the single-use function's logic into its caller, preserving the original behavior, types, and coding style throughout the refactoring process.

Can I use this refactoring approach for exported functions in software engineering?

No, this refactoring approach targets local, non-exported functions used exactly once. Exported functions may be part of a public API and cannot be safely removed without checking for external usage.

Does single-use function removal work for large-scale codebase cleanup tasks?

Single-use function removal is suitable for small-scale cleanup tasks and code reviews. Large-scale refactoring may require broader analysis to ensure removing functions does not impact overall codebase maintainability.