Java Refactoring Remove Parameter
GitHubOfficialFirst committed by jduboisDistributed by GitHub
- Skill
- Workflow
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a rigorous, safety-first procedure for refactoring Java code by removing unused or derivable parameters. It emphasizes behavior preservation, requiring developers to verify test coverage before modification and to account for complex dependencies like reflection, serialization, and public API contracts. The workflow ensures that changes are applied consistently across method hierarchies and external callers to maintain system integrity.
What it does
- Identifies unused or derivable parameters in Java methods.
- Provides a checklist for verifying dependencies like reflection, JPA, and serialization.
- Guides the user through updating method declarations and all associated callers.
- Enforces a strict testing baseline before and after refactoring.
- Advises on handling public API changes via deprecation rather than breaking changes.
When to use it
- When you identify parameters that are no longer used by the method body.
- When a parameter value can be derived from existing fields or other parameters.
- When cleaning up technical debt to improve method signature readability.
- When reducing coupling in internal method calls.
Advantages
- Reduces cognitive load by simplifying method signatures.
- Minimizes the risk of breaking changes through a comprehensive verification checklist.
- Ensures consistency across complex hierarchies and reflective calls.
- Promotes better code maintainability by removing dead data flow.
Usage examples
- “I have a method 'processData(String data, boolean verbose)' where 'verbose' is never used. Can you help me remove it?”
- The agent will guide you to verify test coverage, check for overrides or reflective calls, update the method signature, and propagate the change to all callers while ensuring tests pass.
- “Refactor my constructor 'User(String name, int age, boolean isActive)' to remove 'isActive' as it is always false.”
- The agent will perform a search for all instantiations of the constructor, update them to remove the boolean argument, and verify that serialization or dependency injection frameworks are not impacted.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/github/java-refactoring-remove-parameter/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip java-refactoring-remove-parameter.zip -d .agents/skills
Documentation by jdubois
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 );
}Safety Rules
Behaviour-preserving only. Remove a parameter only if it is truly unused or derivable (field, constant, other parameter); never remove one that is read, even if "redundant" by convention.
Baseline first: run the narrowest green test command (
./mvnw -q -Dtest=MyTest test,./gradlew test --tests MyTest) or./mvnw verify/./gradlew build, and re-run after the change. If the baseline is red, stop and report.If the affected code has no tests, stop and report; propose characterization tests first. Never delete or weaken tests.
Find every usage before changing a signature: use LSP find-references (
lsp-setup/jdtls) and grep across all modules, including tests. Also check:overrides and interface implementors (
@Override, abstract/default methods, functional interfaces, method references): the whole hierarchy must change together;reflection and string-based lookups (
getMethod,getDeclaredMethod,MethodHandle, proxies), and Spring/CDI/Quarkus/Jakarta annotated methods (@Bean,@EventListener,@Scheduled,@Inject,@Path,@Observes,@PostConstruct), which a compiler will not flag;constructors used by serialization/deserialization or JPA/Jackson (
@JsonCreator,@ConstructorBinding,readObject), andserialVersionUIDimpact;XML/properties/YAML configuration and AOP pointcut expressions naming the method;
public or protected API consumed by other modules or published artifacts.
Ask the user before changing public/protected/published API (prefer deprecating and adding an overload) or touching generated code.
One parameter per step (one commit each when the user asks for commits). Prefer the jdtls Change Method Signature refactoring when available; otherwise update the declaration and all callers together.
Removing a parameter can make an overload collide with an existing signature or change overload resolution; check this. Evaluating the argument at the call site may have had side effects: keep them if they matter.
Task
Apply Remove Parameter to improve readability, coupling and consistency.
Identify unused or derivable parameters.
Remove each from the declaration and from all callers, then compile and run the tests.
Add a one-line comment only where the removal is non-obvious; otherwise explain it in the report.
Report parameters removed, callers updated, the commands run and their results, and anything left unverified (e.g. reflective or external callers).
Code to be Refactored:
Now, assess all methods with unused parameters and refactor them using Remove Parameter
Files
- ATTRIBUTION.mdAdded by AutoGineer897 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md4.5 KiB
ATTRIBUTION.md
Attribution
This folder is an unmodified copy of the Agent Skill "java-refactoring-remove-parameter", distributed by AutoGineer (https://autogineer.com/agent-skills).
Commit: 797337f33f73e35d08d82f840e21c4b8c4932d88
First committed by: jdubois (https://github.com/jdubois)
Publisher: GitHub (https://github.com/github)
Licence: MIT License (https://github.com/github/awesome-copilot/blob/797337f33f73e35d08d82f840e21c4b8c4932d88/LICENSE)
Licence evidence: repository licence LICENSE
Retrieved: 2026-11-07
The skill's own files are unmodified copies. AutoGineer is not affiliated with or endorsed by the author or the publisher.
Files added by AutoGineer
ATTRIBUTION.md: this file, written by AutoGineer
LICENSE: copied from LICENSE
Requirements and compatibility
Written for: GitHub Copilot
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- First committed by
jdubois
- Publisher
- GitHub (Official)
- Distributed by
- GitHub
- Source
- github/awesome-copilot · skills/java-refactoring-remove-parameter · commit 797337f
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Contributors
- jdubois
AutoGineer is not affiliated with or endorsed by jdubois or GitHub.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download java-refactoring-remove-parameter.zip