# davidcarliez/trustmebro architecture

> Architecture diagram of the GitHub repository davidcarliez/trustmebro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/davidcarliez/trustmebro
- Repository: https://github.com/davidcarliez/trustmebro

## Overview

TrustMeBro is a command-output interception proxy for coding-agent tools. The main workflow starts when a harness invokes a PATH shim: the shim loads configuration, parses the invocation, selects a rule, then spoofs, rewrites, rejects, or passes through the call; decisions are audit-logged. Separate CLI commands install and inspect the shims, while Linux lab mode creates a temporary interception namespace for commands. The graph follows documented capabilities where implementation excerpts are incomplete; demo-rendering and delivery tooling are excluded.

Main entry points: [`run.go`](https://github.com/davidcarliez/trustmebro/blob/main/run.go) (PATH shim), [`lab.go`](https://github.com/davidcarliez/trustmebro/blob/main/lab.go) (Lab coordinator), [`main.go`](https://github.com/davidcarliez/trustmebro/blob/main/main.go) (TrustMeBro CLI), [`install.go`](https://github.com/davidcarliez/trustmebro/blob/main/install.go) (Shim installer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and installation"]
  node_cli["TrustMeBro CLI<br/>[main.go]"]
  node_installer["Shim installer<br/>[install.go]"]
  node_status["Install status<br/>[install.go]"]
end

subgraph group_runtime["Shim runtime"]
  node_shim["PATH shim<br/>[run.go]"]
  node_spoof["Output generator<br/>[gen.go]"]
  node_rewrite["Output rewriter<br/>[gen.go]"]
  node_audit[("JSONL audit log<br/>[log.go]")]
end

subgraph group_rules["Configuration and rules"]
  node_config["Config loader<br/>[config.go]"]
  node_query["Command parser<br/>[match.go]"]
  node_matcher["Rule matcher<br/>[match.go]"]
end

subgraph group_lab["Lab interception"]
  node_lab["Lab coordinator<br/>[lab.go]"]
end

node_harness(("Agent harness"))
node_real["Real command"]
node_bubblewrap["Bubblewrap"]

node_harness -->|"invokes via PATH"| node_shim
node_cli -->|"dispatches install"| node_installer
node_cli -->|"dispatches status"| node_status
node_cli -->|"dispatches lab"| node_lab
node_shim -->|"loads config"| node_config
node_shim -->|"parses invocation"| node_query
node_shim -->|"selects rule"| node_matcher
node_matcher -->|"tests query"| node_query
node_shim -->|"generates output"| node_spoof
node_shim -->|"rewrites output"| node_rewrite
node_rewrite -->|"runs command"| node_real
node_shim -->|"executes passthrough"| node_real
node_shim -->|"records decisions"| node_audit
node_installer -->|"installs shims"| node_shim
node_installer -->|"creates default config"| node_config
node_lab -->|"loads config"| node_config
node_lab -->|"shadows commands"| node_shim
node_lab -->|"starts namespace"| node_bubblewrap
node_bubblewrap -->|"runs command"| node_harness

click node_cli "https://github.com/davidcarliez/trustmebro/blob/main/main.go"
click node_installer "https://github.com/davidcarliez/trustmebro/blob/main/install.go"
click node_status "https://github.com/davidcarliez/trustmebro/blob/main/install.go"
click node_shim "https://github.com/davidcarliez/trustmebro/blob/main/run.go"
click node_config "https://github.com/davidcarliez/trustmebro/blob/main/config.go"
click node_query "https://github.com/davidcarliez/trustmebro/blob/main/match.go"
click node_matcher "https://github.com/davidcarliez/trustmebro/blob/main/match.go"
click node_spoof "https://github.com/davidcarliez/trustmebro/blob/main/gen.go"
click node_rewrite "https://github.com/davidcarliez/trustmebro/blob/main/gen.go"
click node_audit "https://github.com/davidcarliez/trustmebro/blob/main/log.go"
click node_lab "https://github.com/davidcarliez/trustmebro/blob/main/lab.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_installer,node_status toneBlue
class node_shim,node_spoof,node_rewrite,node_audit toneAmber
class node_config,node_query,node_matcher toneMint
class node_lab toneRose
class node_harness,node_real,node_bubblewrap toneIndigo
```

## Components

### CLI and installation

- [TrustMeBro CLI](https://github.com/davidcarliez/trustmebro/blob/main/main.go): `main.go`
- [Shim installer](https://github.com/davidcarliez/trustmebro/blob/main/install.go): `install.go`
- [Install status](https://github.com/davidcarliez/trustmebro/blob/main/install.go): `install.go`

### Shim runtime

- [PATH shim](https://github.com/davidcarliez/trustmebro/blob/main/run.go): `run.go`
- [Output generator](https://github.com/davidcarliez/trustmebro/blob/main/gen.go): `gen.go`
- [Output rewriter](https://github.com/davidcarliez/trustmebro/blob/main/gen.go): `gen.go`
- [JSONL audit log](https://github.com/davidcarliez/trustmebro/blob/main/log.go): `log.go`

### Configuration and rules

- [Config loader](https://github.com/davidcarliez/trustmebro/blob/main/config.go): `config.go`
- [Command parser](https://github.com/davidcarliez/trustmebro/blob/main/match.go): `match.go`
- [Rule matcher](https://github.com/davidcarliez/trustmebro/blob/main/match.go): `match.go`

### Lab interception

- [Lab coordinator](https://github.com/davidcarliez/trustmebro/blob/main/lab.go): `lab.go`

### Other components

- **Agent harness**
- **Real command**
- **Bubblewrap**

## Connections

- Agent harness → PATH shim: invokes via PATH (evidence: `README.md`)
- TrustMeBro CLI → Shim installer: dispatches install (evidence: `main.go`)
- TrustMeBro CLI → Install status: dispatches status (evidence: `main.go`)
- TrustMeBro CLI → Lab coordinator: dispatches lab (evidence: `main.go`)
- PATH shim → Config loader: loads config (evidence: `run.go`)
- PATH shim → Command parser: parses invocation (evidence: `run.go`)
- PATH shim → Rule matcher: selects rule (evidence: `run.go`)
- Rule matcher → Command parser: tests query (evidence: `match.go`)
- PATH shim → Output generator: generates output (evidence: `README.md`)
- PATH shim → Output rewriter: rewrites output (evidence: `README.md`)
- Output rewriter → Real command: runs command
- PATH shim → Real command: executes passthrough (evidence: `run.go`)
- PATH shim → JSONL audit log: records decisions (evidence: `run.go`)
- Shim installer → PATH shim: installs shims (evidence: `README.md`)
- Shim installer → Config loader: creates default config (evidence: `README.md`)
- Lab coordinator → Config loader: loads config (evidence: `lab.go`)
- Lab coordinator → PATH shim: shadows commands (evidence: `lab.go`)
- Lab coordinator → Bubblewrap: starts namespace (evidence: `lab.go`)
- Bubblewrap → Agent harness: runs command
