A 7-File Governance Layer to Prevent LLM Session Drift

A developer on r/LocalLLaMA shared a solution to prevent LLM coding assistants like Claude from silently undoing architectural decisions across sessions. Instead of treating LLM sessions as conversations, they now treat them as stateless processes that need a protocol.
The Core Problem
Every LLM session starts with zero memory. You re-explain, it re-interprets, and it drifts confidently. The developer noted: "You won't even notice until you are deep inside the project maybe three files deep or four files or who knows even on the last part of project."
The 7-File Governance Layer
The fix isn't a better prompt but a governance layer that any model can read and immediately operate within. The system uses seven files, each owning a specific concern with no overlap:
active_context.md- Session controller, defines what's in scope right nowcontracts.md- Behavioral law, data schemas, enum values, required behavioragent_core.md- Execution discipline, how to operate, validate, reportagent_project.md- Project intent, why this system exists, expected outcomesdecisions.md- ADR log, non-obvious choices and why they were acceptedbuild_plan.md- Module roadmap, implementation order and deliverablesstate.md- Living journal, what's done, what changed, what remains
Key Design Decisions
The developer explained two critical separations:
Separating contracts.md from agent_core.md: "When a behavioral conflict appeared, the model had no way to know which layer to defer to. Was this a schema rule or an execution preference? When they're separate, the hierarchy is unambiguous, contracts always win."
Including decisions.md: "I almost skipped it ('I'll just remember'). Three weeks later I couldn't reconstruct why we'd chosen Postgres over SQLite for a specific module. The ADR log exists precisely because 'I'll remember' is not a protocol."
The Operational Loop
Every session follows this order, no exceptions:
- Read
active_context.md→ extract what's in scope - Re-ground against
contracts.md→ behavioral rules locked - Confirm operating constraints from
agent_core.md+agent_project.md - Check
decisions.md→ don't reverse accepted choices - Execute only what
active_context.mdauthorizes, perbuild_plan.md - Validate with tests — don't declare done without evidence
- Update
state.mdwith factual outcomes - If a new non-trivial decision was made, log it in
decisions.md
Workflow Impact
The active_context.md scope lock proved particularly valuable: "Before this, I would start a session to fix a bug and then end up refactoring an unrelated module because 'it was right there.' Felt productive.........and it Was."
📖 Read the full source: r/LocalLLaMA
👀 See Also

Using a Local LLM as a Claude Code Subagent to Reduce Context Usage
A Reddit user demonstrates how Claude Code can delegate tasks to a local LLM running via LM Studio, keeping file content out of Claude's context. The setup uses a ~120-line Python script with LM Studio's tool-calling API to handle file operations locally.

Bifrost AI Gateway: Open-Source Tool Addresses AI Infrastructure Gaps
Bifrost is an open-source Go-based LLM gateway that provides automatic failover between providers, budget caps that reject requests, audit logging, and hooks for evaluation. Benchmarks show it's ~50x faster than LiteLLM at high throughput.

United States Code Available as Git Repository with Full Change History
The United States Code is available as a Git repository with the entire federal law stored as Markdown files. Each commit represents a point-in-time snapshot from 2013 to present, allowing developers to use git diff, git log, and git blame to track legal changes.

Utilyze: Open-Source GPU Monitor That Measures Real Compute Throughput, Not Just Kernel Activity
Utilyze samples hardware performance counters to report compute and memory throughput relative to theoretical limits, exposing that dashboards showing 100% utilization may have only 1-10% real throughput.