Context Rail
Keep your AI agents on the rails.
AI agents are fast until they go off-script. A prompt file is a suggestion an LLM can ignore. Context Rail turns your git repo into a file-backed workflow engine: you declare the stages, the evidence each stage owes, the paths work lives at, and the approvals that cannot be skipped. Your coding tool still runs the agent; Context Rail decides what counts as done.
The problem is not model speed. It is coordination: agents forget decisions, lose track of finished work, skip checks and change things nobody asked for. Context Rail fixes the coordination, not the model. It plans the work, hands each agent only what its job needs, and refuses to call anything done until the declared checks pass and a separate reviewer signs off. Scope, the quality bar and irreversible actions still wait for a human yes.
Shape the work from declarative files
The engine is deliberately small: six primitives, eight relations, five status categories. Everything project-specific is data.
rail.yaml The manifest → pack name, placement templates, code-graph provider
pack.yaml The domain → statuses, transitions, presets, workflows, gates, actions
surface.yaml The view → labels, screens, card/filter/column fields
charter.md The bar → gates, decision rights, budgets, human-only actions
rail.yamldoes not run agents or assign models. It decides where each primitive and preset lives (items/{preset}/{slug}.md, for example) and which pack the store uses.pack.yamlis the state machine. It names the statuses and their categories, the allowed moves, the item presets and their fields, and the workflow whose quality rule selects a charter gate and its checks.surface.yamlis presentation only. It can relabel a preset or retitle a screen; it cannot introduce a status, a transition, an action or a permission. A presentation change keeps approval. A pack, placement or operating change moves the semantic digest and needs reapproval.charter.mdis the quality bar. Gates (item_done,scope_done,merge,release), decision rights, budgets and the human-only floor live there.
Paths are derived, never supplied. An agent asks for a brief and gets the item, the checks, the result shape and the exact path its record will take. It cannot choose a different folder, title or schema.
Every write passes a fail-closed pipeline
Nothing reaches the store unless it clears the same six stages:
Validate → Authorize → Lock → Atomic write → Record → Index
A malformed pack key, an unauthorized actor, a stale etag, a missing gate or a write outside a seat's reach halts the write. A refusal leaves the store unchanged and names the command that would produce the missing proof. The SQLite index is only a cache under the git directory; delete it and the next command rebuilds it from the files.
What you can build with it
- Risk-routed changes without test overhead. The built-in
adaptive-contractpack classifies work astrivial,standardorcritical. Trivial work gets a build and typecheck; standard work runs the existing checks; critical work adds a few boundary, failure-path and smoke tests, and a human records approval before the build starts. Lessons are short and structural changes are proposed, never auto-applied. - Separated builder and reviewer. A role binds an agent to one project or
container, with a declared reach and workspace. Role mode uses a session seat,
refuses
--actor, and checks every write against that reach. The reviewer is a different actor; the gate refuses self-review and a same-model review when the charter requires another model. The code area is review evidence, not a sandbox: a diff outside it is a review question the reviewer must see. - A relay across models and tools. State lives in Git, not chat history. Plan with one model, implement with another, review with a third. Each candidate and result can record the model and harness that produced it; the rail stores those facts and never chooses a model for you.
- Non-coding state machines. The built-in
videopack runsscene → shot → storyboard → generating → review → approved → published. Copy a pack withrail ops pack createand declare your own vocabulary for research, legal drafting, publishing or any other staged process. - Several repositories, one queue. The
portfoliopack coordinates child stores: a master slice is gated on a child's committed, proven item, without writing the child store or running git on reads.
Try it in 5 minutes
You need Python 3.11+ and git.
python -m pip install context-rail # Windows: py -m pip install context-rail
cd your-project
rail init --pack basic # creates context-rail/ and asks about the project
rail change add task "Write the first task"
rail overview # progress, focus, blockers and the next eligible work
rail serve ui # the local web view
rail init writes a context-rail/ store and asks a few questions about what
you are building. If it reports that approval is missing, approve the brief. A
named lead may sign on the human's behalf; the record names both:
rail approve charter --confirm "APPROVE charter" --confirmer "Your Name"
Run one governed loop
rail loop brief <task> # the work order: objective, checks, code area, result shape
# ... your coding tool does the work and commits ...
rail loop candidate <task> --commit <sha> # code changes only
rail loop result <task> --body-file <result.md> --commit <sha>
rail check run <task> # the declared checks
rail loop review <task> --verdict approve --notes-file <review.md>
rail change move <task> done --expect <etag>
For research or discovery, skip candidate and leave the commit out of
rail loop result; never fabricate a commit. The result body is capped at
256 KiB, needs its ordered ## sections, and can open with a small effort block
naming duration_s, usage, model and harness. See the
loop skill for the exact contract.
Connect your tools
Context Rail speaks one JSON envelope over the CLI, MCP and a local web UI. It works with Claude Code, Codex, opencode, Cursor, Gemini CLI, Droid and any MCP client. Your harness keeps its own agents, worktrees and models.
rail serve mcp # MCP server for your coding tool
rail serve ui # token-protected local dashboard
The rail never launches an agent. It hands out the brief and records the result.
Built-in packs
Start with a built-in pack, or copy one into your store and make it yours:
| Pack | Designed for | How work flows |
|---|---|---|
basic |
Getting started, small projects | todo → doing → done |
flow |
Continuous delivery, no sprints | backlog → ready → building → review → shipped |
scrum |
Teams working in sprints | goal → scope → sprint → story → task |
waterfall |
Projects with distinct phases | planned → designing → building → testing → done |
video |
Video and content production | scene → shot: storyboard → generating → review → approved → published |
portfolio |
Several projects coordinated from one master store | component → slice, gated by child store checks |
adaptive-contract |
Risk-aware code changes without test overhead | classify trivial, standard or critical → contract → build → proportionate checks → lesson |
Want your own words or steps?
rail ops pack create --name <name> --from basic
Edit the copy, then switch with rail ops pack use (human-only). Relabelling a
preset or retitling a screen never needs re-approval; changing a transition,
placement, preset or operating block does.
Why it holds up
- Files are the truth. The store is Markdown, JSON records and
rail.yamlin your repo. SQLite is only a cache under the git dir. - One write path. CLI, MCP and UI all go through validate → authorize → lock → atomic write → record → index. No lost updates; every retry is safe.
- Fail closed. An unknown pack key, manifest schema or policy field is refused, never guessed.
- Agents never read
pack.yaml. The compiler turns the pack into one model; agents askrail next,rail read show,rail why,rail explainandrail model. - Project shape is data. Sprints, phases and scenes are pack data, not engine code, so one engine runs any of them.
- Your project stays yours. Plain files, no server account, no lock-in.
Learn more
- How Context Rail works: architecture, operating model, commands, surfaces
- Roles and seats: sessions, reach and the compat rule
- The six building blocks: the visual model and two worked examples
- User guide: diagrams and a zero-to-daily walkthrough
- Interactive engine graph
- Agent onboarding kit: set up any agent harness
- Operator skills: drop-in skills for your agents
- Upgrading from v1/v2
The test lanes, speed budgets and working rules are in How Context Rail works and AGENTS.md.
License
MIT License. See LICENSE.
Metadata
Release files for context-rail 4.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| context_rail-4.4.0.tar.gz | 806.6 kB | Without provenance | Details for context_rail-4.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| context_rail-4.4.0-py3-none-any.whl | Python 3 | none | any | Details for context_rail-4.4.0-py3-none-any.whl |
Total release size: 1.7 MB
Release files / context_rail-4.4.0.tar.gz
| Download URL | context_rail-4.4.0.tar.gz |
|---|---|
| Size | 806.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10f2b7ec9e7bd9b6700e51789da4f18baddd543debefb671f2bc20643ffcac86
|
|
BLAKE2b-256 checksum How to use checksums |
7e74fbf43ec55620c02ffda35140a686fb707847a0d849c93af40c265a526b7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / context_rail-4.4.0-py3-none-any.whl
| Download URL | context_rail-4.4.0-py3-none-any.whl |
|---|---|
| Size | 931.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
069e485869d52c965cbb2cf0073da062bec236bef7fd3c000c3770bde74b55e0
|
|
BLAKE2b-256 checksum How to use checksums |
fe50b7d34658334a580b869593c6b442690c42f654f35da345412c49b930b1bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for context-rail 4.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.