nullaway
Qué hace
Esta skill guía a tu IA para arreglar errores de NullAway, una herramienta que encuentra posibles valores nulos en código Java. Está pensada para desarrolladores que añaden o actualizan anotaciones de nulos.
Cuándo usarla
- ✓Cuando NullAway informa de un error sobre un valor que podría ser nulo.
- ✓Cuando añades @NullMarked a un archivo Java y necesitas arreglar las nuevas advertencias.
- ✓Cuando necesitas pasar un proveedor o un valor observable que puede ser nulo sin romper el código.
Link de la skill
https://github.com/chromium/chromium/blob/main/agents/skills/nullaway/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“NullAway muestra un error en mi archivo Java. ¿Puedes arreglarlo sin cambiar cómo funciona la app?”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
La IA mira cómo se usa cada valor que podría ser nulo. Después añade una comprobación segura o una aserción, eligiendo la opción más ligera que satisface al verificador.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
Core Principles
1. Migration to @NullMarked vs New Code
The approach differs significantly depending on whether you are migrating
existing code to @NullMarked or writing new code in an already @NullMarked
context:
- Migration to
@NullMarked:- Goal: Satisfy the static analyzer while minimizing functional changes to avoid regressions.
- Practice: Use
NullUtil.assumeNonNull()when dereferencing immediately to satisfy the analyzer without runtime overhead. Useassertwhen storing or returning values. Useifguards occasionally if it helps avoid assertions, but avoid changing the logic.
- New Code (and modifying already
@NullMarkedcode):- Goal: Build robust, null-safe components from the ground up.
- Practice: Be more liberal with
asserts to enforce contracts. Rely on correct annotations (or their absence for implicit@NonNull) and only use null guards for@Nullablevalues.assumeNonNull()should generally not be used for new code.
2. No Functional Changes (For Migration)
- Rule: When migrating existing code, avoid adding new throwing runtime checks where they did not exist before, unless guided by the rules below.
3. assumeNonNull vs assert != null
The choice between assumeNonNull and Java assert depends on how the value is
used:
- Dereferencing
@Nullablevalues immediately: UseNullUtil.assumeNonNull(x).- Example:
var value = mSupplier.get(); assumeNonNull(value); value.doSomething(); - Why: If it is null, it will NPE on the dereference anyway.
assumeNonNullis a no-op that satisfies the analyzer without adding redundant runtime checks. - Style Rule:
assumeNonNull()should be on a separate line, almost always, rather than used inline. - Note: This rule is primarily for migrations to avoid functional
changes. For new code, rely on correct annotations and avoid
assumeNonNull().
- Example:
- Passing
@Nullablevalues to non-null parameters: First, look into the call tree of the receiver class and see if that parameter should be annotated as@Nullableor not. If it can natively handle null, update the method signature instead of adding an assertion. If it strictly requires a non-null value, THEN you MUST use a Javaassert x != null;on a preceding line before passing or storing it.[!CAUTION] NEVER use
assumeNonNull(x)to pass a@Nullablevalue to a non-null parameter or to return it from a non-nullable method. This is STRICTLY FORBIDDEN. You MUST use a Javaasserton a preceding line to add a runtime check.- Bad Example:
mReceiver.setSomething(assumeNonNull(nullableValue)); - Good Example:
assert nullableValue != null; mReceiver.setSomething(nullableValue);
- Bad Example:
- Returning
@Nullablevalues from non-nullable methods: First, consider if the method's return type can be safely updated to@Nullable. If it cannot (e.g., because it implements an interface or strictly enforces a non-null contract), you MUST use a Javaassert x != null;on a preceding line before returning the value. UsingassumeNonNull(x)inline within a return statement is strictly forbidden.- Bad Example:
return assumeNonNull(nullableValue); - Good Example:
assert nullableValue != null; return nullableValue;
- Bad Example:
- Why: Asserts add a runtime check (active in tests/debug) which is an
acceptable functional change. We rely on instrumentation tests to validate
these changes.
- Deep Investigation Rule: Before asserting or assuming non-null for a
passed value, investigate the call tree. If the method being called can be
updated to consider the parameter
@Nullable, prefer updating the method signature over adding an assertion. - Warning: Be careful with
assert value != nullonSupplier.get()during initialization. If the supplier value is set LATER (as is common with UI wiring), the assert might fail immediately during construction. In such cases, the getter should return@Nullableand callers should handle it, rather than asserting non-null immediately.
- Deep Investigation Rule: Before asserting or assuming non-null for a
passed value, investigate the call tree. If the method being called can be
updated to consider the parameter
4. Handling Suppliers and Generics
- Problem: Passing a
Supplier<@Nullable T>to a constructor that expectsSupplier<T>(non-nullable), or vice
Preguntas frecuentes
¿Qué es NullAway?
Es un verificador que busca en código Java los lugares donde un valor podría estar vacío, lo que puede causar fallos.
¿El arreglo cambiará el comportamiento de mi app?
La skill intenta evitar cambios de comportamiento al migrar código antiguo. Prefiere aserciones pequeñas frente a nueva lógica.
¿Es solo para código nuevo?
No. Cubre tanto la migración de código antiguo a código con marcas de nulos como la escritura de código nuevo en archivos que ya usan esas marcas.
Detalles
Descripción original del autor
Guide for resolving NullAway static analysis errors. Best practices for: - Passing ObservableSupplier/Supplier<@Nullable T> - Dereferencing potentially @Nullable values - Adding @NullMarked to Java code
repo: chromium/chromium
Popularidad
- Estrellas en GitHub
- 25 mil
- Posición en el ranking
- #10062
- Licencia
- BSD-3-Clause
- Actualizada
- 2/11/2026
Comentarios
- …
Más skills de este repositorio
fuzzing
25 milAyuda a tu agente a escribir pruebas de fuzzing que introducen muchas entradas aleatorias en el código para encontrar fallos y errores en C++.
gn-deps-debugging
25 milAyuda a tu agente a arreglar errores de compilación por dependencias que faltan o son incorrectas en archivos GN, sin añadir dependencias amplias.
java-memory-leaks
25 milAyuda a tu agente a encontrar y arreglar fugas de memoria en Java de apps Android, leyendo los informes de fugas de LeakCanary.
jni-type-conversion
25 milAyuda a tu agente a reemplazar código manual de conversión de Java a C++ por anotaciones @JniType más simples en código Android.
Skills parecidas
diffs
394 milPermite que tu agente genere un diff real y compartible de los cambios, como enlace de visualización o archivo de imagen, en lugar de un resumen escrito a mano.
coding-agent
394 milAyuda a tu agente a pasar un trabajo de programación grande a Codex, Claude Code u OpenCode como trabajador en segundo plano, y después revisar su progreso.
gh-issues
394 milAyuda a tu agente a encontrar incidencias de GitHub, elegir cuáles trabajar y abrir pull requests con correcciones, incluido el seguimiento de los comentarios de revisión.