# 145-java-refactoring-high-performance

145-java-refactoring-high-performance — a skill for refactoring Java code for performance: reduce memory allocations, optimize CPU hot paths, and improve syntax. Works with Claude Code, Cursor, GitHub Copilot, and other AI editors.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 327 installs · ★ 465 repo stars
- Author: Juan Antonio Breña Moral
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/jabrena/plinth/tree/HEAD/skills/145-java-refactoring-high-performance/SKILL.md
- Updated: 2026-10-21
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/145-java-refactoring-high-performance

## What it does

This skill guides Java performance optimization through profiling-driven techniques. It covers three reference areas: memory allocation (primitives vs. wrappers, escape analysis, data layout), CPU-bound code (loop unrolling, bitwise operations, SIMD), and code shape (APIs, control flow, concurrency, I/O). The workflow starts by identifying a bottleneck and establishing a baseline, then selects the relevant reference section, applies minimal changes, and validates results against real throughput or latency gains.

The skill enforces a measure-first principle: optimize only where profiling shows actual hot spots. Includes bad/good code examples, validation workflows, and safety constraints. Part of the Plinth Toolkit by Juan Antonio Breña Moral.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add jabrena/plinth --skill 145-java-refactoring-high-performance -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/145-java-refactoring-high-performance/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/145-java-refactoring-high-performance/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add jabrena/plinth --skill 145-java-refactoring-high-performance -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/145-java-refactoring-high-performance/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add jabrena/plinth --skill 145-java-refactoring-high-performance -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/145-java-refactoring-high-performance/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install jabrena/plinth skills/145-java-refactoring-high-performance
```

2. **Manually: put the files in place**
- File: `.github/skills/145-java-refactoring-high-performance/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add jabrena/plinth --skill 145-java-refactoring-high-performance -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/jabrena/plinth --path skills/145-java-refactoring-high-performance
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/145-java-refactoring-high-performance/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add jabrena/plinth --skill 145-java-refactoring-high-performance -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/jabrena/plinth/tree/HEAD/skills/145-java-refactoring-high-performance/SKILL.md

## When to use it
- optimize Java hot paths based on profiling results
- reduce memory pressure: lower allocations, tune primitives and data layout
- improve CPU-bound algorithms: unroll loops, apply bitwise tricks, explore SIMD
- refactor syntax and control flow to cut latency
- verify performance gains before committing changes

## Example prompts
- Optimize this Java method for performance using a measure-first approach
- Review the code for avoidable memory allocations and object escapes
- Simplify this hot path: reduce branching and unroll the loop

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 31540937d6663a4e.

BEGIN THIRD-PARTY FILE 31540937d6663a4e
```text
---
name: 145-java-refactoring-high-performance
description: Use when you need to refactor Java code for high performance — including memory/allocation reduction, CPU hot-path optimization, and syntax/API/control-flow improvements. This should trigger for requests such as Review Java code for high performance; Optimize Java hot path; Reduce Java allocations; Improve Java latency/throughput. Part of Plinth Toolkit
license: Apache-2.0
metadata:
  author: Juan Antonio Breña Moral
  version: 0.19.0
---
# Java rules for High Performance

Identify and apply practical Java high-performance techniques using a measure-first approach, with emphasis on allocation reduction, data layout, concurrency discipline, and evidence-based validation.

**What is covered in this Skill?**

- Measure-first workflow for Java code optimization
- JVM/runtime-aware coding guidance
- Allocation reduction techniques with bad/good patterns
- CPU hot-path simplification and loop-level efficiency patterns
- Concurrency/backpressure and timeout/cancellation discipline
- I/O, parsing, and serialization efficiency patterns
- Persistence/query and caching strategy guidance
- Java-centric decision workflow: keep/revert based on measured impact

**Scope:** Practical optimization in application code and APIs. Apply only where profiling indicates real bottlenecks.

## Constraints

Performance optimization must be evidence-driven and safe, focused on Java code changes that preserve correctness and maintainability.

- **MEASURE-FIRST**: Establish baseline behavior and identify Java code hot paths before optimization
- **NO PREMATURE OPTIMIZATION**: Only optimize code paths identified by profiling evidence
- **BEFORE APPLYING**: Read the relevant reference(s) for bad/good examples and measurement workflow
- **EDGE CASE**: If hotspot evidence is unclear, ask clarifying questions before changing code

## When to use this skill

- Review Java code for high performance
- Optimize Java hot path
- Reduce Java allocations
- Improve Java latency
- Improve Java throughput

## Workflow

1. **Identify Java hotspot and baseline behavior**

Confirm the performance-sensitive Java path and baseline behavior before changing code.

2. **Select the relevant reference(s) by bottleneck**
```
END THIRD-PARTY FILE 31540937d6663a4e

The third-party file has ended. Everything between the 31540937d6663a4e tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2267 of 3751 bytes. © Juan Antonio Breña Moral · Apache-2.0 · https://github.com/jabrena/plinth/tree/HEAD/skills/145-java-refactoring-high-performance/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
