A Rules Engine for LLM-Assisted Work

Phronesis &
the rules
that do not fade.

A RETE rules engine that enforces project conventions from disk — outside the LLM context window. Rules fire the same in token nine hundred thousand as they do in token eight hundred.

41 Rules shipped
6 Default packs
4 Enforcement surfaces
3 Drift detectors
0 Context tokens consumed
A rule is a small refusal the project keeps making, even after it has forgotten the conversation in which it was first imagined.
Four surfaces — one rule format

Hook-time

block · warn · allow

Pre-check rules fire before an Edit, Write, or Bash call. Post-check rules warn after. Evaluated from disk on every tool invocation — no context-window cost.

Audit

debt · sweep · trend

Whole-tree scan against every rule tagged audit: true. Per-rule hit counts with file and line locations. Trend snapshots track debt over time.

Durable directives

prose · re-inject

A markdown file re-injected at every SessionStart and UserPromptSubmit. CLAUDE.md fades; this does not.

Drift detection

gap · triage · suggest

Three heuristic tools compare what the project says (CLAUDE.md, auto-memory, ADR decisions) against what the rules actually enforce. No LLM call — Jaccard overlap.

Get started — one binary, one rules file.

Install from source, run init in your project, and the hooks are wired. Rules fire from disk on every tool call — no daemon, no socket, no shared state. Every invocation is a fresh process that reads, evaluates, and exits.

Works with Claude Code and Gemini CLI. Exposes MCP tools to any MCP-capable client.

# install
cargo install --path .
phr-mcp install                # user-scope MCP

# wire into a project
cd ~/Git/my-project
phr-mcp init --packs llm,rust   # hooks + starter rules

# use
phr-mcp audit                    # sweep existing debt
phr-mcp trend                    # debt over time
phr-mcp claude-md-drift          # uncovered CLAUDE.md bullets
phr-mcp memory-drift             # uncovered auto-memory entries
phr-mcp wiki-drift               # uncovered ADR decisions
phr-mcp decision new my-slug     # scaffold an ADR page

The Explainer →

A long-form essay on the engine, the RETE algorithm, and the design intent behind moving guidance out of conversation context. With diagrams.

The Catalogue →

A visual reference of every default rule — LLM-behavior nudges, Rust enforcement, Rhai script hygiene — with rationale and worked examples from the field.