Local-first CLI that reviews C# source against markdown governance rules using a local Ollama model. It streams the critique live and saves a timestamped markdown report.
This is an AI-assisted semantic code reviewer, not a deterministic static analyzer. It does not use Roslyn or parse C# into a syntax tree; the LLM interprets plain source text against your rule packs.
Built while learning .NET architecture and agent-assisted workflows — the irony of using AI to audit AI-generated code is not lost on me.
- .NET 10 SDK
- Ollama running locally with a pulled model (default:
qwen3.5:4b)
dotnet run --project CodeSmellAuditor.CliDrop .cs files into WorkstationStorage/Targets/, governance rules as .mdc into WorkstationStorage/Rules/. Reports land in WorkstationStorage/Reports/.
Environment variables (all optional):
| Variable | Default | Purpose |
|---|---|---|
CODESMELL_STORAGE |
WorkstationStorage under repo root |
Root folder containing Rules/, Targets/, Reports/ |
CODESMELL_MODEL |
qwen3.5:4b |
Ollama model name |
CODESMELL_NUM_CTX |
8192 |
Model context window passed to Ollama |
CODESMELL_NUM_PREDICT |
1200 |
Max output tokens for the critique |
Program.cs(composition root) resolves paths and wiresMarkdownRuleRepository,OllamaAiOrchestrator, andAuditEngine.- Core loads compact
.mdcrules, reads each target.csfile, builds a budgeted prompt, and streams Ollama's response. - Cli renders progress through
SpectreAuditProgressReporter; Core stays presentation-neutral viaIAuditProgressReporter. - Each audit saves a markdown report with YAML front matter. Pass/fail is parsed from a
Status:line in the report body.
Sample report format: docs/sample-report-excerpt.md
More detail: architecture · known limitations · testing
dotnet test CodeSmellAuditor.slnx -c Release15 unit tests covering rule loading, prompt building, pass/fail parsing, and AuditEngine orchestration with fakes. Ollama HTTP streaming is exercised manually, not in CI.
- Single-file
.csaudits against local markdown rule packs - Local Ollama only (privacy-preserving; no cloud API)
- Interactive CLI with streaming terminal output
- Layered Core / Cli / Tests solution with constructor injection at the composition root
- CLI arguments (
--model,--storage,--non-interactive) instead of env vars only - Non-zero exit codes when any audit requires review
- Surface batch pass/fail summary in the CLI (engine already returns
AuditRunResult) - Roslyn-based deterministic pre-checks before the LLM pass
- Cloud model backend via a second
IAiOrchestratorimplementation
MIT
