ctx-manager
A provider-agnostic context engineering CLI + MCP server for multi-language agentic development.
ctx-manager sits between your Docs/ folder (PRDs, architecture docs,
phase plans, API specs) and AI coding agents (Claude Code, Cursor,
Windsurf), cutting token spend two ways:
- Deterministic, header-based document slicing — pull exactly the section you need from a blueprint file, not the whole thing. Structural (regex over Markdown headers), not RAG/embeddings.
- An append-only, git-validated
Memory_Ledger.md— accurate session state so agents don't re-derive or hallucinate what's already been built. Every entry is checked against realgit statusoutput before being marked verified.
Works identically across Rust, Go, TypeScript, Python, or any other stack
-- ctx-manager never touches your application source code, only Docs/.
Install
uvx ctx-manager --help
No virtualenv setup, no global install required.
Usage
Slice a blueprint file by header:
ctx build --slice "PRD.md > 5. Feature List"
Prints the matched section's content to stdout — pipe it into CLAUDE.md
or wherever your agent reads context from.
Append a verified entry to the session ledger:
ctx append-ledger --summary "Implemented the login endpoint" --category completed
Checks git status against your project before writing, and prefixes the
entry [Verified: N files changed], [Reasoning/State Only], or
[Unverified: not a git repo] depending on what it finds -- so an agent's
self-reported "done" claim is checked against what actually happened on
disk.
Run as an MCP stdio server (for Cursor, Windsurf, Claude Desktop):
ctx mcp
Exposes query_slice, append_ledger_entry, and get_current_phase as
MCP tools, calling the exact same code path as the CLI commands above.
Configuration
ctx-manager searches upward from your current directory for
.context/config.toml. If none is found, it uses sane defaults
(Docs/ folder, Memory_Ledger.md, etc.) and warns once.
[project]
docs_dir = "Docs/"
ledger_file = "Memory_Ledger.md"
phase_file = "Phase_file.md"
[blueprint_files]
files = ["PRD.md", "Architecture.md", "API_Spec.md"]
[git]
scope = "docs_dir" # or "repo_root"
Override the search entirely with --project-root.
Claude Code integration
Example SessionStart/SessionEnd hooks (auto-refresh CLAUDE.md before
a session, auto-log to the ledger after) are in
examples/claude_code_hooks/.
Design principles
Docs/in,Docs/out — never touches application source, in any language.- Cheap before heavy — stdlib
rebefore embeddings,subprocess gitbefore a git library, local stdio before any network service. - Append-only ledger — no code path overwrites
Memory_Ledger.mdwholesale. Ever. - Fail loud, not silent — a missing header or missing file returns an explicit error, never empty content an agent could hallucinate on.
See Docs/Architecture.md and
Docs/PRD.md for the full design writeup (this project
dogfoods itself -- its own Docs/ folder is sliced and tracked by
ctx-manager during its own development).
Development
git clone <this-repo>
cd ctx-manager
uv sync
uv run pytest
License
MIT — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctx_manager-0.1.0.tar.gz.
File metadata
- Download URL: ctx_manager-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
985e222b3bf816ed6594bbcd93984aa82d98b0209d89eaa0f2154820ddd70e0f
|
|
| MD5 |
e961b15d1e24d3173c738c1b43ebfd17
|
|
| BLAKE2b-256 |
304943c19a5dbfcf40666d212809f169ee4ee018732e67bcf7411e3995fedea4
|
File details
Details for the file ctx_manager-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ctx_manager-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5407f2cdd1e237033dacfc2b92ce63525b72ae8a0bf6b15f9b7eb292e3c83ba
|
|
| MD5 |
4dadc77df09f1380ad5ff3fe27f32c18
|
|
| BLAKE2b-256 |
a2756b7243465a88bb5dda5fb150d2c8cf3f647d6ade5545a6c684aac386e441
|