performance-smell-detection

Guidance for spotting possible Java code performance problems in streams, collections, regular expressions, boxing, and object creation. These are warnings to investigate, not proof that code is slow.

In plain words
What is it for?
Use it when reviewing performance-sensitive Java code, investigating measured slowdowns, or checking code paths before optimization.
Why use it?
It helps focus performance reviews on likely trouble spots while avoiding changes based only on assumptions; measurement with profilers or benchmarks is still needed.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/decebals/claude-code-java/performance-smell-detection
Any agent
npx skills add decebals/claude-code-java --skill performance-smell-detection
Clone the repo
git clone --depth 1 https://github.com/decebals/claude-code-java

Made for: Claude Code, Codex.

Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,303 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00051 $0.02303
Opus 5 $0.00026 $0.01151
Sonnet 5 $0.00010 $0.00461
Haiku 4.5 $0.00005 $0.00230

Measured 2d ago against content hash a43c8936af13, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

performance-smell-detection scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/performance-smell-detection/SKILL.md · 351 lines

How it starts

The opening of the file, as written. The whole thing — 351 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Performance Smell Detection Skill

Identify potential code-level performance issues in Java code.

Philosophy

"Premature optimization is the root of all evil" - Donald Knuth

This skill helps you notice potential performance smells, not blindly "fix" them. Modern JVMs (Java 21/25) are highly optimized. Always:

  1. Measure first - Use JMH, profilers, or production metrics
  2. Focus on hot paths - 90% of time spent in 10% of code
  3. Consider readability - Clear code often matters more than micro-optimizations

When to Use

  • Reviewing performance-critical code paths
  • Investigating measured performance issues
  • Learning about Java performance patterns
  • Code review with performance awareness

Scope

This skill: Code-level performance (streams, collections, objects) For database: Use jpa-patterns skill (N+1, lazy loading, pagination) For architecture: Use architecture-review skill


Quick Reference: Potential Smells

Smell Severity Context
Regex compile in loop 🔴 High Always worth fixing
String concat in loop 🟡 Medium Still valid in Java 21/25
Stream in tight loop 🟡 Medium Depends on collection size
Boxing in hot path 🟡 Medium Measure first
Unbounded collection 🔴 High Memory risk
Missing collection capacity 🟢 Low Minor, measure if critical

String Operations (Java 9+ / 21 / 25)

What Changed

Since Java 9 (JEP 280), string concatenation with + uses invokedynamic, not StringBuilder. The JVM optimizes simple concatenation well.

Java 25 adds String::hashCode constant folding for additional optimization in Map lookups with String keys.

Still Valid: StringBuilder in Loops

// 🔴 Still problematic - new String each iteration
String result = "";
for (String s : items) {
    result += s;  // O(n²) - creates n strings
}

// ✅ StringBuilder for loops
StringBuilder sb = new StringBuilder();
for (String s : items) {
    sb.append(s);
}
String result = sb.toString();

// ✅ Or use String.join / Collectors.joining
String result = String.join("", items);

Read the full file on GitHub · 351 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 351 lines · 51 tokens per session scan A a43c8936af13

Subscribe to this mod's changes

performance-smell-detection is a skill published in the GitHub repository decebals/claude-code-java (722 stars, last pushed 4d ago), licensed MIT. It adds 51 tokens to every session and 2,303 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

054-design-tdd

Use when Java implementation work should be guided by Test-Driven Development, including maintaining a test list, choosing the next behavior, writing a failing test first, implementing only enough production code to pass, and refactoring while keeping tests green. This should trigger for requests such as Apply TDD…

jabrena/plinth · 93 tokens

001-commands-inventory

Use when you need to generate a checklist document with embedded commands inventory, following the embedded template exactly and producing INVENTORY-COMMANDS-JAVA.md in the project root. This should trigger for requests such as Create embedded commands inventory checklist; Generate INVENTORY-COMMANDS-JAVA.md; Use…

jabrena/plinth · 92 tokens

003-skills-inventory

Use when you need to generate a checklist document with Java system prompts from skills.xml, following the embedded section template and producing INVENTORY-SKILLS-JAVA.md. This should trigger for requests such as Create Java system prompts checklist; Generate INVENTORY-SKILLS-JAVA.md; Use @003-skills-inventory…

jabrena/plinth · 88 tokens

053-design-simple-rules

Use when Java design, refactoring, or implementation tradeoffs should be evaluated with Kent Beck's simple design rules, including passes the tests, reveals intention, has no duplication, and has the fewest elements. This should trigger for requests such as Apply simple design rules; Review this design with Beck's…

jabrena/plinth · 86 tokens

jshell

Use when running Java snippets in JShell or using JShell as a Java REPL or scratchpad.

Heapy/kortex · 24 tokens

apideck-java

Apideck Unified API integration patterns for Java. Use when building integrations with accounting software (QuickBooks, Xero, NetSuite), CRMs (Salesforce, HubSpot, Pipedrive), HRIS platforms (Workday, BambooHR), file storage (Google Drive, Dropbox, Box), ATS systems (Greenhouse, Lever), e-commerce, or any of Apideck's…

apideck-libraries/api-skills · 117 tokens