Skip to main content
skill GitHub Copilot official · GitHub

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.

Install into GitHub Copilot · Skills CLI (Vercel) All methods and platforms ↓
npx skills add github/awesome-copilot --skill java-refactoring-remove-parameter
Open on GitHub

What 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-parameter

2GitHub CLI

gh skill install github/awesome-copilot java-refactoring-remove-parameter

3Manually: put the files in place

.github/skills/java-refactoring-remove-parameter/SKILL.md

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs multi-stage-dockerfile official github This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies. GitHub Copilot 29,688installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs

Similar

chakra-ui-refactor chakra-ui Reviews components against Chakra UI v3 patterns and converts markup from HTML, Tailwind, or styled-components. Useful for UI refactoring and accessibility audits. Claude Code CX Codex Cursor +1 2,800installs error-handling-patterns Seth Hobson This skill covers exceptions, Result types, error propagation, and graceful degradation. Use it when designing APIs or debugging failures. Claude Code CX Codex Cursor 22,957installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. Claude Code 1,163,035installs tdd Matt Pocock Guides the red-green TDD loop: ensures tests are written first, keep them at public interfaces, and avoid coupling to implementation details. Claude Code 1,141,062installs triage Matt Pocock This skill moves issues and external PRs through triage states, verification, and agent briefs. It fits maintainers managing an issue queue. Claude Code 990,453installs codebase-design Matt Pocock This skill helps design modules with small interfaces and hidden complexity. Use it when refactoring code, choosing a seam, or making tests easier to write. Claude Code 850,344installs code-review Matt Pocock Reviews changes from a chosen reference point against repository standards and the originating spec. Use it for a branch, PR, or work in progress. Claude Code 789,521installs implement Matt Pocock Implements work from a specification or tickets, following a test-driven flow and ending with review and a commit. Use it when a coding task needs a defined delivery routine. Claude Code 774,700installs

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

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor