| name | dotnet-agent-harness-hooks |
| category | developer-experience |
| subcategory | cli |
| description | Hooks and MCP server guide for dotnet-agent-harness. How hooks behave, how to disable them, MCP configuration and troubleshooting. |
| license | MIT |
| targets | ["*"] |
| tags | ["hooks","mcp","claude-code","dotnet","tooling"] |
| version | 0.0.1 |
| author | dotnet-agent-harness |
| invocable | true |
| claudecode | {"allowed-tools":["Read","Grep","Glob","Bash","Write","Edit"]} |
| codexcli | {"short-description":"Hooks + MCP integration guide"} |
| opencode | {"allowed-tools":["Read","Grep","Glob","Bash","Write","Edit"]} |
| copilot | {} |
| geminicli | {} |
| antigravity | {} |
dotnet-agent-harness-hooks
Source: dotnet-artisan (MIT) — Claire Novotny LLC. Ported into dotnet-agent-harness.
This guide explains the hook patterns and MCP server integration used by the dotnet-agent-harness ecosystem.
Hooks overview
Hooks fire automatically during Claude Code sessions. They provide .NET-focused defaults and suggestions.
PostToolUse hook (Write|Edit)
A single hook entry with matcher Write|Edit dispatches to scripts/hooks/post-edit-dotnet.sh, which inspects the
edited file's extension and takes the appropriate action.
| File pattern | Behavior | Details |
|---|
*Tests.cs, *Test.cs | Suggests running related tests | Outputs a systemMessage with a dotnet test --filter command targeting the modified test class |
*.cs | Auto-formats with dotnet format | Runs dotnet format --include <file> asynchronously; reports results on the next turn |
*.csproj | Suggests dotnet restore | Outputs a systemMessage recommending restore after project file changes |
*.xaml | Validates XML well-formedness | Uses xmllint or falls back to python3 xml.etree.ElementTree; reports validation errors |
This hook runs asynchronously (async: true) with a 60-second timeout. It never blocks editing (always exits 0).
SessionStart hook (startup)
The scripts/hooks/session-start-context.sh hook fires once when a new Claude Code session starts. It detects whether
the current directory is a .NET project and injects context.
- Counts
.sln/.slnx solution files (up to 3 directories deep)
- Counts
.csproj project files (up to 3 directories deep)
- Checks for
global.json
- Extracts the target framework moniker (TFM) from the first
.csproj found
If .NET project indicators are found, the hook outputs an additionalContext message such as: