Skip to content

Latest commit

 

History

History
262 lines (205 loc) · 21.6 KB

reference.md

File metadata and controls

262 lines (205 loc) · 21.6 KB

dotnet-agent-kit reference

Detail that does not fit the README: install options, per-skill notes, rules, MCP tools, hooks, defaults and repository layout.

Install options

Requirements: Claude Code and the .NET 10 SDK.

Plugin (recommended)

/plugin marketplace add codewithmukesh/dotnet-agent-kit
/plugin install dotnet-agent-kit

Skills, agents, hooks and the MCP server config activate globally. The Roslyn MCP server starts through dotnet dnx CWM.RoslynNavigator@<version> --yes from the plugin's .mcp.json, so you do not install it separately.

macOS/Linux: if the server fails with "No .NET SDKs were found", set DOTNET_ROOT to your .NET installation root (for example /usr/local/share/dotnet). See the MCP server troubleshooting guide.

Windows: "Failed to finalize marketplace cache" (EPERM)? That is a Claude Code installer issue (anthropics/claude-code#12174). Close every Claude Code session, delete %USERPROFILE%\.claude\plugins\marketplaces\*dotnet-agent-kit*, pause OneDrive sync if .claude lives under it, and run the marketplace add again.

Router snippet (optional)

Paste the generated router snippet into a project's CLAUDE.md or AGENTS.md: one line telling the agent to prefer retrieval over pretraining, plus a topic-to-skill index. The session hook already adds a similar index in Claude Code, so this mainly helps other tools.

Local checkout

Loads straight from disk, no install:

git clone https://github.com/codewithmukesh/dotnet-agent-kit.git
claude --plugin-dir ./dotnet-agent-kit

APM

APM (Agent Package Manager) installs the repo as-is, with skills, agents, hooks and the MCP server config:

apm install codewithmukesh/dotnet-agent-kit --target claude    # or --target copilot

Pin a tag or commit SHA (codewithmukesh/dotnet-agent-kit#<tag-or-sha>) to keep installs reproducible. For the Copilot target, APM renames agents to *.agent.md itself.

Global MCP server install (optional)

If you want the server without the plugin, or prefer a global tool:

dotnet tool install -g CWM.RoslynNavigator
claude mcp add --scope user cwm-roslyn-navigator -- cwm-roslyn-navigator --solution ${workspaceFolder}

Per-project setup

Run /dotnet-init in your project directory.

  • Existing project: it detects your solution, scans .csproj SDKs, reads your tech stack from config, asks architecture questions and generates a customized CLAUDE.md. It handles web APIs, console apps and CLI tools, desktop apps (WPF, Avalonia, WinForms, MAUI) and libraries. It can also copy the 8 rules into .claude/rules/.
  • Already have a CLAUDE.md? It never overwrites silently. You choose Merge (recommended: keeps your sections, adds or refreshes only the kit's), Overwrite or Keep, and your original is backed up to CLAUDE.md.bak first.
  • Greenfield: it asks what you are building, scaffolds the solution (dotnet new sln, projects, Directory.Build.props, src/ and tests/), then generates CLAUDE.md. Follow with /scaffold for your first feature.

Manual template copy

cp templates/web-api/CLAUDE.md ./CLAUDE.md           # REST API
cp templates/modular-monolith/CLAUDE.md ./CLAUDE.md   # Business app (default: modular slices)
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 packages
cp templates/console-cli/CLAUDE.md ./CLAUDE.md         # Console app / CLI tool
cp templates/desktop-app/CLAUDE.md ./CLAUDE.md         # Avalonia / WPF / WinForms / MAUI

Replace [ProjectName], update the tech stack and choose your architecture.

Skills in detail

Eleven of the 37 skills are workflow orchestrators (the slash commands). The 26 knowledge skills below are each under 400 lines, with concrete code, BAD/GOOD anti-patterns and a decision guide.

Category Skills What Claude learns
Architecture architecture-advisor, modular-slices Modular slices by default: modules with contracts projects, feature folders, IEndpoint + IHandler, per-module outbox, architecture tests. The advisor's references/ cover single-project VSA, Clean Architecture, DDD and solution structure for when the questionnaire points there
Core language modern-csharp Primary constructors, collection expressions, field keyword, records, pattern matching, spans
Web / API minimal-api, authentication, openapi MapGroup, TypedResults, endpoint filters, API versioning, JWT/OIDC, built-in OpenAPI with Scalar
API security resource-authorization, api-hardening, rate-limiting Owner-scoped queries and 404 for other users' data, resource-based handlers, EF Core 10 named owner/tenant filters; HSTS, forwarded headers with KnownIPNetworks, strict CORS, body limits, security headers; per-caller rate limits, strict auth-endpoint policy, 429 + Retry-After, multi-instance behaviour
Data ef-core No repository wrappers. Compiled queries, interceptors, ExecuteUpdateAsync, value converters
Resilience error-handling, resilience, caching, messaging TypedResults + ProblemDetails, Polly v8 pipelines and typed HTTP clients, HybridCache, built-in outbox/inbox, Hangfire, broker clients, Rebus
Observability logging, opentelemetry Health checks, correlation IDs, Serilog structured logging, OpenTelemetry traces and metrics
Testing testing xUnit v3, WebApplicationFactory, Testcontainers, Verify snapshots
DevOps docker, ci-cd, aspire Multi-stage builds, Dockerfile-less SDK publishing, GitHub Actions, Aspire orchestration
Console and desktop console-cli, desktop-mvvm, native-aot System.CommandLine 2.x, exit codes and stdout/stderr discipline, CommunityToolkit.Mvvm, WPF and Avalonia, Native AOT and trimming
Cross-cutting dependency-injection, configuration Keyed services, Options pattern, secrets management
Learning instinct-system Confidence-scored instincts, convention detection, correction capture. Operations (status, export, import) are modes of this skill: say "show instincts", "export instincts" or "import instincts"

The workflow skills are dotnet-init, spec, verify, tdd, scaffold, code-review, build-fix, migrate, de-sloppify, wrap-up and doctor. dotnet-init, wrap-up and doctor are slash-only: you type them, and their descriptions cost nothing per session. Each carries its methodology inline.

For parallel worktrees, plan mode, subagent patterns and context discipline, see claude-code-workflow.md. Measured token savings come from the Stats CLI; see Measuring token savings.

Rules in detail

The 8 rules total a few hundred lines. They are not auto-loaded by the plugin (plugins can't ship rules); the SessionStart hook adds a digest, and /dotnet-init can copy the full files into your project's .claude/rules/.

Rule Enforces
coding-style C# 14 conventions, file-scoped namespaces, primary constructors, sealed, records
architecture Modular slices by default, no repository over EF, one IEndpoint per feature, dependency direction
security No hardcoded secrets, parameterized queries, explicit auth, HTTPS
testing Integration-first, WebApplicationFactory + Testcontainers, AAA pattern
performance CancellationToken propagation, TimeProvider, IHttpClientFactory, HybridCache
error-handling TypedResults unions, ProblemDetails with stable codes, no broad catch, boundary validation
packages Latest stable NuGet versions, never versions from training data
workflow MCP-first navigation, subagent and model selection, conventional commits, hooks never skipped

The Cursor rules file (.cursor/rules/dotnet-rules.md) and the session-start digest are generated from these files (.github/scripts/generate_cursor_rules.py, .github/scripts/generate_session_context.py); CI fails when they are stale.

Roslyn MCP tools

The server gives Claude semantic answers for 30 to 150 tokens where reading a file costs 500 to 2000 or more. Every list-returning tool reports Truncated. Details, flags and troubleshooting: mcp/CWM.RoslynNavigator/README.md. The server loads analyzers from shadow copies, so it never locks files in ~/.nuget/packages or blocks dotnet restore.

Tool What it does Replaces
find_symbol Locate type/method definitions Grep/Glob across all .cs files
find_references Find all usages of a symbol Grep for the type name
find_implementations Find interface implementors Searching for : IInterface
find_callers Find all methods calling a method Manual grep for the method name
find_overrides Find overrides of virtual/abstract methods Searching for override
get_type_hierarchy Inheritance chain and interfaces Reading multiple files
get_project_graph Solution dependency tree Parsing .csproj files by hand
get_public_api Public API without the full file Reading entire source files
get_symbol_detail Signature, params, declared type, XML docs, by name, SymbolId or file position Reading the file around a line number
get_diagnostics Compiler warnings and errors Running dotnet build and parsing
detect_antipatterns 10 .NET anti-pattern rules Manual code review
find_dead_code Unused types, methods, properties Manual inspection
detect_circular_dependencies Project and type-level cycles Tracing references by hand
get_dependency_graph Method call chain visualization Reading multiple files
get_test_coverage_map Heuristic test coverage mapping Searching for test files
get_symbol_source Exact source of one member (bounded, capped) Reading the whole file for one method
get_file_outline Type and member skeleton of a file, no bodies Reading the file to see what is in it
get_nuget_packages PackageReference inventory, central package management aware Parsing csproj/props files
get_endpoint_map Route inventory with auth posture per endpoint Grepping Map*/controllers
get_di_registrations DI map: lifetimes, duplicates, captive risks (MS.DI, Prism, Autofac) Reading Program.cs and extensions
resolve_stack_trace Maps an exception's frames to file:line in your code Hunting for each method
analyze_change_impact "What breaks if I change this?": callers, implementers, affected tests Chaining reference searches
preview_rename What a semantic rename would change, without writing anything Grepping the name and guessing
get_workspace_status What is loaded, warm-up progress, projects that loaded incompletely Wondering why a search came back empty

Benchmark method and per-question results: A/B report, server benchmark, A/B harness.

Hooks and scripts

Five hooks run automatically (declared in hooks/hooks.json). The rest are git pre-commit hooks and utilities. Setup and design notes: hooks/README.md.

Script Kind What it does
session-start.sh Claude Code hook, SessionStart (startup, clear, compact) In a .NET repo, adds the skill index and a digest of the 8 rules (about 1.5k tokens). Prints nothing elsewhere. CWM_SESSION_CONTEXT=off disables it
pre-bash-guard.sh Claude Code hook, PreToolUse (Bash) Parses each command and blocks destructive ones (force push, reset --hard, clean -f, rm -rf outside build output) and machine-wide ones (pkill, dotnet build-server shutdown, deleting NuGet caches). A command that only mentions one, like a grep pattern or commit message, passes (ADR-007)
post-edit-format.sh + stop-format.sh Claude Code hooks, PostToolUse (*.cs) and Stop Queue each edited C# file, then format the turn's files once when Claude stops, with dotnet format or CSharpier when the repo uses it (CWM_POST_EDIT_FORMAT=edit formats per edit, =off disables it)
post-scaffold-restore.sh Claude Code hook, PostToolUse (*.csproj) Runs dotnet restore after project file changes
post-edit-slop-guard.sh Claude Code hook, PostToolUse (*.cs) Blocks shortcuts in the lines an edit adds: #pragma warning disable with no reason, [Fact(Skip...)], Assert.True(true), empty catch { }, NotImplementedException stubs. Old violations never block (CWM_SLOP_GUARD=warn reports only, =off disables it)
pre-commit-format.sh Git pre-commit (manual install) dotnet format --verify-no-changes
pre-commit-antipattern.sh Git pre-commit (manual install) Detects async void, sync-over-async, new HttpClient() and DateTime.Now in the lines a commit adds (ADR-006)
post-test-analyze.sh Utility (pipe test output) Parses test results into an actionable summary
pre-build-validate.sh Utility (run before builds) Validates project structure (solution file, Directory.Build.props, test projects)

Templates in detail

Template For Includes
web-api Single-area REST APIs, microservices Feature slices with IEndpoint + IHandler, TypedResults, EF Core, testing
modular-monolith Business apps (the default) Contracts projects, per-module schema, outbox/inbox events, Api/Worker/Migrator hosts, architecture tests
blazor-app Blazor Server / WASM / Auto Component organization, render mode strategy, bUnit testing
worker-service Background processing BackgroundService patterns, Hangfire, broker consumers, cancellation
class-library NuGet packages, shared libraries Public API design, XML docs, semantic versioning, SourceLink
console-cli Console apps, CLI tools, dotnet tools System.CommandLine 2.x, exit codes, stdio discipline, tool packaging, Native AOT
desktop-app Avalonia, WPF, WinForms, MAUI MVVM with CommunityToolkit.Mvvm, Generic Host, UI threading, per-OS publishing

Knowledge base

Reference documents updated per .NET release. They are not skills; agents and templates point to them.

Document Purpose
dotnet-whats-new .NET 10 / C# 14 features and how to use them
common-antipatterns Patterns Claude should never generate
package-recommendations Vetted NuGet packages with rationale and "when not to use"
breaking-changes .NET migration gotchas
common-infrastructure Copy-paste implementations: Problems, validation filter, IExceptionHandler, IEndpoint discovery, pagination
mediatr-to-mediator-migration Step-by-step MediatR to Mediator (MIT, source-generated) migration
decisions/ Architecture Decision Records explaining every default

Defaults and decisions

Decision Default Why
Architecture Modular slices Modules built from vertical slices; the advisor still picks VSA, Clean Architecture or DDD when they fit better (ADR-008)
Error handling TypedResults unions + ProblemDetails Compile-checked responses, stable error codes, Result<T> only for non-HTTP code (ADR-008)
ORM EF Core Best developer experience for most scenarios (ADR-003)
Caching HybridCache Built-in stampede protection, L1+L2 (ADR-004)
APIs Minimal APIs Lighter, composable, architecture-agnostic
Testing Integration-first WebApplicationFactory + Testcontainers over in-memory fakes
Time TimeProvider Testable and injectable
HTTP clients IHttpClientFactory Avoids socket exhaustion from new HttpClient()

Other AI coding tools

Claude Code is the only platform the evals, hook tests and SessionStart hook cover. The others are kept in step by CI (counts, versions, rule parity) but are not tested end to end; issues and fixes from their users are welcome.

Platform Config file What it provides
Claude Code .claude-plugin/plugin.json Full integration: skills, agents, hooks, MCP
Cursor .cursor/rules/dotnet-rules.md Consolidated .NET rules, generated from .claude/rules/
Codex CLI .codex/AGENTS.md Agent configuration pointing to skills and agents
OpenCode opencode.json + .opencode/AGENTS.md Roslyn MCP server, consolidated rules, agent and skill catalog
Kimi Code .kimi-plugin/plugin.json Skills, agents and the Roslyn MCP server. Install with /plugins install https://github.com/codewithmukesh/dotnet-agent-kit
APM (Claude, Copilot, Cursor, Codex) Repo layout as-is apm install codewithmukesh/dotnet-agent-kit --target <tool>

Repository structure

dotnet-agent-kit/
├── CLAUDE.md                    # Instructions for developing THIS repo
├── AGENTS.md                    # Agent routing and orchestration
├── agents/                      # 3 agents
├── skills/                      # 37 skills (11 are slash-command workflows)
├── .claude/rules/               # 8 rules
├── templates/                   # 7 drop-in CLAUDE.md templates
├── knowledge/                   # Reference documents and ADRs
├── evals/                       # Plugin evals (claude plugin eval)
├── mcp/CWM.RoslynNavigator/     # Roslyn MCP server (24 tools)
├── mcp-configs/                 # MCP server config templates
├── hooks/                       # Claude Code hooks, git hooks, utilities
├── docs/                        # Guides and this reference
├── .mcp.json                    # MCP server registration
├── .claude-plugin/              # Plugin marketplace manifests
├── .cursor/rules/               # Cursor rules (generated)
├── .codex/, .opencode/          # Codex and OpenCode compatibility
├── opencode.json                # OpenCode config
├── .kimi-plugin/                # Kimi Code plugin manifest
└── .github/                     # CI workflows, issue templates, check and generate scripts

Guides

Guide Content
How I Use dotnet-agent-kit Install, update, first session, everyday workflow, Roslyn token savings, FAQ, troubleshooting
Shorthand guide Quick reference: commands, skills, agents, hooks and MCP tools
Longform guide Workflows, token optimization, autonomous patterns, troubleshooting
Claude Code workflow Worktrees, plan mode, subagents, context discipline