New to Claude Skills? Learn how to install them →

Jgithub on GitHub

Java Refactoring: Remove Parameter

OfficialFree

Streamline Java methods by removing unnecessary parameters.

by github37.7k stars on github/awesome-copilot
4 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What Java Refactoring: Remove Parameter does

This skill focuses on refactoring Java methods by applying the 'Remove Parameter' technique. It provides clear examples of how to identify and eliminate parameters that are either unused or redundant, thereby enhancing the readability and maintainability of your code. The skill emphasizes the importance of keeping methods clean and focused, which is crucial for long-term code health and collaboration among developers.

The skill includes two detailed examples that illustrate the refactoring process. In the first example, a method that originally accepted three parameters is simplified to accept only two, as one parameter was deemed unnecessary for its functionality. The second example showcases a constructor where a parameter is removed, improving clarity without sacrificing functionality. These examples serve as practical guides for developers looking to improve their Java code.

By following the instructions provided, users can ensure that their methods remain compilable and functional after the refactoring process. This skill is particularly useful for developers who are maintaining legacy code or working on large codebases where parameter management can become cumbersome. It promotes best practices in coding by encouraging modularity and low coupling, which are essential for scalable software development.

When to use it

Use this skill when you need to refactor Java methods to enhance readability and reduce complexity.

When not to use it

This skill is not suitable for cases where parameters are essential for method functionality or when the method's logic is already optimal.

What you can build with it

Refactoring Legacy Code

When working on legacy Java code, use this skill to identify and remove unnecessary parameters, making the codebase easier to understand.

Improving Code Reviews

In code reviews, apply this skill to suggest improvements for methods with excessive parameters, enhancing overall code quality.

Enhancing Testability

Refactor methods to remove unnecessary parameters, making them easier to test and maintain in unit tests.

How to install Java Refactoring: Remove Parameter

View source

1. Install with the skills CLI

npx skills add github/awesome-copilot/java-refactoring-remove-parameter --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by github

Refactoring Java Methods with Remove Parameter

Role

You are an expert in refactoring Java methods.

Below are 2 examples (with titles code before and code after refactoring) that represents Remove Parameter.

Code Before Refactoring 1:

public Backend selectBackendForGroupCommit(long tableId, ConnectContext context, boolean isCloud)
        throws LoadException, DdlException {
    if (!Env.getCurrentEnv().isMaster()) {
        try {
            long backendId = new MasterOpExecutor(context)
                    .getGroupCommitLoadBeId(tableId, context.getCloudCluster(), isCloud);
            return Env.getCurrentSystemInfo().getBackend(backendId);
        } catch (Exception e) {
            throw new LoadException(e.getMessage());
        }
    } else {
        return Env.getCurrentSystemInfo()
                .getBackend(selectBackendForGroupCommitInternal(tableId, context.getCloudCluster(), isCloud));
    }
}

Code After Refactoring 1:

public Backend selectBackendForGroupCommit(long tableId, ConnectContext context)
        throws LoadException, DdlException {
    if (!Env.getCurrentEnv().isMaster()) {
        try {
            long backendId = new MasterOpExecutor(context)
                    .getGroupCommitLoadBeId(tableId, context.getCloudCluster());
            return Env.getCurrentSystemInfo().getBackend(backendId);
        } catch (Exception e) {
            throw new LoadException(e.getMessage());
        }
    } else {
        return Env.getCurrentSystemInfo()
                .getBackend(selectBackendForGroupCommitInternal(tableId, context.getCloudCluster()));
    }
}

Code Before Refactoring 2:

NodeImpl( long id, long firstRel, long firstProp )
{
     this( id, false );
}

Code After Refactoring 2:

NodeImpl( long id)
{
     this( id, false );
}

Task

Apply Remove Parameter to improve readability, testability, maintainability, reusability, modularity, cohesion, low coupling, and consistency.

Always return a complete and compilable method (Java 17).

Perform intermediate steps internally:

  • First, analyze each method and identify parameters that are unused or redundant (i.e., values that can be obtained from class fields, constants, or other method calls).
  • For each qualifying method, remove the unnecessary parameters from its definition and from all its internal calls.
  • Ensure that the method continues to function correctly after parameter removal.
  • Output only the refactored code inside a single java block.
  • Do not remove any functionality from the original method.
  • Include a one-line comment above each modified method indicating which parameter was removed and why.

Code to be Refactored:

Now, assess all methods with unused parameters and refactor them using Remove Parameter

Frequently asked questions about Java Refactoring: Remove Parameter

Similar skills