java-refactoring-extract-method
Refactoring using Extract Methods in Java Language
npx skills add github/awesome-copilot --skill java-refactoring-extract-method --agent copilot
Same command for any agent — swap --agent for claude-code, codex, cursor.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 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: ```java public FactLineBuilder setC_BPartner_ID_IfValid(final int bpartnerId) { assertNotBuild(); if (bpartnerId > 0) { setC_BPartner_ID(bpartnerId); } return this; } ``` ## Code After Refactoring 1: ```java 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)); } ``` ## Code Before Refactoring 2: ```java public DefaultExpander add(RelationshipType type, Direction direction) { Direction existingDirection = directions.get(type.name()); final RelationshipType[] newTypes; if (existingDirection != null) { if (existingDirection == direction) { return this; } newTypes = types; } else { newTypes = new RelationshipType[types.length + 1]; System.arraycopy(types, 0, newTypes, 0, types.length); newTypes[typ
- Role
- Code Before Refactoring 1:
- Code After Refactoring 1:
- Code Before Refactoring 2:
- Code After Refactoring 2:
- Task
- Code to be Refactored:
What does the java-refactoring-extract-method skill do?
Refactoring using Extract Methods in Java Language
How do I install it?
Run `npx skills add github/awesome-copilot --skill java-refactoring-extract-method --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From github/awesome-copilot, a repository with 37,432 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.