126-java-exception-handling — Claude Code skill: install guide
126-java-exception-handling is a Claude Code skill for Java exception handling. It activates on requests to review error types, resource cleanup, or failure propagation.
Apache-2.0 307 installs ★ 465 updated 2026-10-21
npx skills add jabrena/plinth --skill 126-java-exception-handling -a claude-codeWhat 126-java-exception-handling does
The skill guides changes to Java error handling, including choosing specific exception classes, closing resources with try-with-resources, and retaining context when wrapping an error. It also covers safe exception messages, thread interruption, logging, timeouts, retries for idempotent operations, and failures in asynchronous code.
Before editing, the agent runs ./mvnw compile or mvn compile and stops if compilation fails. It then reads references/126-java-exception-handling.md, applies relevant guidance, and runs ./mvnw clean verify or mvn clean verify to check the result.
What it helps with
- replace overly broad exception types with specific ones
- close resources using try-with-resources
- retain the cause when translating an exception
- review interruption handling and async failure propagation
Example prompts for the agent
- Review the Java exception handling and suggest suitable changes.
- Refactor this code to use try-with-resources.
- Preserve the original error context when wrapping this exception.
How to install 126-java-exception-handling
1Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 126-java-exception-handling -a claude-code2Manually: put the files in place
~/.claude/skills/126-java-exception-handling/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/126-java-exception-handling/
1Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 126-java-exception-handling -a codex2Manually: put the files in place
.agents/skills/126-java-exception-handling/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 126-java-exception-handling -a cursor2Manually: put the files in place
.cursor/skills/126-java-exception-handling/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install jabrena/plinth skills/126-java-exception-handling2Manually: put the files in place
.github/skills/126-java-exception-handling/SKILL.md1Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 126-java-exception-handling -a gemini-cli2Platform CLI
gemini skills install https://github.com/jabrena/plinth --path skills/126-java-exception-handlingManually: put the files in place
.devin/skills/126-java-exception-handling/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add jabrena/plinth --skill 126-java-exception-handling -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about 126-java-exception-handling
How do I install 126-java-exception-handling in Claude Code?
Run npx skills add jabrena/plinth --skill 126-java-exception-handling -a claude-code. The skill file is placed at ~/.claude/skills/126-java-exception-handling/SKILL.md.
What does 126-java-exception-handling do?
It guides Java exception-handling changes, from selecting exception classes and cleaning up resources to logging and passing failures across API boundaries.
What does 126-java-exception-handling need to run?
The project must compile before edits; the skill runs ./mvnw compile or mvn compile. After changes, it checks the build with ./mvnw clean verify or mvn clean verify.
Source text
SKILL.md · Apache-2.0
--- name: 126-java-exception-handling description: Use when you need to apply Java exception handling best practices — including using specific exception types, managing resources with try-with-resources, securing exception messages, preserving error context via exception chaining, validating inputs early with fail-fast principles, handling thread interruption correctly, documenting exceptions with @throws, enforcing logging policy, translating exceptions at API boundaries, managing retries and idempotency, enforcing timeouts, attaching suppressed exceptions, and propagating failures in async/reactive code. This should trigger for requests such as Exception handling; Use try-with-resources in Java code; Create exception chaining in Java code; Apply fail-fast validation in Java code; Review Java exception taxonomy and propagation. Part of Plinth Toolkit license: Apache-2.0 metadata: author: Juan Antonio Breña Moral version: 0.19.0 --- # Java Exception Handling Guidelines Identify and apply robust Java exception handling practices to improve error clarity, security, debuggability, and system reliability. **What is covered in this Skill?** - Specific exception types instead of generic `Exception`/`RuntimeException` - try-with-resources for automatic resource cleanup - Secure exception messages that avoid information leakage - Exception chaining to preserve full error context - Early input validation with `IllegalArgumentException`/`NullPointerException` - `InterruptedException` handling with interrupted-status restoration - `@throws` JavaDoc documentation, fail-fast principle - Structured logging with correlation IDs, avoiding log-and-throw duplication - API boundary translation via centralized exception mappers - Bounded retry with backoff for idempotent operations only - Timeout enforcement with deadline propagation - `Throwable#addSuppressed` for secondary cleanup failures - Never catching `Throwable`/`Error` - Observability via error metrics - Failure propagation in async `CompletionStage` code **Scope:** The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples. ## Constraints Before applying any exception handling changes, ensure the project compiles. If compilation fails, stop immediately — do not proceed until resolved. After applying improvements, run full verification. - **MANDATORY**: Run `./mvnw compile` or `mvn compile` before applying any changes - **SAFETY**: If compilation fails, stop immediately — do not proceed until the project is in a valid state - **VERIFY**: Run `./mvnw clean verify` or `mvn clean verify` after applying improvements - **BEFORE APPLYING**: Read the reference for detailed good/bad examples, constraints, and safeguards for each exception handling pattern ## When to use this skill - Exception handling - Use try-with-resources in Java code - Create exception chaining in Java code - Apply fail-fast validation in Java code - Review Java exception taxonomy and propagation ## Workflow 1. **Compile project before exception-handling changes** Run `./mvnw compile` or `mvn compile` and stop immediately if compilation fails. 2. **Read exception-handling reference** Read `references/126-java-exception-handling.md` and identify applicable failure-handling and observability improvements. 3. **Apply exception-handling improvements** Refactor to specific exceptions, safe resource handling, error translation, and consistent logging patterns. 4. **Verify with full build** Run `./mvnw clean verify` or `mvn clean verify` after applying improvements. ## Reference For detailed guidance, examples, and constraints, see [references/126-java-exception-handling.md](references/126-java-exception-handling.md).
© Juan Antonio Breña Moral · Apache-2.0 · jabrena/plinth