Tooluck logoTooluck
SKILL.md

csharp-nullable-reference-types

Agent skill fromAaronontheweb/dotnet-skills

Guidelines for introducing and using nullable reference types (NRT) and System.Diagnostics.CodeAnalysis nullable attributes in C# / .NET codebases. Covers the nullability model, flow analysis, the null-forgiving operator, API design rules, the full attribute catalog (AllowNull, DisallowNull, MaybeNull, NotNull, NotNullWhen, MaybeNullWhen, NotNullIfNotNull, MemberNotNull, MemberNotNullWhen, DoesNotReturn, DoesNotReturnIf), the C# 14 field keyword, incremental migration of legacy codebases, and a code-generation checklist.

How to install csharp-nullable-reference-types

install csharp-nullable-reference-types
# install the dotnet-skills pack with the skills CLI
npx skills add Aaronontheweb/dotnet-skills

# or add only this skill to Claude Code: copy the folder

skills/csharp-nullable-reference-types/

# into

~/.claude/skills/csharp-nullable-reference-types/ (all projects)

.claude/skills/csharp-nullable-reference-types/ (one project)

skills/csharp-nullable-reference-types/SKILL.md

MITFull file
1# C# Nullable Reference Types
2
3## When to Use
4
5- Introducing nullable reference types (NRT) into a codebase that has not yet adopted them
6- Writing or refactoring C# code that uses `T?` / nullable annotations
7- Annotating APIs with `System.Diagnostics.CodeAnalysis` nullable attributes
8- Designing public/internal APIs where nullability contracts matter
9- Wrapping unannotated or legacy APIs so downstream callers still benefit from NRT
10- Reviewing code for correct null-state analysis, guard helpers, and the `field` keyword
11
12## Core Goals
13
14- Prevent `NullReferenceException` at runtime by making null intent explicit in signatures.
15- Express contracts the type system cannot represent directly using the official nullable attributes.
16- Adopt NRT incrementally in legacy codebases without a big-bang rewrite.
17
18## Core Nullability Model
19
20### Non-nullable vs nullable
21
22- `string` — non-nullable reference. The compiler assumes instances are never `null`; assigning `null` or a maybe-null value produces a warning.
23- `string?` — nullable reference. The variable may be `null`; the compiler requires a null check before dereference.
24
25```csharp
26string name = "Alice";
27name = null; // Warning: assigning null to non-nullable.
28
29string? nickname = null;
30Console.WriteLine(nickname.Length); // Warning: possible null dereference.
31```
32
33### Null-state analysis (flow)
34
35The compiler tracks whether a reference is *definitely non-null* or *maybe null*. Null checks and assignments update this state.
36…

Excerpt shown under the repository's MIT license.

More skills in dotnet-skills

Keep exploring

Similar skill repositories

thedotmack /

claude-mem
116k

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

CCCXGHGM+135 skills

Leonxlnx /

taste-skill
113k

Agent skills that give coding agents taste: art direction, reference images and a browser check instead of generic AI pages

CCCXCU1 skill

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates