nullaway
O que ela faz
Esta skill orienta sua IA a corrigir erros do NullAway, uma ferramenta que encontra possíveis valores nulos em código Java. Ela é indicada para desenvolvedores que adicionam ou atualizam anotações de nulidade.
Quando usar
- ✓Quando o NullAway reporta um erro sobre um valor que pode ser nulo.
- ✓Quando você adiciona @NullMarked a um arquivo Java e precisa corrigir os novos avisos.
- ✓Quando você precisa passar um supplier ou um valor observável anulável sem quebrar o código.
Link da skill
https://github.com/chromium/chromium/blob/main/agents/skills/nullaway/SKILL.mdCopie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.
Como usar
O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.
Mensagem pronta para colar
Para Claude Code, Codex ou Cursor: rode na pasta do projeto e a skill fica instalada.
Baixe o SKILL.md e coloque na pasta de skills do seu agente.
Exemplo do que pedir para a IA
“O NullAway está mostrando um erro no meu arquivo Java. Você pode corrigir sem mudar o funcionamento do app?”
5 skills novas por semana. 1 minuto de leitura.
Como funciona
A IA observa como cada valor possivelmente nulo é usado. Depois adiciona uma verificação segura ou uma asserção, escolhendo a opção mais leve que satisfaz o verificador.
Conteúdo técnico (SKILL.md original)
Texto original do autor, em inglês, direto do 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
Perguntas frequentes
O que é o NullAway?
O NullAway é um verificador que procura em código Java lugares onde um valor pode estar vazio, o que pode causar falhas.
A correção vai mudar o comportamento do meu app?
A skill tenta evitar mudanças de comportamento ao migrar código antigo. Ela prefere asserções pequenas a nova lógica.
Isto serve só para código novo?
Não. Ela cobre tanto a migração de código antigo para código com marcação de nulidade quanto a escrita de código novo em arquivos que já usam a marcação.
Detalhes
Descrição original do 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
Popularidade
- Estrelas no GitHub
- 25 mil
- Posição no ranking
- #10062
- Licença
- BSD-3-Clause
- Atualizada em
- 02/11/2026
Comentários
- …
Mais skills deste repositório
fuzzing
25 milAjuda seu agente a escrever testes de fuzzing que alimentam o código com muitas entradas aleatórias para encontrar falhas e bugs em código C++.
gn-deps-debugging
25 milAjuda seu agente a corrigir erros de build causados por dependências ausentes ou incorretas em arquivos de build GN, sem adicionar dependências amplas e desnecessárias.
java-memory-leaks
25 milAjuda seu agente a encontrar e corrigir vazamentos de memória em Java em apps Android, lendo relatórios de vazamento do LeakCanary.
jni-type-conversion
25 milAjuda seu agente a substituir o código manual de conversão de Java para C++ por anotações @JniType mais simples em código Android.
Skills parecidas
diffs
394 milPermite que seu agente gere um diff real e compartilhável das edições, como link de visualização ou arquivo de imagem, em vez de um resumo escrito à mão.
coding-agent
394 milAjuda seu agente a passar um trabalho grande de programação para o Codex, Claude Code ou OpenCode em segundo plano e acompanhar o andamento.
gh-issues
394 milAjuda seu agente a encontrar issues do GitHub, escolher quais resolver e abrir pull requests com correções, acompanhando os comentários de revisão.