migrate-nullable-references
Enable nullable reference types in a C# project and systematically resolve all warnings. USE FOR: adopting NRTs in existing codebases, file-by-file or project-wide migration, fixing CS8602/CS8618/CS86xx warnings, annotating APIs for nullability, cleaning up null-forgiving operators, upgrading dependencies with new nullable annotations. DO NOT USE FOR: projects already fully migrated with zero warnings (unless auditing suppressions), fixing a handful of nullable warnings in code that already has NRTs enabled, suppressing warnings without fixing them, C# 7.3 or earlier projects.
npx skills add dotnet/skills --skill migrate-nullable-references --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Instructs an AI coding agent to perform a nullable reference type (NRT) migration on an existing C# project or solution. The aim is to switch to <Nullable>enable</Nullable> (or manage via a staged approach), systematically resolve CS8602/CS8618/CS86xx warnings, annotate public APIs for nullability, clean up null-forgiving operators, and adapt dependencies with new nullable annotations. It supports both file-by-file and project-wide migrations and outlines a commit strategy that creates discrete, reviewable changes across several steps.
How it works
- The skill targets enabling NRTs in an existing codebase and requires generating a project (or solution) with <Nullable>enable</Nullable>, zero nullable warnings, and correctly annotated public APIs.
- It is used when enabling NRTs in an existing project, resolving dereference warnings, annotating declarations, applying nullable attributes, and cleaning up suppressions (Steps 2–6).
- It prescribes a step-by-step workflow with a strong emphasis on not changing runtime behavior: only metadata changes such as nullable annotations, NotNullWhen attributes, and nullable directives are allowed; any latent runtime bugs discovered should be deferred with TODO comments for separate fixes.
- It defines a commit strategy: commit after enabling Nullable, after fixing dereference warnings, after annotating declarations, after applying nullable attributes, and after cleaning up suppressions.
- It provides guidance on how to handle build and readiness checks, including language/framework suitability checks (C# 8.0+ and compatible targets), and whether to proceed based on existing Nullable and warnings state.
- It includes detailed guidance for handling common dereference warnings (CS8602, CS8600, CS8603, CS8604) and explicit rules about when to use nullable markers, null-forgiving operators, or guard checks.
When to use it
- Enabling nullable reference types in an existing C# project or solution.
- Systematically resolving CS86xx nullable warnings after enabling NRTs.
- Annotating a library’s public API surface for accurate nullability information.
- Upgrading a dependency that introduces new nullable annotations and warnings.
- Analyzing suppressions in a codebase with NRTs to determine possible removals.
What it can touch
- The policy discusses touching project files to add <Nullable>enable</Nullable> (or <Nullable>warnings</Nullable> during staged strategies).
- It covers annotations on public API surface and various code declarations to reflect intended nullability (e.g., adding ?, NotNullWhen, and related metadata-only changes).
- It references commands and tools for readiness checks and builds but the concrete touched items are primarily code entities and project properties as part of the migration process.
Caveats
- Runtime behavior must not be altered; changes are metadata-only where possible (nullable annotations, directives, and certain attributes).
- If a latent bug is discovered during migration, the recommended action is to add a TODO comment suggesting a separate fix (e.g., ArgumentNullException.ThrowIfNull) rather than addressing it inline in this migration step.
- The workflow emphasizes committing at natural boundaries and starting with core types to minimize cascading warnings.
- It cautions against enabling NRTs on projects that target C# 7.3 or earlier and outlines what to do if language/framework requirements are not met.
# Nullable Reference Migration Enable C# nullable reference types (NRTs) in an existing codebase and systematically resolve all warnings. The outcome is a project (or solution) with `<Nullable>enable</Nullable>`, zero nullable warnings, and accurately annotated public API surfaces — giving both the compiler and consumers reliable nullability information. ## When to Use - Enabling nullable reference types in an existing C# project or solution - Systematically resolving CS86xx nullable warnings after enabling the feature - Annotating a library's public API surface so consumers get accurate nullability information - Upgrading a dependency that has added nullable annotations and new warnings appear - Analyzing suppressions in a code base that has already enabled NRTs to determine whether they can be removed ## When Not to Use - The project already has `<Nullable>enable</Nullable>` and zero warnings — the migration is done unless the user wants to re-examine suppressions with a view to removing unnecessary ones (see Step 6) - The user only wants to suppress warnings without fixing them (recommend against this) - The code targets C# 7.3 or earlier, which does not support nullable referen
- When to Use
- When Not to Use
- Inputs
- Workflow
- Step 1: Evaluate readiness
- Step 2: Choose a rollout strategy
- Step 3: Fix dereference warnings
- Step 4: Annotate declarations
- Step 5: Apply nullable attributes for advanced scenarios
- Step 6: Clean up suppressions
- Step 7: Validate
- Validation
- Code review checklist
- Breaking Changes from NRT Annotations (Libraries)
What does the migrate-nullable-references skill do?
Enable nullable reference types in a C# project and systematically resolve all warnings. USE FOR: adopting NRTs in existing codebases, file-by-file or project-wide migration, fixing CS8602/CS8618/CS86xx warnings, annotating APIs for nullability, cleaning up null-forgiving operators, upgrading dependencies with new nullable annotations. DO NOT USE FOR: projects already fully migrated with zero warnings (unless auditing suppressions), fixing a handful of nullable warnings in code that already has NRTs enabled, suppressing warnings without fixing them, C# 7.3 or earlier projects.
How do I install it?
Run `npx skills add dotnet/skills --skill migrate-nullable-references --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From dotnet/skills, a repository with 4,927 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
