Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Csharp Pro

ASecurity

Idiomatic modern C#: nullable reference types, records, async/await, LINQ, and .NET project structure. Use when writing, reviewing, or structuring C# applications.

2 stars
0 votes
0 copies
0 views
Added 9/29/2026
ai-agentsgoc#expresstestingapidatabaseperformance

Works with

cliapi

Security Analysis

A100/100

Scanned 9/29/2026

$npx -y skills add aicodedecode/awesome-muse-skills --skill csharp-pro --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Csharp Pro?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Csharp Pro
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aicodedecode-csharp-pro/badge)](https://www.skillsdirectory.com/skills/aicodedecode-csharp-pro)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: csharp-pro
description: Idiomatic modern C#: nullable reference types, records, async/await, LINQ, and .NET project structure. Use when writing, reviewing, or structuring C# applications.
category: development
---

# C# Pro

## Overview

Modern C# (10–13) with .NET is a **high-productivity, high-performance platform**: nullable
reference types bring compile-time null safety, records simplify immutable data, async/await is
first-class, and minimal APIs plus strong tooling make everything from CLIs to cloud services
pleasant. Professional C# means enabling the safety features, modeling with the modern type
toolbox, writing async correctly, and using LINQ as a query language — not a cleverness contest.

The through-line: turn on every safety feature, model precisely, and let the runtime's maturity
do the heavy lifting.

## When to use

- Writing or reviewing C# for modern idiom (.NET 6+).
- Structuring .NET solutions (projects, layering, DI).
- Designing async code, data models, or APIs.
- Enabling nullable reference types or modernizing legacy C#.
- Setting up testing (xUnit/NUnit), analyzers, and CI.

## Core concepts

- **Nullable reference types ON.** `<Nullable>enable</Nullable>` — nullability becomes part of the
  type system (`string` vs `string?`). The migration is the value: every warning fixed is a
  potential NullReferenceException eliminated. Treat warnings as errors in CI for new code.
- **Records for immutable data.** `record` / `record struct` for DTOs, messages, value objects —
  value equality and non-destructive mutation (`with`) built in. Classes for behavior + identity,
  structs for small hot-path values.
- **Async all the way.** `async`/`await` end-to-end; never `.Result`/`.Wait()` (deadlocks under
  synchronization contexts); `ConfigureAwait(false)` in libraries; `ValueTask` for hot paths where
  the result is often already available. `IAsyncEnumerable<T>` for async streams.
- **LINQ as a query language.** Declarative transforms (`Where`/`Select`/`GroupBy`) over data —
  but materialize deliberately (`ToList()` when multiple enumeration would re-run queries or
  re-hit the DB), and watch for N+1 in EF Core (eager load with `Include`, project with `Select`).
- **Dependency injection as the composition model.** Constructor injection, explicit lifetimes
  (transient/scoped/singleton — and know why scoped services can't live in singletons), and
  `IOptions<T>` for configuration. The container is not a service locator.
- **Pattern matching + switch expressions.** Exhaustive, expression-based control flow over
  `if/else` chains. Combined with records and discriminated-union-style hierarchies, it brings
  much of the functional modeling power to C#.

## Practical workflow

1. **Scaffold the solution.** `dotnet new sln`; projects per boundary (`Api`, `Application`,
   `Domain`, `Infrastructure`); nullable + ImplicitUsings + latest LangVersion enabled;
   `.editorconfig` for style; TreatWarningsAsErrors for new projects.
2. **Model the domain.** Records for data, small focused classes for behavior, exceptions for
   exceptional cases (custom domain exceptions with context), validation at boundaries.
3. **Write async services.** Inject dependencies via constructor; `CancellationToken` parameters
   on async methods (and honor them); avoid `async void` (only event handlers).
4. **Data access with EF Core deliberately.** DbContext per unit of work (scoped), compiled or
   split queries for hot paths, migrations in source control, database constraints backing up
   application validation.
5. **Test in layers.** xUnit + FluentAssertions + NSubstitute/Moq for unit tests; WebApplicationFactory
   for API integration tests with a real test database (Testcontainers); a few end-to-end tests
   for critical journeys.
6. **Analyzers in CI.** `dotnet build -warnaserror`, Roslyn analyzers (Microsoft defaults +
   curated ruleset), and format enforcement (`dotnet format --verify-no-changes`).

Idiomatic snippets:

```csharp
// Record + pattern matching + nullable enabled
public abstract record PaymentResult;
public sealed record PaymentOk(string TransactionId) : PaymentResult;
public sealed record PaymentFailed(string Reason) : PaymentResult;

string Describe(PaymentResult r) => r switch {
    PaymentOk(var id)      => $"Paid: {id}",
    PaymentFailed(var why) => $"Failed: {why}",
    _ => throw new UnreachableException(),
};

// Async with cancellation, no .Result in sight
public async Task<Order> PlaceAsync(PlaceOrder cmd, CancellationToken ct = default) {
    await using var tx = await _db.Database.BeginTransactionAsync(ct);
    // ...
}
```

## Common pitfalls

- **Nullable disabled or warning-suppressed.** `#nullable disable` or `!` sprinkled to silence
  the compiler reintroduces the billion-dollar mistake. Fix the nullability model instead.
- **`.Result` / `.Wait()` deadlocks.** Blocking on async code, especially in ASP.NET (classic) or
  UI contexts. Async all the way down; it's viral by design.
- **Captive dependencies.** Singleton holding a scoped service (like DbContext) — works until it
  spectacularly doesn't. Respect lifetime boundaries; the container validates scopes in dev — listen.
- **LINQ multiple enumeration.** Passing `IEnumerable<T>` around and enumerating it three times,
  re-running a DB query each time. Materialize once when the source is expensive.
- **EF Core N+1 and client evaluation.** Lazy-loading loops and untranslatable LINQ silently
  dragging tables into memory. Profile queries; `Include`/projection deliberately.
- **God Startup / god Program.cs.** Hundreds of service registrations with no organization.
  Extension methods per area (`AddOrderServices()`), and keep composition readable.
- **Exceptions for control flow.** Throwing for expected outcomes (validation failures, "not found"
  in normal operation). Use result types or return values for expected cases; exceptions for the
  exceptional.

Attribution

aicodedecodeaicodedecode
View sourceSee grades on GitHubMore from aicodedecode →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698461 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →