Skip to main content
ZICQ

Skills ZICQ category:Agent Workflows java-refactoring-extract-method

Java Refactoring Extract Method

Refactoring using Extract Methods in Java Language

9345 installs

Official URL:skills.sh

What this skill does

Intro in this page language first. The official description stays in its original wording; we do not rewrite SKILL.md.

What it does

Refactoring using Extract Methods in Java Language

When to use it

The official description does not include a separate “Use when”. Per the spec, agents activate this skill when the task matches keywords in that description.

How agents load it

Per Agent Skills progressive disclosure: name and description load at startup (~100 tokens); the full SKILL.md body loads when the skill activates; scripts/, references/, and assets/ load only as needed. This file's sections: Refactoring Java Methods with Extract Method; Role; Code Before Refactoring 1:; Code After Refactoring 1:; Code Before Refactoring 2:; Code After Refactoring 2:.

File analysis

File analysis: instruction-only skill (SKILL.md). The agent loads the full body when activated.

Refactoring Java Methods with Extract MethodRoleCode Before Refactoring 1:Code After Refactoring 1:Code Before Refactoring 2:Code After Refactoring 2:TaskCode to be Refactored:

Source category:skills.sh agent-skill

SKILL.md & Agent activation

Official spec ↗
name
java-refactoring-extract-method
description
Refactoring using Extract Methods in Java Language
  1. DiscoverThe client exposes names and descriptions to the agent.
  2. ActivateYour request or the task context selects the skill and loads its instructions.
  3. Load resourcesReferenced scripts, documentation and assets are used when needed.

Invocation syntax and available tools depend on your Agent client. Client integration guide ↗

Install this skill

Skills CLI ↗

Choose the target agent and installation scope, keep referenced package files, then verify the skill appears in the client's catalog.

Ask your Agent to install

Copy these instructions to a compatible agent and confirm the target directory matches your client.

Install the agent skill "java-refactoring-extract-method" into my project. The full SKILL.md and official description are at https://zicq.com/en/skills/skl-930be29916f1fd88-Java-Refactoring-Extract-Method.html
Save it as .cursor/skills/java-refactoring-extract-method/SKILL.md or .claude/skills/java-refactoring-extract-method/SKILL.md and keep the frontmatter name and description exactly as-is.

Full package on GitHub ↗

Install from the terminal · Skills CLI

Requires Node.js and npx. First inspect the repository's skill list to confirm the name.

npx skills add 'https://github.com/github/awesome-copilot' --list

npx skills add 'https://github.com/github/awesome-copilot' --skill 'java-refactoring-extract-method'

The CLI lets you choose the agent interactively. The default scope is the project; use -g for user scope. Confirm package availability with the discovery command, then use npx skills list to inspect installed skills.

Readable layout
--- name: java-refactoring-extract-method description: 'Refactoring using Extract Methods in Java Language' --- # 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[types.length] = type; } Map newDirections = new HashMap(directions); newDirections.put(type.name(), direction); return new DefaultExpander(newTypes, newDirections); } ``` ## Code After 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[types.length] = type; } Map newDirections = new HashMap(directions); newDirections.put(type.name(), direction); return (DefaultExpander) newExpander(newTypes, newDirections); } protected RelationshipExpander newExpander(RelationshipType[] types, Map directions) { return new DefaultExpander(types, directions); } ``` ## Task Apply **Extract Method** to improve readability, testability, maintainability, reusability, modularity, cohesion, low coupling, and consistency. Always return a complete and compilable method (Java 17). Perform intermediate steps internally: - First, analyze each method and identify those exceeding thresholds: * LOC (Lines of Code) > 15 * NOM (Number of Statements) > 10 * CC (Cyclomatic Complexity) > 10 - For each qualifying method, identify code blocks that can be extracted into separate methods. - Extract at least one new method with a descriptive name. - Output only the refactored code inside a single ```java``` block. - Do not remove any functionality from the original method. - Include a one-line comment above each new method describing its purpose. ## Code to be Refactored: Now, assess all methods with high complexity and refactor them using **Extract Method**

Related skills

Agent Workflows

Skill Creator

Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that exte…

Agent Workflows

Clawdhub

Use the ClawdHub CLI to search, install, update, and publish agent skills from clawdhub.com. Use when you need to fetch new skills on the fl…

Agent Workflows

Agent Team Orchestration

Orchestrate multi-agent teams with defined roles, task lifecycles, handoff protocols, and review workflows. Use when: (1) Setting up a team …

Agent Workflows

Superpowers

Spec-first, TDD, subagent-driven software development workflow. Use when: (1) building any new feature or app — triggers brainstorm → plan →…