Skip to content
Skillpedia
General coding40k · #5202

java-refactoring-remove-parameter

Allows your agent to remove unnecessary parameters from functions in Java code. This simplifies the code, making it cleaner and more efficient.

What it does

This tool helps clean up your Java code by removing unnecessary information passed into functions. This makes the code easier to understand and use.

When to use it

  • ✓When a function receives data it doesn't use.
  • ✓To simplify functions that have too many arguments.
  • ✓When organizing code to make it clearer.

Example of what to ask your AI

“Remove the 'isCloud' parameter from the 'selectBackendForGroupCommit' function because it's not being used.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/github/awesome-copilot/blob/main/skills/java-refactoring-remove-parameter/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/java-refactoring-remove-parameter/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The AI analyzes your Java functions to find parameters that aren't being used. It then removes these parameters and updates the code so it still works correctly, but in a cleaner way.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add github/awesome-copilot --skill java-refactoring-remove-parameter

Or download just the file:

curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/java-refactoring-remove-parameter/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from 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

FAQ

Why does removing parameters improve code?

Removing unnecessary parameters makes code easier to read, understand, and test, as there's less information to manage.

Will the code still work after the change?

Yes, the goal is to remove only what isn't used, ensuring the functionality remains the same.

Does this affect other parts of my program?

If the modified function is called elsewhere, the AI will also adjust those calls so everything continues to work together.

Details

Original description by the author

Refactoring using Remove Parameter in Java Language

repo: github/awesome-copilot

Popularity

GitHub stars
40k
Ranking position
#5202
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills