让 Claude 代码成为 .NET 10 专家
dotnet-claude-kit
Make Claude Code an expert .NET developer.
47 skills • 10 specialist agents • 16 slash commands • 10 rules • 5 project templates • 22 MCP tools • automation hooks
Built for .NET 10 / C# 14. Architecture-aware. Token-efficient.Full Guide • Installation • Quick Start • 10x Features • Commands • Skills • Agents • Rules • Templates • MCP Server • Contributing
New here? Start with the guide
How I Use dotnet-claude-kit: Making Claude Code Write Senior-Level .NET →
The complete walkthrough: install and update the plugin, what happens in your first session, the everyday feature workflow, how the Roslyn MCP server cuts token usage, which commands keep a codebase healthy, plus FAQ and troubleshooting.
This README is the reference. The guide is how to actually use it.
Claude Code is powerful, but out of the box it doesn't know your .NET conventions. It generates DateTime.Now instead of TimeProvider. It wraps EF Core in repository abstractions. It picks an architecture without asking about your domain. It reads entire source files when a Roslyn query would cost 10x fewer tokens.
dotnet-claude-kit fixes all of that.
A curated knowledge and action layer that sits between Claude Code and your .NET project. Drop a single CLAUDE.md into your repo and Claude instantly knows:
IEndpointGroup auto-discovery, TypedResults, and proper OpenAPI metadataWebApplicationFactory + Testcontainers instead of in-memory fakesNo configuration. No setup wizards. Just copy one file and go.
An action layer on top of the knowledge layer — Claude doesn't just know the right patterns, it actively applies and enforces them:
| Capability | What It Does |
|---|---|
| Surgical Code Analysis | 22 Roslyn-powered MCP tools with guaranteed bounded responses. get_symbol_source reads ONE method body instead of the whole file. get_file_outline shows what's in a file before reading it. resolve_stack_trace turns an exception into file:line in your own code. analyze_change_impact answers "what breaks if I change this?" in one call. Every list-returning tool reports Truncated — no tool can blow your context window. |
| Architecture Enforcement | /arch-check verifies the code still matches its declared architecture (VSA, Clean, DDD, Modular Monolith): dependency direction, layer violations, module leaks, cycles — with file:line evidence and fixes. |
| Dependency Health | /outdated reports stale packages, CVEs, and commercial-license traps (MediatR 13+, MassTransit 9+, FluentAssertions 8+, AutoMapper 15+) before an innocent update-all changes your legal position. |
| Security Mapping | get_endpoint_map inventories every route with its auth posture (authorized/anonymous/unmarked) in one token-cheap call — /security-scan starts every auth audit there. |
| DI X-Ray | get_di_registrations maps every service registration with lifetimes, duplicate detection, and captive-dependency risks (singleton holding scoped). |
| Agents That Learn | Specialist agents carry memory: project — the code reviewer, architect, and security auditor learn your conventions across sessions instead of rediscovering them. The reviewer is tool-enforced read-only; the cleanup agent works in an isolated worktree. |
| Scaffolding | One command → complete feature with Result pattern, validation, OpenAPI metadata, pagination, CancellationToken, and tests. 9-point checklist enforced. All 4 architectures. |
| Health Check | Automated codebase analysis using MCP tools: anti-pattern scan, diagnostics, dead code detection, test coverage → graded report card. |
| PR Review | Multi-dimensional code review: anti-patterns, diagnostics, API surface changes, blast radius, architecture compliance, test coverage. |
| Convention Learning | Detects project-specific patterns (naming, structure, modifiers) and enforces them in new code. Adapts to your codebase. |
| Active Hooks | Automated quality scripts — format on edit, destructive-command guard, restore on .csproj change — tested on Windows and Linux in CI. |
| Always Current | Every package recommendation verified against NuGet with licensing-trap warnings, and a .NET 11 preview watch so guidance never rots. |
| Metric | Without Kit | With Kit | Impact |
|---|---|---|---|
| Architecture decisions | Claude picks randomly | Asks questions, recommends with rationale | Correct architecture from day one |
| Code quality | Generic C#, legacy patterns | Modern C# 14 with idiomatic .NET 10 | Zero "fix this pattern" revision cycles |
| Codebase navigation | Reads entire files (500-2000+ tokens each) | Roslyn MCP queries (30-150 tokens each) | ~10x token savings on exploration |
| Anti-patterns generated | DateTime.Now, repository-over-EF, new HttpClient() |
TimeProvider, direct DbContext, IHttpClientFactory |
Production-ready on first generation |
| Testing approach | In-memory fakes, mocked everything | WebApplicationFactory + Testcontainers |
Tests that catch real bugs |
| Production resilience | No retry, no circuit breakers | Polly v8 pipelines with telemetry | Handles transient failures automatically |
The result: Less time reviewing and correcting Claude's output. More time shipping features.
Prefer a narrated walkthrough with screenshots and troubleshooting? Read the complete installation and usage guide.
Install as a Claude Code plugin — all 47 skills (including 16 slash-command workflows), 10 agents, hooks, and MCP config activate globally. The 10 rules ship in this repo for you to copy into your project's .claude/rules/:
# In your terminal — install the Roslyn MCP server
dotnet tool install -g CWM.RoslynNavigatormacOS/Linux: If the server fails with "No .NET SDKs were found", set
DOTNET_ROOTto your .NET installation root (e.g./usr/local/share/dotnet). See the MCP server troubleshooting guide.
Then inside a Claude Code session:
# Add the marketplace and install the plugin
/plugin marketplace add codewithmukesh/dotnet-claude-kit
/plugin install dotnet-claude-kitFor local development/testing (loads directly from disk, no install needed):
claude --plugin-dir /path/to/dotnet-claude-kitNavigate to your project directory (existing or empty) and run:
/dotnet-initExisting project? It detects your solution, scans .csproj SDKs, reads your tech stack from config, asks architecture questions, and generates a customized CLAUDE.md.
Greenfield project? It asks what you're building, scaffolds the full solution structure (dotnet new sln, projects, Directory.Build.props, src/ and tests/ folders), then generates CLAUDE.md. Follow up with /scaffold to add your first feature.
No manual template copying needed.
Manual Template Copy (Alternative)
If you prefer manual setup, copy the template matching your project type:
cp templates/web-api/CLAUDE.md ./CLAUDE.md # REST API
cp templates/modular-monolith/CLAUDE.md ./CLAUDE.md # Multi-module system
cp templates/blazor-app/CLAUDE.md ./CLAUDE.md # Blazor app
cp templates/worker-service/CLAUDE.md ./CLAUDE.md # Background workers
cp templates/class-library/CLAUDE.md ./CLAUDE.md # NuGet packagesReplace [ProjectName], update tech stack, choose your architecture.
Start Claude Code — 47 skills, 10 agents, and 22 MCP tools activate automatically. Copy the 10 rules into your project's .claude/rules/ to make them always-loaded.
That's it. Claude now writes .NET code the way a senior .NET engineer would.
Manual Install (Alternative)
If you prefer to clone the repo and wire things up manually:
# 1. Install the MCP server globally
dotnet tool install -g CWM.RoslynNavigator
# 2. Register it in Claude Code at user scope (available in ALL projects)
claude mcp add --scope user cwm-roslyn-navigator -- cwm-roslyn-navigator --solution ${workspaceFolder}
# 3. Clone the kit
git clone https://github.com/codewithmukesh/dotnet-claude-kit.git
# 4. Load as a local plugin (or copy a template manually)
claude --plugin-dir ./dotnet-claude-kit// Claude generates this
public class OrderService
{
private readonly IOrderRepository _repo; // unnecessary abstraction over EF Core
public async Task CreateOrder(CreateOrderDto dto)
{
var order = new Order();
order.CreatedAt = DateTime.Now; // wrong — use TimeProvider
order.Items = dto.Items.ToList();
await _repo.AddAsync(order);
return order; // leaks domain entity to API
}
}…// Each endpoint group auto-discovered — Program.cs never changes
public sealed class OrderEndpoints : IEndpointGroup
{
public void Map(IEndpointRouteBuilder app)
{
var group = app.MapGroup("/api/orders").WithTags("Orders");
group.MapPost("/", CreateOrderHandler)
.WithName("CreateOrder").Produces(201)
.ProducesValidationProblem()
.AddEndpointFilter>();
}
}Result pattern. FluentValidation with endpoint filters. IEndpointGroup auto-discovery. TypedResults with OpenAPI metadata. CancellationToken everywhere. Sealed handlers. TimeProvider injection. DbContext directly. Every pattern comes from the skills in this kit.
Shortcut workflows that orchestrate skills and agents. Type the command and Claude handles the rest. These are workflow skills — each lives at skills//SKILL.md, registers its /name automatically, and carries its methodology inline (no separate knowledge twin to load).
| Command | Purpose | Works With |
|---|---|---|
/dotnet-init |
Project setup (existing or greenfield) — detects or scaffolds, then generates CLAUDE.md | project-setup skill, dotnet-architect agent |
/spec |
Relentless questioning until human + AI agree on a persisted spec (docs/specs/) |
feeds /plan and /tdd |
/plan |
Architecture-aware planning — consumes approved specs | architecture-advisor skill, dotnet-architect agent |
/verify |
7-phase verification: build → analyzers → antipatterns → tests → security → format → diff | — |
/tdd |
Red-green-refactor with xUnit + Testcontainers | testing skill, test-engineer agent |
/scaffold |
Architecture-aware feature scaffolding (all 4 architectures, per-architecture templates included) | dotnet-architect agent |
/code-review |
MCP-powered, blast-radius-prioritized code review | code-reviewer agent |
/build-fix |
Bounded build-fix and test-fix loops with progress detection | build-error-resolver agent |
/checkpoint |
Mid-session save: commit + brief handoff note | — |
/security-scan |
OWASP + secrets + vulnerable dependency audit | security-auditor agent |
| `/migra |
暂无开放 Issues,或尚未同步最近议题。