Use when you need to apply functional exception handling best practices in Java — including replacing exception overuse with Optional and VAVR Either types, designing error type hierarchies using sealed classes and enums, implementing monadic error composition pipelines, establishing functional control flow patterns, and reserving exceptions only for truly exceptional system-level failures. This should trigger for requests such as Improve the code with Functional Exception Handling; Apply Functi
SkillScore77Maintained
Automatic
◆Coding pack
Last verified 8/20/2026
What it changes
Passed 15 of 19 test cases with the skill, and 13 of 19 without it.
Without skill68%
With skill77%
Checks it passed that the model alone missed
Runs Maven clean verify after applying code changes.
Specifies adding the SLF4J logging dependency to pom.xml.
Uses VAVR Validation to accumulate multiple validation failures.
3 fixed14 passed either way4 still failing1 broke
Pass-rate lift
+9 pp
Tokens
+3%
Agent turns
0%
Response time
-30%
Model gemini-3.6-flashMeasured 8/20/2026v117 of 22 cases passed with skill · 19 comparable
Tokens, turns and time describe resource use, not a dollar price.
See it in action
One of 3 test cases the skill fixed. Same model, same prompt, with and without the skill.
1 of 3
Prompt
After refactoring business logic in `AccountService.java` to use functional error handling with VAVR `Either`, what Maven command should be executed to verify complete compilation and test execution?
What was checked, without and with the skill
Checked
Without skill
With skill
Runs Maven clean verify after applying code changes.
Missed
Passed
case-12 · gemini-3.6-flash · 8/20/2026 · answers are capped and redacted
What's inside
The instructions your model reads when the skill loads.
SKILL.md61 lines2 files
Java Functional Exception handling Best Practices
Identify and apply functional exception handling best practices in Java to improve error clarity, maintainability, and performance by eliminating exception overuse in favour of monadic error types.
What is covered in this Skill?
Optional<T> for nullable values over throwing NullPointerException or NotFoundException
VAVR Either<L,R> for predictable business-logic failures
CompletableFuture<T> for async error handling
Sealed classes and records for rich error type hierarchies with exhaustive pattern matching
Enum-based error types for simple failure cases
Functional composition: flatMap/map/peek/peekLeft for chaining operations that can fail
Structured logging: warn/info for business failures, error for system failures
Checked vs unchecked exception discipline
Exception chaining with full causal context when exceptions are unavoidable
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 functional exception handling changes, ensure the project validates. When introducing Either types, confirm the VAVR dependency (io.vavr:vavr) and SLF4J are present.
MANDATORY: Run ./mvnw validate or mvn validate before applying any changes
SAFETY: If validation fails, stop immediately — do not proceed until the project is in a valid state
DEPENDENCY: When introducing Either types, confirm VAVR (io.vavr:vavr) and SLF4J are present
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 functional exception handling pattern
When to use this skill
Improve the code with Functional Exception Handling
Apply Functional Exception Handling
Refactor the code with Functional Exception Handling
Model Java errors with Result or Either types
Replace exception-heavy flows with functional error handling
Workflow
Validate project before functional-exception changes
Use when you need to set up JMeter performance testing for a Java project — including creating the run-jmeter.sh script from the exact template, configuring load tests with loops, threads, and ramp-up, or running performance tests from the project root with custom or default settings. This should trigger for requests such as Improve the code with JMeter performance testing; Apply JMeter performance testing; Refactor the code with JMeter performance testing; Add JMeter support; Create a JMeter te