Fluent C# architecture spec that enforces the rules (CLI, CI, xUnit) and generates AI-agent context (AGENTS.md, MCP) from one model.
- ✓Open-source license (MIT)
- ✓Actively maintained (<30d)
- ✓Clear description
- ✓Topics declared
- ✓Documented (README)
git clone https://github.com/andypgray/loadbearingMCP Servers overview
# LoadBearing
<!-- mcp-name: io.github.andypgray/loadbearing -->
[](https://github.com/andypgray/loadbearing/actions/workflows/ci.yml) [](https://scorecard.dev/viewer/?uri=github.com/andypgray/loadbearing) [](https://www.nuget.org/packages/Zphil.LoadBearing.Cli) [](https://www.nuget.org/packages/Zphil.LoadBearing.Cli)
LoadBearing is a .NET tool that renders one C# architecture spec to two targets: enforcement and agent context.
The architecture of a long-lived codebase is real: layers, boundaries, rules. It is also unenforced: it lives in a few heads, no build step checks it, and diagrams drift. Nothing fails when a change crosses a boundary, least of all when a coding agent wrote the change: fast, plausible, and blind to which walls are load-bearing. Architecture-as-code is LoadBearing's answer: the rules become one C# spec, and the spec becomes every surface on this page.
1. **Enforcement**: one checker passes or fails the rules at the command line, in CI, as named xUnit tests, and in an agent hook after each edit.
2. **Agent context**: the same rules render to a managed `AGENTS.md` block, per-directory rule cards, and MCP query tools for coding agents.
Write your architecture once. Use it everywhere.
A rule is one statement:
```csharp
arch.Rule("layering/domain-independent")
.Enforce(domain.MustNotReference(application, infrastructure, api))
.Because("The Domain holds the quote and rate model the rest of the subsystem is built on; it stays free of the layers that depend on it so it can be reasoned about and tested on its own.")
.Fix("Move the dependency out of Domain: define an interface here and implement it in the outer layer that needs it.");
```
That is the whole rule: an ID, a posture (`Enforce`), a constraint, a reason, a fix. It is committed in the [clean-architecture example](https://github.com/andypgray/loadbearing/tree/main/examples/Meridian.Quoting), and CI holds `check` green against the codebase it governs.
LoadBearing is pre-alpha and under construction; [Status](#status) holds the current inventory.
## One spec produces
Each target below consumes the same reified model, and every violation report carries the rule ID, the generated rule sentence, the reason, the fix, and the exact `file:line`.
| Target | What it is |
|---|---|
| `loadbearing check` | one pass-or-fail verdict for the command line and CI |
| `check --sarif` | that verdict as SARIF 2.1.0, for code scanning |
| xUnit adapter | every rule an individually named test |
| `loadbearing render` | the managed `AGENTS.md` block and per-directory rule cards |
| `loadbearing mcp` | `arch_check`, `arch_status`, `arch_explain`, `arch_context`, and `arch_graph`, plus a `derive_spec` prompt |
| agent hook | `check` after each edit; a red rule blocks it, report on stderr |
The adapter's failure text is byte-identical to the CLI's: the two share one renderer, and a product test pins them equal. The managed block plus `loadbearing explain` are also the generated architecture documentation, written for agents first and readable by people; the gate under [The prose it generates](#the-prose-it-generates) keeps it current.
The compiler is the source of truth for your code. LoadBearing is the source of truth for your architecture.
## This repo's own spec
LoadBearing governs itself. Thirty rules over this repository's real code, across eight declared layers, live in [`LoadBearingArchSpec.cs`](https://github.com/andypgray/loadbearing/blob/main/arch/Zphil.LoadBearing.ArchSpec/LoadBearingArchSpec.cs), and every fence from here down to [This page is tested](#this-page-is-tested) is that spec, or this solution under it, on one surface after another. Take the rule that keeps the CLI off stdout — `host` is the layer the CLI project's namespace defines:
```csharp
arch.Rule("cli/no-stdout")
.Enforce(host
.MustNotUse(
arch.Member(() => Console.Out),
arch.Member(typeof(Console), nameof(Console.Write)),
arch.Member(() => Console.WriteLine())))
.Because("Stdout is a protocol channel here — the MCP server speaks JSON-RPC over it and CLI " +
"output flows through System.CommandLine's console — so a direct Console write corrupts " +
"the wire and is invisible to the in-process tests.")
.Fix("Write CLI output through the command's InvocationConfiguration console; route server " +
"diagnostics to the logger or Console.Error.");
```
Nothing in the build system stops the CLI writing to `Console`, and the MCP server on the other side of that stdout speaks JSON-RPC over it. This rule is the only thing standing between those two facts.
## The prose it generates
`loadbearing render` derives the rule sentence from the constraint, carries the `Because` across verbatim, and writes the result into the managed block of this repository's committed [`AGENTS.md`](https://github.com/andypgray/loadbearing/blob/main/AGENTS.md), the convention file Claude Code, Codex, Cursor, and Copilot read:
```markdown
- `cli/no-stdout` — The Host layer must not use `Console.Out`, `Console.Write()` or `Console.WriteLine()`. Stdout is a protocol channel here — the MCP server speaks JSON-RPC over it and CLI output flows through System.CommandLine's console — so a direct Console write corrupts the wire and is invisible to the in-process tests.
```
Nobody wrote that sentence, and nobody can let it go stale: [`SelfSpecTests.AgentsMd_IsCurrent`](https://github.com/andypgray/loadbearing/blob/main/tests/Zphil.LoadBearing.Tests/Dogfood/SelfSpecTests.cs) composes the block in process and asserts the committed file already equals it. Its sibling `ScopedCards_AreCurrent` holds the whole class the same way, every per-directory card this repository commits, and also fails on a card that no rule placement produced, so one orphaned by a spec change cannot stay behind being read. The prose an agent reads is provably the spec the build enforces. Agents that query rather than read get the same model over MCP (`loadbearing mcp`).
## When an agent breaks it
Suppose an agent adds a progress printer to the CLI so a slow solution load stops looking hung, and reaches for `Console.WriteLine`. The `PostToolUse` hook in [`hooks/`](https://github.com/andypgray/loadbearing/tree/main/hooks) runs `check` on the edit, the rule goes red, and the wrapper exits 2, which is how a Claude Code hook blocks, with the report on the agent's stderr:
```text
FAIL cli/no-stdout — The Host layer must not use `Console.Out`, `Console.Write()` or `Console.WriteLine()`.
because: Stdout is a protocol channel here — the MCP server speaks JSON-RPC over it and CLI output flows through System.CommandLine's console — so a direct Console write corrupts the wire and is invisible to the in-process tests.
fix: Write CLI output through the command's InvocationConfiguration console; route server diagnostics to the logger or Console.Error.
subject: 154 types, 1 generated
src/Zphil.LoadBearing.Cli/Rendering/ProgressPrinter.cs:10 — Zphil.LoadBearing.Cli.Rendering.ProgressPrinter uses System.Console.WriteLine()
src/Zphil.LoadBearing.Cli/Rendering/ProgressPrinter.cs:15 — Zphil.LoadBearing.Cli.Rendering.ProgressPrinter uses System.Console.WriteLine()
```
That stanza is one rule's worth of the board the wrapper hands back whole. It carries the four things an agent needs to act without asking a human: the rule ID, the reason, the fix, and the exact `file:line` of every offending write. The `subject:` line is scope rather than a finding, and appears only when a generator wrote some of what the rule swept. The agent routes the output through the command's console instead, the next check is green, and the block clears in the same turn, before the change lands.
## In xUnit
The same spec runs inside a test project, where a team already looks. `ArchRuleTests<TSpec>` from the xUnit adapter turns each rule into an individually named test, and this repository's whole adapter dogfood is [one class declaration](https://github.com/andypgray/loadbearing/blob/main/tests/Zphil.LoadBearing.Tests/Dogfood/AdapterSelfSpecTests.cs):
```csharp
[Collection("Serial")]
public sealed class AdapterSelfSpecTests : ArchRuleTests<LoadBearingArchSpec>
{
protected override string SolutionPath => FindSolutionUp("Zphil.LoadBearing.slnx");
}
```
Each test's display name is its rule ID, so a broken rule is named in the run summary rather than buried in an assertion message, and a `Migrate` rule's grandfathered sites keep their test green while the ratchet holds. [CI](https://github.com/andypgray/loadbearing/blob/main/.github/workflows/ci.yml) runs it as a step of its own, "Self-spec as named xUnit tests (one test per rule)", whose log carries one line per rule ID.
## As SARIF
`check --sarif` writes the same verdict as SARIF 2.1.0, which is what GitHub code scanning reads. This repository's one `Migrate` rule is retiring direct `System.Environment` reads out of the MCP infrastructure, over a counted baseline:
```csharp
arch.Rule("mcp/env-through-seam")
.Migrate(
"MCP infrastructure reads process env vars via System.Environment directly.",
arch.Types.InNamespace("Zphil.LoadBearing.Cli.Mcp.Infrastructure.*")
.Except(arch.Types.WithNameMatching("SystemEnvironment"))
.MustNotReference(typeof(Environment)))
.Because("A single IEnvironment seam keeps the MCP pipeline testable without mutating real " +
What people ask about loadbearing
What is andypgray/loadbearing?
+
andypgray/loadbearing is mcp servers for the Claude AI ecosystem. Fluent C# architecture spec that enforces the rules (CLI, CI, xUnit) and generates AI-agent context (AGENTS.md, MCP) from one model. It has 0 GitHub stars and its last recorded update is dated 2026-08-22.
How do I install loadbearing?
+
You can install loadbearing by cloning the repository (https://github.com/andypgray/loadbearing) or following the README instructions on GitHub. ClaudeWave also provides quick install blocks on this page.
Is andypgray/loadbearing safe to use?
+
Our security agent has analyzed andypgray/loadbearing and assigned a Trust Score of 95/100 (tier: Verified). See the full breakdown of passed checks and flags on this page.
Who maintains andypgray/loadbearing?
+
andypgray/loadbearing is maintained by andypgray. The last recorded GitHub activity is dated 2026-08-22, with 2 open issues.
Are there alternatives to loadbearing?
+
Yes. On ClaudeWave you can browse similar mcp servers at /categories/mcp, sorted by popularity or recent activity.
Deploy loadbearing to your cloud
Ship this repo to production in minutes. Each platform spins up its own environment with editable env vars.
Maintain this repo? Add a badge to your README
Drop the badge into your GitHub README to show it's tracked on ClaudeWave. Each badge links back to this page and reflects the live Trust Score.
[](https://claudewave.com/repo/andypgray-loadbearing)<a href="https://claudewave.com/repo/andypgray-loadbearing"><img src="https://claudewave.com/api/badge/andypgray-loadbearing" alt="Featured on ClaudeWave: andypgray/loadbearing" width="320" height="64" /></a>More MCP Servers
Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.
User-friendly AI Interface (Supports Ollama, OpenAI API, ...)
An open-source AI agent that brings the power of Gemini directly into your terminal.
Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface
The fastest path to AI-powered full stack observability, even for lean teams.
🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!