github avatar

Java Refactoring Extract Method

Claude Code's java-refactoring-extract-method skill guides developers through applying the Extract Method refactoring pattern to Java code, helping them break down complex or lengthy methods into smaller, more focused ones. It targets Java developers working on code maintenance and improvement, providing concrete before-and-after examples to demonstrate how extraction improves readability, testability, and reusability. The skill solves the problem of bloated methods by identifying candidates that exceed complexity thresholds and systematically extracting cohesive logic into separate, compilable methods.

skills.sh installs
9.3K
GitHub stars
41K
last updated
Aug 21, 2026

Install

$ npx -y skills add github/awesome-copilot --skill java-refactoring-extract-method --agent claude-code

Installs into .claude/skills of the current project.

Files

Refactoring Java Methods with Extract Method

Role

You are an expert in refactoring Java methods.

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

Code Before Refactoring 1:

public FactLineBuilder setC_BPartner_ID_IfValid(final int bpartnerId) {
	assertNotBuild();
	if (bpartnerId > 0) {
		setC_BPartner_ID(bpartnerId);
	}
	return this;
}

Code After Refactoring 1:

public FactLineBuilder bpartnerIdIfNotNull(final BPartnerId bpartnerId) {
	if (bpartnerId != null) {
		return bpartnerId(bpartnerId);
	} else {
		return this;
	}
}
public FactLineBuilder setC_BPartner_ID_IfValid(final int bpartnerRepoId) {
	return bpartnerIdIfNotNull(BPartnerId.ofRepoIdOrNull(bpartnerRepoId));
}

Sponsors

Details

Repository
github.com/github/awesome-copilot
Categories
Git & Pull Requests, Code Review & Quality, AI & Agent Building, Java & JVM

More from github/awesome-copilot

All 318
1github avatarbreakdown-testgithub/awesome-copilotTest Planning and Quality Assurance prompt that generates comprehensive test strategies, task breakdowns, and quality validation plans for GitHub projects.9.3Kskills.sh installs
2github avataradd-educational-commentsgithub/awesome-copilotAdd educational comments to the file specified, or prompt asking for file to comment if one is not provided.9.3Kskills.sh installs
3github avatarbreakdown-feature-implementationgithub/awesome-copilotPrompt for creating detailed feature implementation plans, following Epoch monorepo structure.9.2Kskills.sh installs
4github avatardataverse-python-advanced-patternsgithub/awesome-copilotGenerate production code for Dataverse SDK using advanced patterns, error handling, and optimization techniques.9.2Kskills.sh installs
5github avatarupdate-specificationgithub/awesome-copilotUpdate an existing specification file for the solution, optimized for Generative AI consumption based on new requirements or updates to any existing code.9.2Kskills.sh installs
6github avatargo-mcp-server-generatorgithub/awesome-copilotGenerate a complete Go MCP server project with proper structure, dependencies, and implementation using the official github.com/modelcontextprotocol/go-sdk.9.2Kskills.sh installs