$npx -y skills add ducpm2303/claude-java-plugins --skill java-fixDiagnoses and fixes Java compile errors, runtime exceptions, and stack traces. Use when user asks to "fix this error", "this won't compile", "I'm getting an exception", "debug this", or "build is failing".
| 1 | Diagnose the Java error or stack trace I've provided and propose a fix. Be specific — do not give generic advice. |
| 2 | |
| 3 | ## Step 1 — Identify the error type |
| 4 | |
| 5 | **Compile errors (javac / Maven / Gradle output):** |
| 6 | - `cannot find symbol` → missing import, misspelled name, or wrong scope |
| 7 | - `incompatible types` → type mismatch; check generics, autoboxing, widening |
| 8 | - `method X is not applicable` → wrong number or types of arguments |
| 9 | - `variable X might not have been initialized` → missing initialisation on all code paths |
| 10 | - `reached end of file while parsing` → unmatched `{` or `}` |
| 11 | - `class X is public, should be declared in a file named X.java` → filename mismatch |
| 12 | |
| 13 | **Runtime exceptions (stack traces):** |
| 14 | - `NullPointerException` → identify the line; determine which reference is null; suggest a null check or Optional |
| 15 | - `ClassCastException` → show the actual vs expected type; fix the cast or use instanceof first |
| 16 | - `ArrayIndexOutOfBoundsException` → check loop bounds and array length |
| 17 | - `StackOverflowError` → identify the recursive call; check base case |
| 18 | - `ConcurrentModificationException` → iterating and modifying a collection simultaneously; suggest iterator.remove() or a copy |
| 19 | - `IllegalArgumentException` / `IllegalStateException` → read the message; check the API contract |
| 20 | |
| 21 | ## Step 2 — Find the root cause |
| 22 | Read the full error message carefully. The root cause is usually the last "Caused by:" in a stack trace. Show the user: |
| 23 | 1. The exact line causing the error (if visible in the stack trace) |
| 24 | 2. Why that line fails |
| 25 | |
| 26 | ## Step 3 — Propose the fix |
| 27 | Show: |
| 28 | 1. The problematic code (before) |
| 29 | 2. The corrected code (after) |
| 30 | 3. One sentence explaining what was wrong |
| 31 | |
| 32 | If the fix requires reading a file not currently shown, ask for it: "Can you share the contents of `ClassName.java`? I need to see [specific thing]." |
| 33 | |
| 34 | ## Step 4 — Prevent recurrence |
| 35 | Add one short note on how to avoid this class of error in the future (e.g., "Use `Objects.requireNonNull()` at method entry to catch nulls early"). |
| 36 | |
| 37 | ## Next Steps |
| 38 | After applying the fix: |
| 39 | - Suggest running the build to verify: `mvn compile -q` or `./gradlew build -q` |
| 40 | - If the fix changed business logic → suggest running `/java-test` to verify behaviour is preserved |
| 41 | - If the root cause was a design problem → suggest running `/java-review` on the surrounding code |