ContextRail: Minimum Effective Project Memory for Agentic Coding
An open-source harness framework that resolves inter-session memory loss, file sprawl, and context pollution with 5 Markdown layers and 3 platform validators.
ContextRail is an open-source harness framework designed to help AI agents work consistently, verifiably, and across sessions within software repositories. When an agent begins a new session, it coordinates where the project left off, the active task, established decisions, and past explorations without file sprawling or context window bloat across 5 Markdown layers and cross-platform validators.
Project Overview
| Property | Value |
|---|---|
| Role | Design, architecture development, documentation |
| Status | Stable |
| Scope | Software development projects with AI agents |
| Technologies | Markdown, Bash, PowerShell, GitHub Actions |
| License | MIT |
| Distribution | GitHub Template Repository + GitHub Release |
Problem and Target
Agentic coding tools (Codex, Claude Code, Gemini, Cursor, etc.) are evolving rapidly, but they share a fundamental bottleneck: project memory.
When an agent begins a fresh session:
- Active task state is forgotten.
- Architectural rationales are lost.
- Redundant repo-wide scans waste tokens and latency.
- The human operator is repeatedly forced into tedious context reconstruction.
Common industry workarounds (monolithic rule files, fragmented micro-notes, or complex multi-agent orchestrators) either saturate the context window or induce navigational confusion. ContextRail solves this by organizing project state across 5 distinct lifecycle layers with deterministic mechanical validation.
Architecture Flow & Lifecycle
ContextRail structures project memory into 5 lifecycle-aligned Markdown layers:
- AGENTS.md — Operational guidelines and navigational routing
- SYSTEM.md — Project boundaries, components, and architectural invariants
- BOARD.md — Active tasks and current backlog status
- NOTES.md — Decision rationales, constraints, and permanent architectural memory
- HISTORY.md — Historical ledger of verified tasks and evidence logs
On top of these 5 layers, cross-platform native validator scripts (Bash, PowerShell, GitHub Actions) enforce contract compliance. It requires zero SDKs, runtime dependencies, or external vector stores; it drops cleanly into any existing repository.
Scope and Boundaries
ContextRail does:
- Provide agents with a clear, single entry point at session initialization.
- Decouple active work, decision rationales, and historical evidence into distinct lifecycle tiers.
- Direct agents toward targeted file reading instead of broad repository scanning.
- Anchor tasks and decisions via stable, unique identifiers.
- Govern third-party specifications through a structured handoff adoption workflow.
- Maintain permanent behavior boundaries in code via task-linked code traces.
- Mechanically validate metadata contracts across Linux, macOS, and Windows.
- Integrate into existing project test, build, and lint pipelines.
ContextRail does not:
- Impose a new programming language or framework.
- Introduce heavy runtime SDKs or libraries.
- Replace the project’s native test frameworks.
- Depend on embeddings, semantic search, or graph databases.
- Supplant the agent’s internal planning loop.
Solution Architecture
Lifecycle Separation
Information is organized strictly by lifecycle rather than arbitrary file counts:
AGENTS.md→ Operating rules and navigation mapSYSTEM.md→ Project boundary, core architecture, system invariantsBOARD.md→ Active backlog and task stateNOTES.md→ Permanent rationale and technical constraintsHISTORY.md→ Chronological evidence of completed tasks
The agent reads BOARD.md to discover its active assignment. It follows task-referenced decision IDs to query only relevant subsections of NOTES.md, referencing HISTORY.md only when verifying past implementations.
External Handoff Mechanism
Unprocessed specifications, audits, and design proposals land in handoffs/incoming/. The agent processes them via handoffs/HANDOFF.md: checking existing IDs, transcribing permanent context into Notes, deriving verifiable Board tasks, reporting discrepancies, and archiving or removing the source artifacts only upon successful validation.
Task-Linked Code Traceability
Durable invariants are anchored in code using concise inline comments:
ContextRail: TASK-0042
Invariant: Persistent mutation requires explicit authorization.
The task ID carries the comprehensive context, design rationale, and relational dependencies. The code comment simply references the governing task rather than logging historical diffs, and identical anchors are attached to accompanying regression tests.
Agent Compatibility Layer
Platform-specific instruction files route directly to the canonical guide:
CLAUDE.md→ Claude CodeGEMINI.md→ Gemini.github/copilot-instructions.md→ GitHub Copilot.cursor/rules/00-agents.mdc→ Cursor
Each file contains the single directive: “Read and follow AGENTS.md at repository root.”
Cross-Platform Validators
scripts/
validate-linux.sh
validate-macos.sh
validate-windows.ps1
The validator scripts operate independently of application runtimes. They inspect Markdown metadata contracts directly:
- Enforcing mandatory files and system schema completeness.
- Guarding against lifecycle entries erroneously written into
SYSTEM.md. - Detecting duplicate IDs or conflicting titles.
- Validating task statuses and required evidence fields.
- Ensuring bidirectional reference integrity across superseded and related records.
- Verifying code traces against active lifecycle entities.
Two Repositories, Dual Distribution, Single Point of Truth
minimum-governed-harness: Core development, governance rules, and release artifacts.contextrail-template: Clean, user-facing template repository for fresh projects.
New projects initialize directly from the GitHub template, while existing codebases install versioned release ZIP packages accompanied by SHA-256 checksum manifests.
Governance Guidelines
ContextRail formalizes operational discipline for agent workflows:
- External Handoff Adoption: Structured ingestion of external plans preventing duplication and hallucinated scope.
- Task-Linked Code Trace: Invariants explicitly tied to tasks in code and regression suites.
- Root Cause Before Patch: Agents must isolate broken invariants or transitions before attempting fixes.
- Independent Review: Self-evaluating changes against objective acceptance criteria prior to completion.
- Controlled Incidental Findings: Incidental issues discovered during tasks are documented with evidence rather than silently altered.
- Unified Validation Integration: Combining project test suites with ContextRail validators into a single gating check.
- Governed Delegation: Subagents execute scoped, low-risk routines while architectural state remains with the lead agent.
Open Source Distribution
- Core Repository: github.com/muisik/minimum-governed-harness — Public, MIT License
- Template Repository: github.com/muisik/contextrail-template — GitHub Template
- Releases: Downloadable ZIP distributions with checksum verification
- Supported Agents: Codex, Claude Code, Gemini, Cursor, GitHub Copilot
📋 Related Links
🔗 Technical Deep Dive: Teach the Agent Where to Look, Not Everything at Once
📂 Core Repository: github.com/muisik/minimum-governed-harness
🛠️ Template Repository: github.com/muisik/contextrail-template
Last updated: October 2026 | Version: 1.0