Skip to content
Back to skills

Null Safety

ASecurity

Use when annotating nullability in Spring Boot 4 / Spring Framework 7, migrating to JSpecify, integrating Kotlin, or enabling build-time null checks with NullAway.

  • 272 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 6, 2026
ai-agentsgojavakotlinspring

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 6, 2026

npx -y skills add rrezartprebreza/spring-boot-skills --skill null-safety --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Null Safety?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Null Safety
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/rrezartprebreza-null-safety-spring-boot-skills/badge)](https://www.skillsdirectory.com/skills/rrezartprebreza-null-safety-spring-boot-skills)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: null-safety
description: >
  Use when annotating nullability in Spring Boot 4 / Spring Framework 7, migrating to JSpecify,
  integrating Kotlin, or enabling build-time null checks with NullAway.
---

# Null Safety with JSpecify (Boot 4)

Spring Framework 7 adopts JSpecify for nullability. Use `org.jspecify.annotations` for new code
and migrate away from the older Spring nullability annotations at module boundaries.

## Mark packages and annotate exceptions

```java
@NullMarked
package com.example.orders;

import org.jspecify.annotations.NullMarked;
```

Inside a null-marked package, types are non-null by default. Annotate only genuine exceptions:

```java
@Nullable
Order findActive(String customerEmail) { ... }

List<@Nullable String> namesWithGaps; // non-null list, nullable elements
@Nullable List<String> maybeNoList;   // nullable list, non-null elements
```

Use `Object @Nullable []` for a nullable array and `@Nullable Object[]` for a non-null array whose
elements may be null. Add the JSpecify dependency through the Boot dependency management.

JSpecify is metadata. IntelliJ can inspect it, while NullAway with `JSpecifyMode=true` can enforce
the contract during compilation. Kotlin consumes the annotations as real nullability.

## Gotchas

- Agent uses `org.springframework.lang.Nullable` in new Framework 7 code - prefer JSpecify.
- Agent annotates every parameter with `@NonNull` - use package-level `@NullMarked` and mark exceptions.
- Agent writes `@Nullable List<String>` for nullable elements - use `List<@Nullable String>`.
- Agent puts `@Nullable` on the wrong side of an array type - distinguish nullable arrays from nullable elements.
- Agent expects annotations alone to fail the build - add NullAway or enable IDE inspections.
- Agent forgets `package-info.java` - without `@NullMarked`, most checks remain unknown.
- Agent mixes JSpecify and legacy Spring annotations in one module - migrate the module consistently.

Files in this skill

  • SKILL.md1.9 KB
  • agents/openai.yaml185 B
  • examples/bad-null-contract.java123 B
  • examples/good-package-info.java85 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.