java-refactoring-remove-parameter — GitHub Copilot Java skill
This skill guides an agent through removing unused or derivable parameters from Java methods and updating their callers. Use it when the change must preserve behavior and be checked with tests.
npx skills add github/awesome-copilot --skill java-refactoring-remove-parameterWhat java-refactoring-remove-parameter does
The skill asks the agent to confirm that a parameter is unused or can be derived from a field, constant, or another parameter. It then calls for checking every usage, method hierarchies, reflective lookups, configuration references, overloads, and side effects at call sites. Its examples show a method and a constructor with a parameter removed.
Run a suitable test command before editing and rerun tests afterward. If the baseline fails or the affected code has no tests, the skill says to stop; for public or protected APIs and generated code, ask the user before proceeding. Install it when you want a cautious, test-led workflow for Java signature changes. It is unnecessary for parameter inspection alone.
What it helps with
- find unused parameters in Java methods
- remove a parameter from a declaration and its callers
- check overrides and method references before changing a signature
- preserve argument side effects at call sites
- compare test results before and after a refactor
Example prompts for the agent
- Find unused parameters in this Java module and run the relevant tests first.
- Remove `context` from this method only if it is truly unused; update callers and rerun the tests.
- Check whether removing this parameter affects overrides, reflective lookups, or a public API.
How to install java-refactoring-remove-parameter
1Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill java-refactoring-remove-parameter2GitHub CLI
gh skill install github/awesome-copilot java-refactoring-remove-parameter3Manually: put the files in place
.github/skills/java-refactoring-remove-parameter/SKILL.md1Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill java-refactoring-remove-parameter -a claude-code2Manually: put the files in place
~/.claude/skills/java-refactoring-remove-parameter/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/java-refactoring-remove-parameter/
Manually: put the files in place
.agents/skills/java-refactoring-remove-parameter/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/java-refactoring-remove-parameter/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
Platform CLI
gemini skills install https://github.com/github/awesome-copilot --path skills/java-refactoring-remove-parameterManually: put the files in place
.devin/skills/java-refactoring-remove-parameter/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set554
The whole set →Similar
Questions about java-refactoring-remove-parameter
How do I install java-refactoring-remove-parameter in GitHub Copilot?
Run npx skills add github/awesome-copilot --skill java-refactoring-remove-parameter. You can also use gh skill install github/awesome-copilot java-refactoring-remove-parameter.
What does java-refactoring-remove-parameter do?
It guides an agent in identifying unused or derivable Java parameters, removing them from method signatures and callers, and checking relevant tests and dependencies.
What if the affected code has no tests?
The skill says to stop and propose characterization tests first. It also forbids deleting or weakening existing tests.
Source text
SKILL.md · MIT
---
name: java-refactoring-remove-parameter
description: 'Refactoring using Remove Parameter in Java Language'
---
# 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:
```java
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:
```java
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:
```java
NodeImpl( long id, long firstRel, long firstProp )
{
this( id, false );
}
```
## Code After Refactoring 2:
```java
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`), and `serialVersionUID` impact;
- 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.
1. Identify unused or derivable parameters.
2. Remove each from the declaration and from all callers, then compile and run the tests.
3. Add a one-line comment only where the removal is non-obvious; otherwise explain it in the report.
4. 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**
© github · MIT · github/awesome-copilot