csharp-nullable-reference-types

csharp-nullable-reference-types is a skill for Claude Code, Codex from Aaronontheweb/dotnet-skills. It costs 126 tokens per session (2,526 once invoked), scanned A, original, MIT.

Guidance for using C# nullable reference types, which let the compiler track whether a reference may contain no value.

In plain words
What is it for?
Use it when adding nullability checks to new or existing C# code, designing APIs, or wrapping older libraries that do not describe nullability.
Why use it?
It makes missing-value expectations explicit and helps catch possible null-reference errors before the program runs.

Skill for Claude CodeCodex

Part of the dotnet-skills plugin — 36 skills, 6 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/aaronontheweb/dotnet-skills/csharp-nullable-reference-types
Any agent
npx skills add Aaronontheweb/dotnet-skills --skill csharp-nullable-reference-types
Clone the repo
git clone --depth 1 https://github.com/Aaronontheweb/dotnet-skills

Made for: Claude Code, Codex.

Or install dotnet-skills, the plugin that ships this one along with the rest of its 36 skills, 6 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for csharp-nullable-reference-types

README.md
[![agentmods](https://agentmods.dev/badge/skills/aaronontheweb/dotnet-skills/csharp-nullable-reference-types.svg)](https://agentmods.dev/skills/aaronontheweb/dotnet-skills/csharp-nullable-reference-types)
Your own site
<a href="https://agentmods.dev/skills/aaronontheweb/dotnet-skills/csharp-nullable-reference-types"><img src="https://agentmods.dev/badge/skills/aaronontheweb/dotnet-skills/csharp-nullable-reference-types.svg" alt="Measured on agentmods" height="20"></a>
Per session 126 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,526 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00126 $0.02526
Opus 5 $0.00063 $0.01263
Sonnet 5 $0.00025 $0.00505
Haiku 4.5 $0.00013 $0.00253

Measured 4d ago against content hash 62c64b253f51, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

csharp-nullable-reference-types scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/csharp-nullable-reference-types/SKILL.md · 199 lines

How it starts

The opening of the file, as written. The whole thing — 199 lines — stays where its author put it; the contents beside it link to each section on GitHub.

C# Nullable Reference Types

When to Use

  • Introducing nullable reference types (NRT) into a codebase that has not yet adopted them
  • Writing or refactoring C# code that uses T? / nullable annotations
  • Annotating APIs with System.Diagnostics.CodeAnalysis nullable attributes
  • Designing public/internal APIs where nullability contracts matter
  • Wrapping unannotated or legacy APIs so downstream callers still benefit from NRT
  • Reviewing code for correct null-state analysis, guard helpers, and the field keyword

Core Goals

  • Prevent NullReferenceException at runtime by making null intent explicit in signatures.
  • Express contracts the type system cannot represent directly using the official nullable attributes.
  • Adopt NRT incrementally in legacy codebases without a big-bang rewrite.

Core Nullability Model

Non-nullable vs nullable

  • string — non-nullable reference. The compiler assumes instances are never null; assigning null or a maybe-null value produces a warning.
  • string? — nullable reference. The variable may be null; the compiler requires a null check before dereference.
string name = "Alice";
name = null;          // Warning: assigning null to non-nullable.

string? nickname = null;
Console.WriteLine(nickname.Length); // Warning: possible null dereference.

Null-state analysis (flow)

The compiler tracks whether a reference is definitely non-null or maybe null. Null checks and assignments update this state.

string? message = GetMessageOrNull();

if (message != null)
{
    // message is definitely non-null in this block.
    Console.WriteLine(message.Length);
}

// Outside the if, message is maybe null again.

Introduce explicit null checks (if (x != null), is not null, pattern matching) before dereferencing nullable values. Narrow nullability early and keep the non-null state alive. Null-conditional assignment (C# 14) lets you write customer?.Order = CreateOrder(); — the right side is evaluated only when the receiver is non-null.

Read the full file on GitHub · 199 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 199 lines · 126 tokens per session scan A 62c64b253f51

Subscribe to this mod's changes

csharp-nullable-reference-types is a skill published in the GitHub repository Aaronontheweb/dotnet-skills (1,135 stars, last pushed 27d ago), licensed MIT. It adds 126 tokens to every session and 2,526 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

build-and-test

How to build and test .NET projects in the Agent Framework repository. Use this when verifying or testing changes.

microsoft/agent-framework · 26 tokens

agui-dotnet-streaming-chat

Get started with the AG-UI .NET SDK: bootstrap and run your first streaming-chat app (client + server) with the AG-UI .NET NuGet packages (AGUI.Client, AGUI.Server, AGUI.Formatting, AGUI.Abstractions). USE FOR: which packages to install and how to wire them; constructing an AGUIChatClient against an endpoint and…

ag-ui-protocol/ag-ui · 223 tokens

agui-dotnet-reasoning

Surface a reasoning/thinking model's intermediate thoughts separately from its final answer with the AG-UI .NET SDK — so a client can show the agent "thinking" before it responds, and handle that reasoning trace correctly across turns. USE FOR: distinguishing the model's reasoning trace from its answer on the client…

ag-ui-protocol/ag-ui · 161 tokens

mpg-migration

Handles Azure SDK for .NET management-plane migrations from AutoRest/Swagger to TypeSpec; use for MPG, mgmt migration, or Azure.ResourceManager. migration requests.

Azure/azure-sdk-for-net · 39 tokens

convert-blazor-server-to-webapp

Guides conversion of a pre-.NET 8 Blazor Server app into a .NET 8+ Blazor Web App. USE FOR: migrating apps that use AddServerSideBlazor and MapBlazorHub to the AddRazorComponents/MapRazorComponents model, converting Host.cshtml to an App.razor root component, replacing blazor.server.js with blazor.web.js, migrating…

dotnet/skills · 176 tokens

maui-data-binding

Guidance for .NET MAUI XAML and C# data bindings — compiled bindings, INotifyPropertyChanged / ObservableObject, value converters, binding modes, multi-binding, relative bindings, fallbacks, and MVVM best practices. USE FOR: setting up compiled bindings with x:DataType, implementing INotifyPropertyChanged or…

dotnet/skills · 180 tokens