Agent skill

Performance Smell Detection

by decebals in decebals/claude-code-java

Detect potential code-level performance smells in Java - streams, collections, boxing, regex, object creation.

MITAuto-check passedDevelopment

Install Performance Smell Detection

skills CLI
$ npx skills add decebals/claude-code-java --skill performance-smell-detection -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install decebals/claude-code-java performance-smell-detection --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/decebals/claude-code-java.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/performance-smell-detection .claude/skills/performance-smell-detection && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
performance-smell-detection
GitHub stars
751
Token cost
~2.3k tokens
SKILL.md length
477 words
Files
2
Skills in repo
18
Repo updated
First seen
Licence
MIT

At a glance

Detect potential code-level performance smells in Java - streams, collections, boxing, regex, object creation.

  • Works in 3 steps: Measure first - Use JMH, profilers, or… → Focus on hot paths - 90% of time spent… → Consider readability - Clear code often…
  • Development work in your project
  • SKILL.md covers Philosophy, When to Use, Scope and Quick Reference: Potential…, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Performance Smell Detection is an agent skill from decebals/claude-code-java. Detect potential code-level performance smells in Java - streams, collections, boxing, regex, object creation. Provides awareness, not absolutes - always measure before optimizing. For JPA/database performance, use jpa-patterns instead.

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file (for example `README.md`).

It sits in Development. It works with Java. The repository describes itself as: Reusable AI development infrastructure for Java projects, optimized for Claude Code. The licence is MIT.

When your agent uses it

  • Development work in your project

Example prompts

  • “/performance-smell-detection”

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  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

What it can do on your machine

Read from SKILL.md and the folder at commit 0d98fe9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are java and bash).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Performance Smell Detection loads about 2.3k tokens when it runs. Until then it costs about 66 tokens; SKILL.md has 477 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~66
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from decebals/claude-code-java at commit 0d98fe9, republished under its MIT licence (© decebals). 477 words, ~2,270 tokens.

Download SKILL.mdSave it as .claude/skills/performance-smell-detection/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
performance-smell-detection
description
Detect potential code-level performance smells in Java - streams, collections, boxing, regex, object creation. Provides awareness, not absolutes - always measure before optimizing. For JPA/database performance, use jpa-patterns instead.
license
MIT

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

SmellSeverityContext
Regex compile in loop🔴 HighAlways worth fixing
String concat in loop🟡 MediumStill valid in Java 21/25
Stream in tight loop🟡 MediumDepends on collection size
Boxing in hot path🟡 MediumMeasure first
Unbounded collection🔴 HighMemory risk
Missing collection capacity🟢 LowMinor, 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
java
// 🔴 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);
Now Fine: Simple Concatenation
java
// ✅ Fine in Java 9+ - JVM optimizes this
String message = "User " + name + " logged in at " + timestamp;

// ✅ Also fine
return "Error: " + code + " - " + description;
Avoid in Hot Paths: String.format
java
// 🟡 String.format has parsing overhead
log.debug(String.format("Processing %s with id %d", name, id));

// ✅ Parameterized logging (SLF4J)
log.debug("Processing {} with id {}", name, id);

Stream API (Nuanced View)

The Reality

Streams have overhead, but it's often acceptable:

  • < 100 items: Streams can be 2-5x slower (but still microseconds)
  • 1K-10K items: Difference narrows significantly
  • > 10K items: Often within 50% of loops
  • GraalVM: Can optimize streams to match loops

Recommendation: Prefer streams for readability. Optimize to loops only when profiling shows a bottleneck.

When Streams Are Problematic
java
// 🔴 Stream created per iteration in hot loop
for (int i = 0; i < 1_000_000; i++) {
    boolean found = items.stream()
        .anyMatch(item -> item.getId() == i);
}

// ✅ Pre-compute lookup structure
Set<Integer> itemIds = items.stream()
    .map(Item::getId)
    .collect(Collectors.toSet());

for (int i = 0; i < 1_000_000; i++) {
    boolean found = itemIds.contains(i);
}
Show full SKILL.md (190 more words)Show less
When Streams Are Fine
java
// ✅ Single pass, readable, not in tight loop
List<String> names = users.stream()
    .filter(User::isActive)
    .map(User::getName)
    .sorted()
    .collect(Collectors.toList());

// ✅ Primitive streams avoid boxing
int sum = numbers.stream()
    .mapToInt(Integer::intValue)
    .sum();
Parallel Streams: Use Carefully
java
// 🔴 Parallel on small collection - overhead > benefit
smallList.parallelStream().map(...);  // < 10K items

// 🔴 Parallel with shared mutable state
List<String> results = new ArrayList<>();
items.parallelStream()
    .forEach(results::add);  // Race condition!

// ✅ Parallel for CPU-intensive + large collections
List<Result> results = largeDataset.parallelStream()  // > 10K items
    .map(this::expensiveCpuComputation)
    .collect(Collectors.toList());

Boxing/Unboxing

Still a Real Issue

Boxing creates objects on heap, adds GC pressure. JVM caches small values (-128 to 127) but not larger ones.

Future: Project Valhalla will improve this significantly.

java
// 🔴 Boxing in tight loop - creates millions of objects
Long sum = 0L;
for (int i = 0; i < 1_000_000; i++) {
    sum += i;  // Unbox, add, box
}

// ✅ Primitive
long sum = 0L;
for (int i = 0; i < 1_000_000; i++) {
    sum += i;
}
Use Primitive Streams
java
// 🟡 Boxing overhead
int sum = list.stream()
    .reduce(0, Integer::sum);

// ✅ Primitive stream
int sum = list.stream()
    .mapToInt(Integer::intValue)
    .sum();

Regex

Always Pre-compile in Loops

This advice is not outdated - Pattern.compile is expensive.

java
// 🔴 Compiles pattern every iteration
for (String input : inputs) {
    if (input.matches("\\d{3}-\\d{4}")) {  // Compiles regex!
        process(input);
    }
}

// ✅ Pre-compile
private static final Pattern PHONE = Pattern.compile("\\d{3}-\\d{4}");

for (String input : inputs) {
    if (PHONE.matcher(input).matches()) {
        process(input);
    }
}

Collections

Capacity Hint (Minor Optimization)
java
// 🟢 Low severity - but free optimization if size known
List<User> users = new ArrayList<>(expectedSize);
Map<String, User> map = new HashMap<>(expectedSize * 4 / 3 + 1);
Right Collection for the Job
java
// 🟡 O(n) lookup in loop
List<String> allowed = getAllowed();
for (Request r : requests) {
    if (allowed.contains(r.getId())) { }  // O(n) each time
}

// ✅ O(1) lookup
Set<String> allowed = new HashSet<>(getAllowed());
for (Request r : requests) {
    if (allowed.contains(r.getId())) { }  // O(1)
}
Unbounded Collections
java
// 🔴 Memory risk - could grow unbounded
@GetMapping("/users")
public List<User> getAllUsers() {
    return userRepository.findAll();  // Millions of rows?
}

// ✅ Pagination
@GetMapping("/users")
public Page<User> getUsers(Pageable pageable) {
    return userRepository.findAll(pageable);
}

Modern Java (21/25) Patterns

Virtual Threads for I/O (Java 21+)
java
// 🟡 Traditional thread pool for I/O - wastes OS threads
ExecutorService executor = Executors.newFixedThreadPool(100);
for (Request request : requests) {
    executor.submit(() -> callExternalApi(request));  // Blocks OS thread
}

// ✅ Virtual threads - millions of concurrent I/O operations
try (ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor()) {
    for (Request request : requests) {
        executor.submit(() -> callExternalApi(request));
    }
}
Structured Concurrency (Java 21+ Preview)
java
// ✅ Structured concurrency for parallel I/O
try (StructuredTaskScope.ShutdownOnFailure scope = new StructuredTaskScope.ShutdownOnFailure()) {
    Future<User> user = scope.fork(() -> fetchUser(id));
    Future<Orders> orders = scope.fork(() -> fetchOrders(id));

    scope.join();
    scope.throwIfFailed();

    return new UserProfile(user.resultNow(), orders.resultNow());
}

Performance Review Checklist

🔴 High Severity (Usually Worth Fixing)
  • Regex Pattern.compile in loops
  • Unbounded queries without pagination
  • String concatenation in loops (StringBuilder still valid)
  • Parallel streams with shared mutable state
🟡 Medium Severity (Measure First)
  • Streams in tight loops (>100K iterations)
  • Boxing in hot paths
  • List.contains() in loops (use Set)
  • Traditional threads for I/O (consider Virtual Threads)
🟢 Low Severity (Nice to Have)
  • Collection initial capacity
  • Minor stream optimizations
  • toArray(new T[0]) vs toArray(new T[size])

When NOT to Optimize

  • Not a hot path - Setup code, config, admin endpoints
  • No measured problem - "Looks slow" is not a measurement
  • Readability suffers - Clear code > micro-optimization
  • Small collections - 100 items processed in microseconds anyway

Analysis Commands

bash
# Find regex in loops (potential compile overhead)
grep -rn "\.matches(\|\.split(" --include="*.java"

# Find potential boxing (Long/Integer as variables)
grep -rn "Long\s\|Integer\s\|Double\s" --include="*.java" | grep "= 0\|+="

# Find ArrayList without capacity
grep -rn "new ArrayList<>()" --include="*.java"

# Find findAll without pagination
grep -rn "findAll()" --include="*.java"

© decebals, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/performance-smell-detection of decebals/claude-code-java.

  • SKILL.md
  • README.md

Open the folder on GitHubat commit 0d98fe9

Compare with similar skills

Performance Smell Detection next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Performance Smell Detection compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Performance Smell Detection this skilldecebals/claude-code-java751—~2.3kAutomated safety check: PassMIT
Creating Description For Gh PRredis/jedis12k—~838Automated safety check: PassMIT
Code Review Skillawesome-skills/code-review-skill2.1k—~2.8kAutomated safety check: NotesMIT
Caffeine Cache Optimization Experimentsben-manes/caffeine18k—~2.6kAutomated safety check: NotesApache-2.0
Coding Standardsapache/shardingsphere21k—~2.2kAutomated safety check: PassApache-2.0
Git History Bug Auditben-manes/caffeine18k—~3.3kAutomated safety check: PassApache-2.0

Similar skills

  • Official

    Generate a clear, concise GitHub PR title and description from the diff between two local git branches, and save it to prDescription.md in the repo root.

    12k GitHub stars~838 tokensUpdated today
    DevelopmentAuto-check passed
  • Code Review Skill

    awesome-skills/code-review-skill

    Provides comprehensive code review guidance for React 19, Vue 3, Angular 17+, Svelte 5, Rust, TypeScript, Java, Java 8, PHP, Ruby, Rails, Python, Django, FastAPI, Go, C/.NET, Kotlin, Swift, Dart…

    2.1k GitHub stars~2.8k tokensUpdated 1 mo ago
    DevelopmentAuto-check: notes
  • Runs controlled JMH experiments on the Caffeine cache to find shared contention and hot-path waste, then reviews correctness and returns a reviewable patch.

    18k GitHub stars~2.6k tokensUpdated today
    DevelopmentAuto-check: notes
  • Coding Standards

    apache/shardingsphere

    Apply Apache ShardingSphere's written coding standards when explicitly requested, or when code-implementation routes task-changed production, test, script, build, generated, or Maven POM artifacts…

    21k GitHub stars~2.2k tokensUpdated today
    DevelopmentAuto-check passed
  • Git History Bug Audit

    ben-manes/caffeine

    Audits a module by walking its git history commit by commit, tracking unresolved issues forward, and reporting the ones that survive to HEAD as findings.

    18k GitHub stars~3.3k tokensUpdated today
    DevelopmentAuto-check passed
  • CI Act Run

    chewiebug/GCViewer

    Run the full build-and-deploy.yaml workflow locally via act + Docker.

    4.6k GitHub stars~2.4k tokensUpdated 3 mo ago
    DevelopmentAuto-check: notes

More from decebals/claude-code-java

All 18 skills in this repo
  • Java Design Patterns Reference

    decebals/claude-code-java

    A practical Java reference for Builder, Factory, Singleton, Strategy, Observer and other patterns, with a table matching problems to patterns.

    751 GitHub starsUsed in 1 repo~4.4k tokens
    Auto-check passed
  • Jpa Patterns

    decebals/claude-code-java

    JPA/Hibernate patterns and common pitfalls (N+1, lazy loading, transactions, queries).

    751 GitHub starsUsed in 1 repo~4k tokens
    Auto-check passed
  • Logging Patterns

    decebals/claude-code-java

    Java logging best practices with SLF4J, structured logging (JSON), and MDC for request tracing.

    751 GitHub starsUsed in 1 repo~3.3k tokens
    Auto-check passed
  • REST API Contract Review

    decebals/claude-code-java

    Reviews REST API design for correct HTTP verbs, versioning, DTO use, consistent responses and backward compatibility before an API change ships.

    751 GitHub stars~2.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Java Architecture Review

    decebals/claude-code-java

    Reviews a Java project's architecture at the macro level: package structure, module boundaries, dependency direction and layering.

    751 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check passed
  • Changelog Generator for Java

    decebals/claude-code-java

    Builds changelog entries from conventional commits in a Java project, after working out whether it uses SemVer, two-part versions or calendar versions.

    751 GitHub stars~2.1k tokensUpdated 1 mo ago
    Auto-check passed

Works with

Categories

Questions about Performance Smell Detection

What does Performance Smell Detection do?

Detect potential code-level performance smells in Java - streams, collections, boxing, regex, object creation. Performance Smell Detection is an agent skill from decebals/claude-code-java. Detect potential code-level performance smells in Java - streams, collections, boxing, regex, object creation.

When should I use Performance Smell Detection?

Performance Smell Detection fits situations like: development work in your project.

How do I install Performance Smell Detection in Claude Code?

Run `npx skills add decebals/claude-code-java --skill performance-smell-detection -a claude-code`. Or copy the skill folder (skills/performance-smell-detection in decebals/claude-code-java) into .claude/skills/performance-smell-detection in your project. Claude Code loads it when a task matches its description.

How do I install Performance Smell Detection in Codex?

Run `npx skills add decebals/claude-code-java --skill performance-smell-detection -a codex`. Or copy the skill folder (skills/performance-smell-detection in decebals/claude-code-java) into .agents/skills/performance-smell-detection in your project. Codex loads it when a task matches its description.

Can I use Performance Smell Detection in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add decebals/claude-code-java --skill performance-smell-detection -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/performance-smell-detection, .gemini/skills/performance-smell-detection, .github/skills/performance-smell-detection and .opencode/skills/performance-smell-detection in your project.

What does Performance Smell Detection need to run?

SKILL.md names no scripts, command-line tools or credentials: Performance Smell Detection is instructions for the agent only.

Does Performance Smell Detection access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Performance Smell Detection safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Performance Smell Detection use?

Performance Smell Detection is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Performance Smell Detection use?

About 2.3k tokens (SKILL.md is roughly 9.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Performance Smell Detection?

Skills that share tags, products or a category with Performance Smell Detection: Creating Description For Gh PR (redis/jedis, 12k stars), Code Review Skill (awesome-skills/code-review-skill, 2.1k stars), Caffeine Cache Optimization Experiments (ben-manes/caffeine, 18k stars) and Coding Standards (apache/shardingsphere, 21k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Performance Smell Detection?

decebals (a GitHub user) maintains it in decebals/claude-code-java, which has 751 GitHub stars. The repository holds 18 skills in this directory. The repository was last updated on September 6, 2026.

Source: decebals/claude-code-java on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.