# dotnet-csharp-code-smells

dotnet-csharp-code-smells — a C# review skill: the agent catches leaked IDisposable, misused async and DI, suppressed warnings and other anti-patterns while it plans, writes or reviews code.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 180 installs · ★ 92 repo stars
- Author: wshaddix
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/wshaddix/dotnet-skills/tree/HEAD/skills/dotnet-csharp-code-smells/SKILL.md
- Updated: 2026-02-27
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/dotnet-csharp-code-smells

## What it does

The skill stays on through planning, implementation and review, so the agent checks its own C# as it goes. Inside are reference tables of common smells, each with the harm it does, the fix and the CA rule that flags it. Sections cover disposable handling, warning suppression, LINQ, event subscriptions, design thresholds and exception handling.

Concrete numbers make it usable. A class past 500 lines or a method past 30 lines gets flagged. `throw ex;` gives way to a bare `throw;`, `.Count() > 0` becomes `.Any()`, and a query is enumerated once instead of twice.

Generation mistakes such as wrong NuGet packages or a broken project layout are out of scope — `dotnet-agent-gotchas` handles those. Async details, DI lifetimes and nullable annotations sit in companion skills from the same set, and this one only points at them.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill dotnet-csharp-code-smells -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/dotnet-csharp-code-smells/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/dotnet-csharp-code-smells/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill dotnet-csharp-code-smells -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/dotnet-csharp-code-smells/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill dotnet-csharp-code-smells -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/dotnet-csharp-code-smells/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install wshaddix/dotnet-skills skills/dotnet-csharp-code-smells
```

2. **Manually: put the files in place**
- File: `.github/skills/dotnet-csharp-code-smells/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill dotnet-csharp-code-smells -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/wshaddix/dotnet-skills --path skills/dotnet-csharp-code-smells
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/dotnet-csharp-code-smells/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill dotnet-csharp-code-smells -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/wshaddix/dotnet-skills/tree/HEAD/skills/dotnet-csharp-code-smells/SKILL.md

## When to use it
- find a disposable local variable that never gets a `using`
- stop a LINQ chain from enumerating the same collection twice
- replace an empty `catch` with logging or a rethrow
- locate an event subscription that is never removed
- split a method that has grown too long

## Example prompts
- Check `OrderService.cs` for leaked `IDisposable` and event handlers that never unsubscribe.
- Review this PR for LINQ anti-patterns: where the collection is enumerated twice and where `.Count() > 0` should be `.Any()`.
- Find empty `catch` blocks and `throw ex;` under `src/Api`.

## Similar
- [analyzing-dotnet-performance](https://affpapa.org/en/nevibecode/skills/analyzing-dotnet-performance.md) — skill · 6200 installs
- [csharp-async](https://affpapa.org/en/nevibecode/skills/csharp-async.md) — skill · 10883 installs
- [modern-csharp](https://affpapa.org/en/nevibecode/skills/modern-csharp.md) — skill · 4100 installs
- [openapi-to-application-csharp-dotnet](https://affpapa.org/en/nevibecode/plugins/openapi-to-application-csharp-dotnet.md) — plugin · ★ 41430 repo stars
- [csharp-expert](https://affpapa.org/en/nevibecode/agents/csharp-expert.md) — subagent · ★ 1029 repo stars
- [dotnet-slopwatch](https://affpapa.org/en/nevibecode/skills/dotnet-slopwatch.md) — skill · 593 installs

From the same set: [wshaddix/dotnet-skills](https://affpapa.org/en/nevibecode/by/wshaddix/dotnet-skills.md) — 24 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
