This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Restore dependencies
dotnet restore ProjGraph.slnx
# Build
dotnet build ProjGraph.slnx
# Run all tests
dotnet test ProjGraph.slnx
# Run a specific test project
dotnet test tests/ProjGraph.Tests.Unit.ClassDiagram
# Run a specific test class
dotnet test tests/ProjGraph.Tests.Unit.ClassDiagram --filter "ClassAnalysisDepthTests"
# Run CLI locally
dotnet run --project src/ProjGraph.Cli -- visualize ./ProjGraph.slnx
dotnet run --project src/ProjGraph.Cli -- stats ./ProjGraph.slnx
# Run MCP server locally
dotnet run --project src/ProjGraph.McpBuild enforces TreatWarningsAsErrors=true and EnforceCodeStyleInBuild=true. XML documentation is required on all public APIs.
ProjGraph is a .NET 10 tool ecosystem with two entry points — a CLI (Spectre.Console.Cli) and an MCP server (ModelContextProtocol.Server over stdio) — both backed by a shared library layer.
Cli ──┐
├──► Lib ──► Lib.Core ──► Core
Mcp ──┘ ├──► Lib.ProjectGraph ──► Lib.Core
├──► Lib.ClassDiagram ──► Lib.Core
└──► Lib.EntityFramework ──► Lib.CoreProjGraph.Core— Pure domain models (SolutionGraph,ClassModel,EfModel,SolutionStats) and exceptions. No dependencies.ProjGraph.Lib.Core— Cross-cutting abstractions (IFileSystem,IOutputConsole,ICompilationFactory,IDiagramRenderer<T>), solution parsers (.sln/.slnx), and infrastructure utilities.ProjGraph.Lib.ProjectGraph— Builds dependency graphs from solution/project files using Buildalyzer; computes stats viaTarjanSccAlgorithmfor cycle detection.ProjGraph.Lib.ClassDiagram— Roslyn-based C# class hierarchy analysis. Accepts a file or directory; optionally discovers related types across the workspace viaIWorkspaceTypeDiscovery.ProjGraph.Lib.EntityFramework— Roslyn semantic analysis of EF CoreDbContextfiles andModelSnapshotfiles; includes a multi-class Fluent API parser.ProjGraph.Lib— Composition root only. ExposesAddProjGraphLib()which wires all sub-library services via DI.
Use-case pattern — Each feature library organises logic as:
Application/
├── IServiceInterface.cs
├── ServiceImplementation.cs
└── UseCases/
└── SpecificUseCase.csRendering pipeline — Parse → Model → Render. Models are pure records in ProjGraph.Core. IDiagramRenderer<T> implementations are resolved by keyed DI (each renderer exposes a Format property). Multiple renderers can exist per model type (tree, flat, Mermaid).
MCP stdout safety — The MCP server overrides IOutputConsole with NullOutputConsole to prevent ANSI markup from leaking onto the JSON-RPC stdio transport.
New feature checklist:
- Add domain models to
ProjGraph.Coreif needed. - Implement in the appropriate
Lib.*project following the use-case pattern. - Register services in that library's
DependencyInjection.cs. - Expose via CLI command (
src/ProjGraph.Cli/Commands/) and/or MCP tool (src/ProjGraph.Mcp/Program.cs). - Add unit and integration tests.
| Project | Purpose |
|---|---|
Tests.Unit.* |
Unit tests per library |
Tests.Integration.Cli |
CLI end-to-end tests |
Tests.Integration.Mcp |
MCP tool integration tests |
Tests.Contract |
MCP contract validation & DI wiring |
Tests.Shared |
Shared helpers (TestDirectory, TestPathHelper) |
Releases are triggered by pushing a v* tag. The publish workflow builds, packs, pushes to NuGet.org and GitHub Packages, submits to the MCP Registry via mcp-publisher, and creates a GitHub Release. The MCP Registry ownership comment (<!-- mcp-name: io.github.handys11/projgraph -->) must remain at the end of src/ProjGraph.Mcp/README.md.