$npx -y skills add ducpm2303/claude-java-plugins --skill java-reviewReviews Java code for bugs, naming issues, code smells, and version-appropriate idioms. Use when user asks to "review this code", "check my Java", "look at this class", "find issues in", "code review", "what's wrong with this", or "review this file".
| 1 | Review the Java code I've selected or provided. Follow these steps: |
| 2 | |
| 3 | ## Step 1 — Detect Java version |
| 4 | Check the project for `pom.xml` (look for `<java.version>` or `<maven.compiler.source>`) or `build.gradle` (look for `sourceCompatibility`). If not found, ask: "What Java version are you targeting? (8, 11, 17, 21, or other)" |
| 5 | |
| 6 | ## Step 2 — Review for bugs and correctness |
| 7 | - **Null safety:** flag unguarded dereferences; suggest `Optional<T>` (Java 8+) for values that may be absent |
| 8 | - **Resource leaks:** flag unclosed `InputStream`, `Connection`, `PreparedStatement`; suggest try-with-resources |
| 9 | - **equals/hashCode:** if one is overridden without the other, flag it |
| 10 | - **Collection mutation:** flag modification of a collection while iterating over it |
| 11 | - **Thread safety:** flag shared mutable fields accessed from multiple threads without synchronization |
| 12 | - **Off-by-one:** review loop bounds and index access |
| 13 | |
| 14 | ## Step 3 — Review naming and style |
| 15 | - Classes/interfaces: must be `PascalCase` |
| 16 | - Methods/variables: must be `camelCase` |
| 17 | - Constants (static final): must be `SCREAMING_SNAKE_CASE` |
| 18 | - Flag single-letter variable names outside of loop counters (`i`, `j`, `k`) |
| 19 | - Flag abbreviations that reduce clarity (e.g., `usr` → `user`, `mgr` → `manager`) |
| 20 | |
| 21 | ## Step 4 — Review Java idioms (version-aware) |
| 22 | For each suggestion involving a version-gated feature, state: "Requires Java X+" |
| 23 | - Java 8+: suggest streams/lambdas over verbose imperative loops where clarity improves |
| 24 | - Java 8+: suggest try-with-resources for `Closeable` resources |
| 25 | - Java 10+: suggest `var` where the type is obvious from the right-hand side |
| 26 | - Java 16+: suggest records for classes that are pure data holders with no behaviour |
| 27 | - Java 17+: suggest sealed classes for fixed hierarchies; pattern matching for `instanceof` chains |
| 28 | |
| 29 | ## Step 5 — Review code smells |
| 30 | - Methods longer than 20 lines: suggest extracting to named helper methods |
| 31 | - Classes with more than one clear responsibility: suggest splitting |
| 32 | - Magic numbers/strings: suggest named constants |
| 33 | - Deep nesting (more than 3 levels): suggest early returns or extraction |
| 34 | |
| 35 | ## Output format |
| 36 | Respond with: |
| 37 | 1. **Summary** — 1–2 sentences overall assessment |
| 38 | 2. **Issues** — grouped by severity: |
| 39 | - 🔴 **Critical** (bugs, resource leaks, thread safety) |
| 40 | - 🟡 **Warning** (naming, missing equals/hashCode, raw types) |
| 41 | - 🔵 **Suggestion** (idiom improvements, version-gated enhancements) |
| 42 | 3. **Strengths** — what is done well (at least one observation) |
| 43 | |
| 44 | Be concise. Each issue: one sentence description + one-line fix example. |
| 45 | |
| 46 | ## Next Steps |
| 47 | After completing this review, offer these follow-up actions based on findings: |
| 48 | - If structural issues found (long methods, god classes) → suggest running `/java-refactor` |
| 49 | - If missing or inadequate tests found → suggest running `/java-test` |
| 50 | - If security issues found (SQL concat, hardcoded secrets, weak crypto) → suggest delegating to the `java-security-reviewer` agent |
| 51 | - If performance issues found (N+1, unbounded queries, String concatenation in loops) → suggest delegating to the `java-performance-reviewer` agent |
| 52 | - If Javadoc is missing on public API → suggest running `/java-docs` |