---
name: Null Safety
slug: null-safety
category: Quality
description: Null Safety guides nullability annotations in Spring Boot 3 and Spring Framework 6 code. Use it for Java/Kotlin modules, repository contracts, and mixed annotation strategies without assuming Framework 7 JSpecify defaults.
github: "https://github.com/rrezartprebreza/spring-boot-skills/tree/main/skills/spring-boot-3/null-safety"
language: Java
stars: 247
forks: 39
install: "npx degit https://github.com/rrezartprebreza/spring-boot-skills/tree/main/skills/spring-boot-3/null-safety ~/.claude/skills/null-safety"
installs_to: ~/.claude/skills/null-safety
source_path: skills/spring-boot-3/null-safety/SKILL.md
collection_size: 24
category_size: 1418
collection_url: "https://dirskills.com/collections/rrezartprebreza/spring-boot-skills"
added: 2026-09-02T05:21:23.066Z
last_synced: 2026-09-02T05:21:23.066Z
canonical_url: "https://dirskills.com/skills/null-safety"
---

# Null Safety

Null Safety guides nullability annotations in Spring Boot 3 and Spring Framework 6 code. Use it for Java/Kotlin modules, repository contracts, and mixed annotation strategies without assuming Framework 7 JSpecify defaults.

**Install:**

```bash
npx degit https://github.com/rrezartprebreza/spring-boot-skills/tree/main/skills/spring-boot-3/null-safety ~/.claude/skills/null-safety
```

## README

# Null 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.

```java
@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 `@NonNullApi` without 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.
