MCP server that captures and retrieves architectural decisions and context for Claude Code sessions
Project description
Contexer
Contexer is a lightweight MCP server for Claude Code that automatically captures decisions made during coding sessions and surfaces them at the start of every future session — so Claude never starts blind.
The problem
Every Claude Code session starts with no memory of the previous one. CLAUDE.md files require manual maintenance and go stale. When Claude works autonomously, the reasoning behind decisions disappears when the session ends. Teams end up re-explaining the same constraints, conventions, and architecture choices every time.
Contexer solves this by capturing decisions as they happen — silently, automatically, in the background — and replaying them as project rules at session start.
Quick start
Install takes under two minutes. See docs/install.md for full steps, verification, and uninstall.
Step 1 — install the package:
uv tool install contexer
Step 2 — wire it into Claude Code:
contexer install
Step 3 — restart Claude Code and open any git repo. Bootstrap runs automatically on the first session.
How it works
You work normally. Contexer runs silently in the background.
- Session start — all your constraints and conventions are injected as project rules before you type anything
- As you work — Claude captures significant decisions automatically; you never have to do it manually
- "Why" questions — if you ask about rationale or past decisions, Contexer auto-fetches the relevant ones
- Context window limit — decisions are saved before compaction and restored after, so nothing is lost
You never call anything directly. If Claude misses something, say "store that decision" and it will be captured immediately.
Decision types
Every stored decision has a type that controls when it is surfaced.
| Type | What it captures | Surfaced at session start? |
|---|---|---|
constraint |
Rules that must always apply — "never commit untested code" | Yes — always |
convention |
Team or project standards — "use uv not pip", "conventional commits" | Yes — always |
architecture |
Structural decisions — "chose REST over GraphQL for this service" | No — fetched when relevant |
pattern |
Recurring implementation approaches — "always validate at the boundary" | No — fetched when relevant |
Constraints and conventions apply to every task, so they load immediately. Architecture and pattern decisions are fetched on demand when the task requires them.
Managing decisions
All operations use natural language.
Store a decision
"store that as a constraint"
"save this as a convention: always use uv not pip"
"remember this architecture decision"
Note: Your first prompt each session is captured as the current task description, not as a constraint. If you open a session with an instruction like "always update docs before committing", say "store that as a constraint" to make sure it is saved correctly.
Store a global decision
Some conventions apply across every repo — commit style, branch naming, code review process. Store these once and they appear in every session automatically:
"store that globally as a convention"
"save this as a global constraint: always use conventional commits"
Only constraint and convention subtypes can be stored globally. Architecture and pattern decisions are always repo-specific.
To see what is stored globally:
"show all global conventions"
"show global constraints"
Query decisions
"show me all constraints"
"what decisions did we make about postgres?"
"show everything stored for this repo"
Update a decision
"update the uv decision — we switched back to pip"
"correct the constraint about commit format"
The old entry stays alongside the new one. If the revision is too similar to the original, rephrase it to include what changed.
Remove a decision
"delete the postgres decision"
"remove all outdated constraints"
You can also edit the store file directly — it is plain JSON at ~/.contexer/.
Token cost
Contexer is front-loaded by design. Cost is paid once at session start; everything after is near-zero.
What gets injected at session start:
Only constraint and convention decisions are pre-loaded. architecture and pattern decisions cost 0 tokens at session start — they are fetched on demand when relevant.
| Decisions stored | Pre-loaded rules | Tokens at session start |
|---|---|---|
| 10 | 5 | ~125 |
| 20 | 10 | ~250 |
| 50 | 25 | ~625 |
Cost is flat at ~25 tokens per pre-loaded rule, regardless of store size.
What that compares to:
~250 tokens (20 decisions) is 0.3–2.5% of a typical Claude Code session. Without Contexer, Claude spends 200–500 tokens re-establishing each rule through back-and-forth — every session. A single corrected mistake costs 500–2,000 tokens. The tool pays for itself after one avoided repetition.
Rationale injection — only fires on "why" questions:
| Event | Tokens added | Latency |
|---|---|---|
| Hit — relevant decision found | ~45–80 | ~0.06ms store lookup |
| Miss — no rationale keyword | 0 | 0.000ms |
Latency: Contexer's store operations take 0.03–0.27ms. The perceived delay is the MCP hook call round-trip (~50–200ms), which runs before Claude responds — not added on top of it. Sessions with 500 stored decisions have the same sub-millisecond retrieval as sessions with 10.
These numbers were measured on Claude Sonnet 4.6. Haiku will process injected tokens faster; Opus will take slightly longer but produce higher-quality responses with the same context. The store lookup times are model-independent — they are pure Python/disk operations.
Troubleshooting
Claude isn't storing decisions automatically. Say "store that decision" and Claude will capture it immediately.
A decision was stored but isn't appearing. Constraints and conventions load at session start. If you added one mid-session, it will appear from the next session onward.
A decision is outdated or wrong. Say "delete the X decision" or edit the store file directly.
A new decision wasn't saved — it looks like a duplicate. If the content is too close to an existing decision, it is silently skipped. Rephrase it to include what specifically changed.
No context appeared at session start. This happens the first time you open a repo — bootstrap will run to capture your initial decisions. Complete it once and all future sessions will have context.
License
MIT
Project details
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 contexer-0.1.4.tar.gz.
File metadata
- Download URL: contexer-0.1.4.tar.gz
- Upload date:
- Size: 90.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7863ac2652fd890a2fa68908e35ea354cd687f4d1bc07c810ed4dadd8f64cd2f
|
|
| MD5 |
111d713d0eaf33f84c6f8b295e513eba
|
|
| BLAKE2b-256 |
f83422475c5062f00227e65b6cd0c850f6c6594c73a1b8993fb17d110063ab6a
|
Provenance
The following attestation bundles were made for contexer-0.1.4.tar.gz:
Publisher:
publish.yml on bhargavamin/contexer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contexer-0.1.4.tar.gz -
Subject digest:
7863ac2652fd890a2fa68908e35ea354cd687f4d1bc07c810ed4dadd8f64cd2f - Sigstore transparency entry: 1751757059
- Sigstore integration time:
-
Permalink:
bhargavamin/contexer@61beae6db54d41a7de74051f0674ddeb32e95485 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/bhargavamin
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@61beae6db54d41a7de74051f0674ddeb32e95485 -
Trigger Event:
push
-
Statement type:
File details
Details for the file contexer-0.1.4-py3-none-any.whl.
File metadata
- Download URL: contexer-0.1.4-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
958e46dc6f4eaa024df9f3c51d698bad8a560b327e1f3d0a4b4e22864b8bae53
|
|
| MD5 |
9e0d4056952f53abe94cb3375a617351
|
|
| BLAKE2b-256 |
5c2407d71e69bad6cae266e66865f09137951d3bebbd0c6607ec298db36dc3dd
|
Provenance
The following attestation bundles were made for contexer-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on bhargavamin/contexer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contexer-0.1.4-py3-none-any.whl -
Subject digest:
958e46dc6f4eaa024df9f3c51d698bad8a560b327e1f3d0a4b4e22864b8bae53 - Sigstore transparency entry: 1751757128
- Sigstore integration time:
-
Permalink:
bhargavamin/contexer@61beae6db54d41a7de74051f0674ddeb32e95485 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/bhargavamin
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@61beae6db54d41a7de74051f0674ddeb32e95485 -
Trigger Event:
push
-
Statement type: