Hooks
Three hooks run automatically during development sessions.
SessionStart — Environment Check
When: Every time a Claude Code session starts.
What: Verifies the .NET SDK and csharp-ls are installed. Prints a warning with install instructions if anything is missing.
Script: scripts/check-dotnet-environment.ps1
PostToolUse — Auto-Format
When: After every Write or Edit operation on a .cs file.
What: Runs dotnet format --include <file> to enforce .editorconfig formatting rules automatically.
Script: scripts/dotnet-format.ps1
PostToolUse — Build Check
When: After every Write or Edit operation on a .cs or .csproj file.
What: Runs dotnet build --no-restore and reports any warnings or errors. This enforces the zero-warnings policy immediately after each edit.
Script: scripts/dotnet-build-check.ps1
How Hooks Work
Hooks are defined in hooks/hooks.json and reference PowerShell scripts in scripts/. Each script receives a JSON payload on stdin containing the tool name and input parameters. Scripts communicate via exit codes:
| Exit Code | Meaning |
|---|---|
| 0 | Success (silent) |
| 2 | Non-blocking message (displayed to user) |