About null-safety
A development skill for handling nullability in Spring Boot 3 and Spring Framework 6 projects. It explains annotation conventions, nullable contracts, and mixed Java/Kotlin considerations while warning against assuming Framework 7 defaults.
Key features
- 01Guidance on Spring nullability annotations
- 02Advice for nullable parameters and results
- 03Repository return type contract checks
- 04Java and Kotlin annotation alignment
- 05Gotchas for validation and migration
Use cases
- 01Reviewing nullability in a Boot 3 module
- 02Annotating nullable service or repository APIs
- 03Checking Java and Kotlin nullability settings
- 04Avoiding unintended contract changes
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ rrezartprebreza/ spring-boot-skills --skill null-safetyAfter installing, type/null-safetyin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlexamples/bad-null-contract.javagood-package-info.javaDetails
From the project READMENull Safety (Boot 3 / Framework 6)
Use the nullability model supported by the project. Spring Framework 6 commonly uses
org.springframework.lang.Nullable, @NonNull, and package-level @NonNullApi. JSpecify can be
introduced deliberately, but do not assume Framework 7 migration semantics in a Boot 3 module.
@NonNullApi
package com.example.orders;
import org.springframework.lang.NonNullApi;
Annotate genuine nullable results and parameters with @Nullable. Keep repository return types
explicit, validate external input at boundaries, and use Kotlin compiler settings that match the
annotations when Java and Kotlin are mixed. If the project standardizes JSpecify independently,
apply it consistently at module boundaries and document the chosen checker.
Gotchas
- Agent assumes Framework 7 JSpecify defaults - Boot 3 projects usually use Spring's legacy annotations.
- Agent uses
@NonNullApiwithout importing the package annotation - package metadata must compile and be checked in. - Agent marks every value
@NonNull- establish a package default and annotate only nullable exceptions. - Agent treats annotations as runtime validation - use Bean Validation or explicit checks for input validation.
- Agent changes a repository's nullable contract without updating callers - preserve
Optional, nullable, and empty collection semantics. - Agent mixes JSpecify and Spring annotations without a migration plan - choose one module boundary policy.