Codevira logo — persistent memory for AI coding agents

Codevira — persistent memory and decision enforcement for AI coding agents

Stop re-explaining your codebase to every AI tool — and stop the next agent from undoing the fix that took you three hours.

PyPI version Python versions CI Downloads License: MIT Model Context Protocol PRs welcome

This page is the project README, rendered as part of this site — view the source on GitHub ↗

Codevira is a local-first MCP server (Model Context Protocol) that gives every AI coding agent on your machine one shared, in-repo memory of the decisions you've made and why. What one tool learns, all of them know — and a decision you lock, none of them can silently undo: codevira refuses the edit in Claude Code and the commit in any editor.

pipx install codevira              # ~70 MB venv, no ML deps, no vectors
cd ~/Projects/my-project
codevira init                      # opt this project in
codevira setup                     # wire it into the AI tools on this machine
What it isA local MCP server that stores your project's decisions together with the reasoning behind them, in your repo.
What's differentIt doesn't just remember — mark a decision do_not_revert and it physically blocks the edit (Claude Code) and, once you install the git hook, the commit (any editor) that would undo it.
Who it's forAnyone running two or more AI coding tools on the same repo.
Default scopePer-machine — memory is not git-tracked. codevira init --shared commits .codevira/ so teammates on the same repo share one decision log.
CostMIT · local-first · no cloud · no account · no vectors · nothing phones home.
Claude Code Cursor Google Antigravity OpenAI Codex GitHub Copilot Model Context Protocol

Claude Code · Claude Desktop · Cursor · Google Antigravity · OpenAI Codex · GitHub Copilot · any MCP-compatible AI tool

30-second demo: MP4 · WebM · offline HTML player (no network, after cloning)

The whole thing on one page — solution blueprint
Codevira solution blueprint: persistent memory and decision enforcement for AI coding agents. Four levels — remember, surface, warn, block. Capabilities include decision memory, cross-tool sync, session context, code graph, enforcement engine, anti-regression, skill library and working memory. Works with Claude Code, Claude Desktop, Cursor and Antigravity over MCP, and with Codex and Copilot via AGENTS.md.

Why Codevira

AI agents write a large share of your code now. They're fast and capable, but each one is stateless across sessions and blind to the others — so you quietly became the memory.

The painWhat Codevira does
Re-explaining your codebase every session — ten minutes and thousands of tokens, then again tomorrowEvery tool opens with the project's decisions already loaded
An agent "simplifies" a fix it never knew the reason for — three hours of debugging, undoneA locked decision is refused at the edit (Claude Code) and at the commit (any editor), with the original reasoning attached
Cross-tool amnesia — plan in Claude Code, code in Cursor, nothing carries overOne in-repo memory every MCP client reads
Token budget burned on re-discovery — the same dozen files re-read every sessionSummary-first recall of only what's relevant

The root cause under all four: your decisions live in your head, not anywhere the AI can be held to them.

Codevira is not a knowledge base. A knowledge base answers "what is true?" and hopes the agent reads it. Codevira answers "what did we decide, and why?" — then blocks the edit that would break it.


See it in action: record, block, recall

1. You (or the AI) record a decision — one MCP call, ~50 tokens.

record_decision(
  decision="Use bcrypt for password hashing",
  context="md5 considered and rejected — rainbow-table risk. Re-examine only if NIST guidance changes.",
  tags=["auth", "security"],
  do_not_revert=true,
)
→ {"recorded": true, "decision_id": "D000412", "do_not_revert": true, ...}

It lands in <repo>/.codevira/decisions.jsonl — plain text, human-readable, and diffable (and git-tracked as soon as you run codevira init --shared). Codevira regenerates a slim AGENTS.md contract from it — that file is always committed.

2. Weeks later, a fresh Claude Code session tries to swap bcrypt for md5.

The Edit goes through Claude Code's PreToolUse hook first. Because the diff touches the locked decision's subject, the hook denies the tool call and hands the agent the original reasoning (abridged here; the real message is longer):

✗ Edit blocked — decision_lock (do_not_revert)
  D000412: "Use bcrypt for password hashing"
  context: md5 rejected — rainbow-table risk.
  The file was not modified. Surface this to the human and re-decide deliberately.

The regression never reaches disk. An orthogonal edit to the same file — one whose diff doesn't touch the decision's subject — is allowed through and downgraded to a warn. Precision, not paranoia.

3. You switch to Cursor the next morning — and it already knows.

You never re-explained anything. Cursor reads the same repo AGENTS.md and, over MCP, can call search_decisions("bcrypt") — D000412 comes back as a compact row, and expand(ids=["D000412"]) returns its full reasoning. A decision recorded in one tool is visible to every tool.

Where the block is physical. Edit-time in Claude Code; commit-time in every editor via codevira engine install-git-hook — because they all commit with git. Overrides, kill-switches and the precise boundary: Enforcement engine (expand).

The whole path, in one diagram — record → violate → intercept → engine → refuse
Enforcement flow: record_decision appends to decisions.jsonl; weeks later an agent edits a covered file; the edit is intercepted at Claude Code PreToolUse or at git pre-commit; one dispatch() runs 7 prioritised policies; the refusal carries the original reasoning. Fails open, with kill switches.

What you get

What it means
One memory, every AI toolA decision logged in Claude Code is visible to Cursor, Antigravity, Codex, Copilot — all read the same .codevira/decisions.jsonl and generated AGENTS.md. No per-tool re-onboarding, no cloud sync.
Enforcement, not notesdo_not_revert refuses the edit in Claude Code and refuses the commit in any editor. An Anti-Regression guard also blocks re-introducing a previously-fixed bug. Every guard ships a warn/off kill-switch.
One-command setupcodevira setup detects installed AI tools via strong signals (binary on PATH + valid config file) and configures only what's actually there. --force overrides a missed detect.
Local-first, no MLDecision search is pure keyword/BM25 over SQLite FTS5 — no vectors, no ChromaDB, no sentence-transformers, no torch, nothing phones home. The memory is plain text: this repo's own 347-decision log is 444 KB.
Frugal by designTools return summaries by default; get_session_context() is one call that targets ~500 tokens; the server starts in under a second with no ML model to load.
Concurrent-safeEvery write is a crash-safe atomic write behind a Posix fcntl.flock, so two IDEs on one project don't race. Details (expand)

Latest: 4.3.0. Upgrade: codevira had been quietly losing memory. write_session_log threw away the decisions and next steps it was given, and renaming a project folder could split its memory or replace its roadmap. 4.3.0 fixes both, makes saving a file cost about 1 s of CPU instead of several, and adds an opt-in shared daemon: one process for every agent and project. Restart your IDE after upgrading. Full release notes →


Quick Start

# 1. Install (~70 MB venv, no ML deps)
pipx install codevira

# 2. Opt this project in (writes .codevira/, AGENTS.md, .gitignore)
cd ~/Projects/my-project
codevira init

# 3. Wire codevira into every AI tool detected on this machine
codevira setup

# 4. Install the universal commit-time backstop (enforces do_not_revert in ANY editor)
codevira engine install-git-hook

Step 4 is what makes enforcement universal. codevira init installs only a post-commit reindex hook; the enforcing pre-commit hook is this separate, explicit opt-in.

Open any IDE — codevira's MCP server is ready. Then, in your AI tool, ask: "Use get_session_context to brief me on this project." You get a structured project state (targeting ~500 tokens) in one tool call instead of the AI re-reading docs.

Verify the install:

codevira doctor          # health checks: ✓/⚠/✗ + a fix command for each
codevira replay          # browse the decisions timeline
codevira sync            # regenerate AGENTS.md from current decisions.jsonl

Team sharing. By default codevira keeps decision memory per-machine (not committed), so unrelated projects never bleed into each other; AGENTS.md and .gitignore are still committed. To share memory with teammates on the same GitHub repo, run codevira init --shared — it keeps .codevira/ git-tracked, and a built-in git merge driver reconciles concurrent edits.

Opt-in tracking. codevira init is the explicit opt-in. Codevira tracks only projects you've init-ed; a project you merely open stays inert (its tools return a "run codevira init" hint and nothing is written), so ~/.codevira/projects/ never fills with projects you didn't choose. Set CODEVIRA_AUTO_ADOPT=1 to track every project you open instead.


How it works

A local MCP server. Decisions live in <repo>/.codevira/*.jsonl — plain text, human-readable, diffable, and git-tracked once you opt in with init --shared. A slim AGENTS.md is generated from them for every IDE to read, and Claude Code lifecycle hooks — plus the opt-in git pre-commit hook — enforce the ones you locked.

Animated architecture of Codevira: six AI tools (Claude Code, Cursor, Codex, Antigravity, Claude Desktop and a worktree agent) connect over MCP, hooks and git pre-commit to one shared codevira daemon (opt-in; by default each AI tool session runs its own process) with four parts: a router that binds every call to its project, 36 MCP tools, an enforcement engine with 7 policies, and an incremental code graph. Below sit each project's in-repo .codevira/ memory and the per-machine ~/.codevira home. It plays four scenes: a worktree agent records a decision into its main project's memory; a locked decision blocks an edit; saving a file re-indexes only that file; a call that names no project is refused.
Detailed static architecture: every file, hook and data location
Codevira architecture: AI tools connect over MCP, one process per session or one shared daemon; canonical decision memory lives in the repo under .codevira/, a per-machine cache in .codevira-cache/, and cross-project state in ~/.codevira/
Full file layout and hook flow
Codevira file layout and hook flow: three stacked layers. In the project repo, .codevira/ holds decisions.jsonl, digest.jsonl, outcomes.jsonl, manifest.yaml, enforcement.yaml, config.yaml, sessions.jsonl, roadmap.yaml and skills.jsonl; AGENTS.md is generated from it; .codevira-cache/ holds fts5.sqlite, hash-cache.db and working.jsonl and is gitignored; the code graph is a per-project SQLite db under ~/.codevira/, not in your repo. Below it, one pipx-installed codevira binary (CLI plus MCP server, no chromadb, sentence-transformers or torch, no model), reached over MCP and hooks. Below that, your IDE and its four hook points: UserPromptSubmit into a relevance-gated inject, Edit or Write into PreToolUse which blocks if a do_not_revert decision is violated, PostToolUse into the Post-Edit Graph Refresh and working-memory fanout, and Stop into the Token Budget and Session-Log Enforcer.

codevira init creates config.yaml, enforcement.yaml, decisions.jsonl, outcomes.jsonl, sessions.jsonl and roadmap.yaml; digest.jsonl, manifest.yaml and skills.jsonl appear on first use. Deeper detail: docs/architecture.md.


Built to be trusted

Codevira holds a team's architectural decisions and can refuse your AI's edits. Every guarantee below is checked by the build, not asserted in this file.

Test suite4,121 tests across 185 test files. More test code than product code (72,819 vs 55,128 lines).
CIEvery push to main and every pull request runs the suite on Python 3.10 / 3.11 / 3.12 / 3.13, plus a separate random-order run (collection-order blindness had hidden real state-leak bugs) and a mypy type-check job.
"Local-first" is enforced, not promisedtests/test_egress_boundary.py walks the import graph of the shipped package with an AST scan and fails the build if any module other than egress.py imports a network client.
Adversarial testingscripts/chaos_smoke.py runs 8 hostile scenarios — SIGKILL during a held lock, symlink traversal, malformed MCP payloads, corrupt-JSONL degradation, read-only directories.
No destructive MCP toolsEvery MCP tool carries destructiveHint=false. The only destructive operations (reset, uninstall) are CLI-only and ask for confirmation — an autonomous agent cannot reach them.
Reversible memoryAfter a default init, .codevira/ is not git-tracked — so git revert can't undo a bad migration or an accidental wipe. codevira memory snapshot + codevira memory undo can, and the undo is itself undoable.

What's solid, what's not

Production-stableKnown-limited
Cross-IDE decision memory via in-repo JSONLHard PreToolUse enforcement at edit time is verified on Claude Code only; Antigravity gets a hook too but it is not yet confirmed in a live session, and other IDEs read AGENTS.md (advisory) and are backstopped at the commit boundary
do_not_revert enforced at the Claude Code hook and, in any editor, at the commit boundary (codevira engine install-git-hook)Graph tools cover Python / TS / JS / Go / Rust; other languages → the AI Reads the file directly
FTS5/BM25 decision searchReal-time multi-machine sync — by design local-first; for team sharing, run codevira init --shared
Per-project + cross-machine project inventory (global.db)No web UI — use the codevira://decisions MCP resource, or codevira replay --format html
36 MCP tools advertised in tools/list (37 defined — refresh_graph is hidden) + 30 CLI commands + 7 engine policiesThe HTTP server (codevira serve) is single-project per launch — for daily use, stick with stdio, or use the shared daemon for many projects
Concurrent-safe storage (Posix fcntl.flock + Windows sentinel), thread + subprocess + chaos-testedWindows sentinel fallback is verified in unit tests but not yet load-tested on real Windows
Anti-Regression on small Edit/MultiEdit hunksAnti-Regression does not yet detect full-file Write reverts; accuracy depends on fix: commit hygiene

Reference

Everything below is depth for when you need it. Each section is collapsed — open the one you came for. Browser find-in-page does not search inside a closed section, so expand before Ctrl+F. What's in them:

CLI      init setup daemon connect doctor status projects untrack index sync reconcile
         repair-ids observe-git replay search graph memory export import engine prune
         reset uninstall serve working induce-skills eval register-all merge-driver
         merge-driver-agents
Env      CODEVIRA_ENGINE  CODEVIRA_TOOL_PROFILE  CODEVIRA_DECISION_LOCK_MODE
         CODEVIRA_ANTI_REGRESSION_MODE  CODEVIRA_BLAST_RADIUS_MODE  CODEVIRA_GIT_HOOK_MODE
         CODEVIRA_DECISION_LOCK_CONTENT_AWARE  CODEVIRA_SESSION_LOG_ENFORCER_MODE
         CODEVIRA_AUTO_ADOPT  CODEVIRA_IDE

MCP tool surface

36 tools advertised (37 defined) — the lean-12 profile, every read/write tool, and what 4.0 removed

36 tools are advertised to AI clients via tools/list (37 are defined — a 37th, refresh_graph, is registered but hidden; the code graph is refreshed automatically after edits and by codevira index). Every tool carries MCP ToolAnnotations (readOnlyHint / destructiveHint=false / idempotentHint): most are read-only and can run without a confirmation prompt, and no MCP tool is destructive — the only destructive ops (reset / uninstall) are CLI-only, never exposed over MCP. Good to know for anyone wiring codevira into an autonomous agent.

The lean 12 (CODEVIRA_TOOL_PROFILE=lean) are the ones you keep — set that in the MCP server's env block to cut tools/list from 36 tools to 12 — about 60% smaller (measured on 4.3.0: ~31 KB → ~13 KB of tool-list JSON). Hidden tools still work when called explicitly.

get_session_context · get_impact · get_node · get_roadmap · search_decisions
list_decisions · expand · record_decision · update_phase_status
complete_phase · update_next_action · write_session_log

Reads — the memory surface

ToolDescription
get_session_contextTHE "catch me up" call. Targets ~500 tokens: current phase, next action, recent decisions, top tags, last session brief.
search_decisions(query)FTS5/BM25 over decisions.jsonl. Top 5 truncated by default; full=true / summary_only=true. all_projects=true searches every registered repo, tagging each result with its project.
expand(ids=[…])Fetch full records for just the ids you care about — the summary-first complement to search_decisions / list_decisions. Read-only; in the lean 12.
list_decisionsPaginate / filter: since_date, file_pattern, protected_only, tags, include_superseded.
list_tagsAll tags with decision counts.
get_history(file_path)Recent decisions touching a file.
check_conflict(decision_text)Surface duplicate / contradictory decisions BEFORE you write.

Writes — capturing decisions

ToolDescription
record_decisionCapture a decision. do_not_revert=true triggers Claude Code PreToolUse enforcement; symbol="login" scopes the lock to one function/class. It supersedes a strong unprotected near-duplicate instead of appending a twin.
supersede_decision(old_id, new_decision, reason)Retire an old decision, link to its replacement, keep the audit trail.
mark_decision_outdated(decision_id, reason)Retire a decision that's simply no longer true (no successor) so it stops surfacing. Reversible via set_decision_flag. do_not_revert needs force=True.
reaffirm_decision(decision_id)Re-confirm a soft-expired do_not_revert lock.
set_decision_flag(decision_id, …)Toggle do_not_revert / tags / is_outdated.
write_session_logSession record: task, decisions, files changed, next steps. All three are stored (4.3.0 fixed a bug that dropped them).

Roadmap — get_roadmap · get_phase · add_phase · update_phase_status · update_next_action · complete_phase · defer_phase · bulk_import_phases.

Code graph — get_node (file metadata) · get_impact (blast radius) · query_graph (function-level callers/callees/tests/dependents/symbols) · get_playbook (curated rules for add_tool / add_service / add_schema / debug_pipeline / commit / write_test). Plus the hidden refresh_graph.

Memory subsystems

SubsystemToolsWhat it covers
Working memory (4)working_add, working_get, working_promote, get_working_contextIntra-session scratchpad, decay-scored (importance × e^(−Δt/τ=6h) + 0.5·access_count), capacity-bounded. Auto-populated by the PostToolUse fan-out.
Skill library (6)record_skill, get_skill, apply_skill_outcome, list_skills, supersede_skill, promote_skill_to_playbookReusable procedures; FTS5 composite ranking (BM25 + tag-Jaccard + recency); auto-archive at 5 consecutive failures or 90 unused days (do_not_revert exempt).
Provenance (1)origin_ofWhich IDE, which machine, when — what attributes an amendment across a two-host merge. (CODEVIRA_IDE is a cooperative signal, spoofable, not a security boundary.)

Workflow prompt — onboard_session: full project catch-up for new sessions; wraps get_session_context().

Removed in 4.0 (52 tools → 37 defined; 36 advertised). Cut on measured usage across 4,203 transcripts, not taste — the data they wrote is untouched, and codevira export still includes everything. See MIGRATING.md.

RemovedInstead
consensus_check, consensus_status, consensus_propose_supersession, consensus_resolveorigin_of
reflect, get_reflections, list_reflections—
spatial_nearby, spatial_heat, spatial_neighborhood, spatial_affordancesget_impact
distill_preferences, search_preferences— (the style panel went with them)
get_code, get_signatureread the file — both measured zero calls in 2.5 months

Enforcement engine

The 7 default policies, how verdicts combine, and every kill-switch

Codevira ships 7 default engine policies ("heroes"), each hooked to Claude Code lifecycle events: SessionStart, PreToolUse, PostToolUse, UserPromptSubmit, Stop.

PolicyEventWhat it does
Decision LockPreToolUseBlocks an edit that touches a do_not_revert decision's subject. Content-aware: a provably-orthogonal edit downgrades to a warn; a token-touching edit blocks. Strict file-level locking via CODEVIRA_DECISION_LOCK_CONTENT_AWARE=0.
Anti-RegressionPreToolUseBlocks edits that look like reverts of previously-fixed bugs. Fix-history is scanned from fix: / bug: / hotfix: / fixes #N commit messages and self-freshens on read when git HEAD advances. Caveat: calibrated for small Edit/MultiEdit hunks; full-file Write reverts are deliberately exempt (future work).
Blast-Radius VetoPreToolUseBlocks a signature-removing/modifying edit to a high-fan-in file (purely-additive signatures pass). Shows the callers.
Relevance InjectUserPromptSubmitInjects ≤3 relevant decisions per prompt; 0 tokens when off-topic.
Session-Log EnforcerSessionStart + StopBlocks (or, in warn mode, nudges) a session that shipped commits without a write_session_log. A second consecutive block degrades to a warn so a session that genuinely cannot log still finishes.
Post-Edit Graph RefreshPostToolUseReindexes edited files in the background.
Token Budget / telemetryStopRecords outcome telemetry.

How verdicts combine. The three edit guards compose into a single verdict — first block wins by priority (Decision Lock 100 > Anti-Regression 80 > Blast-Radius 50). The highest-priority block's message is what you see; the rest are recorded as telemetry.

Fail-open and opt-in. The dispatcher never raises: each policy is wrapped in try/except and returns allow on failure. CODEVIRA_ENGINE=0 disables all policies; each edit guard also has a per-policy off|warn|block env override (CODEVIRA_DECISION_LOCK_MODE, CODEVIRA_ANTI_REGRESSION_MODE, CODEVIRA_BLAST_RADIUS_MODE). Enforcement is not global across all Claude Code projects — in any project you never ran codevira init on, the hooks stay fully inert.

The universal backstop (4.0). codevira engine install-git-hook installs a pre-commit hook that runs locked decisions against staged changes through the same engine — so a do_not_revert decision is enforced in any editor, because they all commit with git. git commit --no-verify overrides a single commit; CODEVIRA_GIT_HOOK_MODE=warn (or off) changes it globally; merge commits are never blocked.

Why edit-time blocking is Claude Code only. The hard-block path is Claude Code's real PreToolUse hook. Edits from Cursor / Codex / Copilot go straight to the filesystem — they never reach codevira's PreToolUse engine — so those IDEs get decisions as advisory AGENTS.md context, with the git pre-commit hook as the universal backstop. Verified: Claude Code returns permissionDecision: deny (exit 2) with the decision's reasoning, rejected alternatives and re-examination trigger attached; the git hook refuses the commit with the same reasoning. Other IDEs are supported but verified one at a time rather than inferred.

CLI commands

30 commands — the daily-use table, plus what's safe vs destructive

30 subcommands. Three are internal (merge-driver and merge-driver-agents, invoked by git's merge drivers, and register-all, a setup helper); three more are advanced (working, induce-skills, eval). The daily-use ones are below — run codevira <cmd> --help for full flags:

CommandWhat it does
codevira initOpt this project in: .codevira/ + AGENTS.md + .gitignore + git merge driver. Add --shared to commit memory for team sharing (default keeps it per-machine)
codevira setupDetect installed AI tools + write MCP configs + Claude Code hooks. --daemon points them at the shared daemon, --no-daemon puts them back exactly as they were, --all-projects does every registered project
codevira daemonThe one shared local Codevira: install (start at login, restart on crash), start / stop / restart / status, token / rotate-token, uninstall
codevira connect --project <path>Small stdio bridge to the shared daemon, for clients that can only launch a command (Claude Desktop)
codevira doctorHealth checks (read-only; ✓/⚠/✗ + a fix command each)
codevira statusIndex health + project state
codevira projectsList your projects (one row each; git worktrees are counted under their project, never listed as projects); --all adds leftovers and bookkeeping columns; projects archive <name> drops one
codevira untrack <path>Remove one stray or temporary project entry
codevira indexBuild / refresh the code-graph cache
codevira syncRegenerate AGENTS.md + manifest + digest from decisions.jsonl
codevira reconcileReport near-duplicate and contradicting decisions in a shared repo (report only, writes nothing)
codevira repair-idsDetect/repair cross-engineer decision-id collisions (--apply; --semantic reports near-duplicates)
codevira observe-gitClassify past decisions as kept/modified/reverted from git history
codevira replayBrowse the decisions timeline (terminal / markdown / HTML)
codevira search <query>Search decisions from the terminal (FTS5/BM25); --all-projects, --json
codevira graphRender an interactive, offline HTML viewer of decision memory
codevira memorysnapshot / undo the memory store — the rollback path git revert can't give you
codevira export / importBack up / restore project memory + global learning across machines (export setup bundles one archive; import <archive> restores it)
codevira engineinstall-git-hook installs the universal pre-commit backstop; status / disable / enable
codevira pruneRemove orphaned project dirs, dead global.db rows, ghost dirs and legacy backups. Never touches decisions, IDE configs or hooks. --dry-run first. Most of this now happens automatically (see Upgrading & troubleshooting)
codevira resetDestructive cleanup of this project's memory (auto-exports first; requires a typed confirmation)
codevira uninstallReverse the system writes codevira made — ~/.codevira/ including snapshots, codevira's IDE config entries, the Claude Code hooks, and (unless --keep-data) each project's .codevira/. Preserves user content outside markers. Asks to confirm; --dry-run shows the plan. It does not remove the shared daemon's login service; codevira daemon uninstall does
codevira cleanRemoved in 4.0.1 — it was a full uninstall mis-named as tidy-up, and its old description destroyed a real install. It now errors invalid choice. Use prune to tidy, uninstall to remove
codevira serveStart the single-project MCP HTTP server (stdio is the daily mode)

To fully remove codevira: run the uninstall command above, then pipx uninstall codevira.

Language support

What's language-agnostic vs. what needs a grammar
FeaturePythonTS/JSGoRustOthers
Decision capture + search✓✓✓✓✓
Cross-IDE memory via AGENTS.md✓✓✓✓✓
Roadmap / sessions✓✓✓✓✓
Code graph + blast radius✓✓✓✓—
Symbol-level query_graph✓✓✓✓—

Decisions / AGENTS.md / roadmap are language-agnostic — they work for any language. Code-graph and symbol tools cover exactly Python (stdlib ast) plus TS / TSX / JS / JSX / Go / Rust (bundled tree-sitter grammars). For any other language the AI Reads the file directly. The legacy 17-grammar [all-languages] pack was removed in v2.2.0 to keep the install lean.

Concurrency & safety

Atomic writes, file locking, and how they're stress-tested

Every on-disk write goes through mcp_server/storage/atomic.py: a crash-safe atomic write (mkstemp + fsync + os.replace) behind a Posix fcntl.flock (with an in-process threading.Lock first, and a Windows O_EXCL sentinel fallback). Appends to the JSONL logs are line-atomic — concurrent appenders never interleave bytes. Result: two IDEs hitting the same project don't race on manifest.yaml / roadmap.yaml / AGENTS.md.

This is exercised by a 50-operation stress over a 10-thread pool, a 20-subprocess cross-process stress (spawn), and an adversarial chaos harness (scripts/chaos_smoke.py — 8 scenarios including SIGKILL during a held lock, symlink traversal, malformed MCP payloads, corrupt-JSONL graceful degradation, and read-only-directory hostility). See docs/architecture.md § "Concurrent-write safety".

One shared Codevira for many agents (optional)

By default each AI tool starts its own codevira process for each project. With many agents, worktrees and projects open at once that adds up. Switch to one shared local process instead:

codevira daemon install     # macOS: start at login, restart on crash
codevira setup --daemon     # point this project's AI tools at it
codevira daemon status
codevira setup --no-daemon  # undo: tools go back exactly as they were

After daemon install, new projects set up with codevira init (or codevira setup) use it automatically (init --no-daemon opts out); worktrees use their main project's entry. Each request carries its project (X-Codevira-Project), so memory still lands in the right project; a request without one is refused and writes nothing. The daemon listens on 127.0.0.1 only and needs the token in ~/.codevira/daemon/token. Claude Desktop connects through codevira connect --project <path>. Codex gets a [mcp_servers.<name>] table in ~/.codex/config.toml; only that table changes.

Animated diagram: agents working in three git worktrees of billing-api write decisions into the main checkout's single .codevira memory. One worktree is removed; the daily cleanup then deletes its code-graph cache while the live and the locked worktree's caches are kept.

Upgrading & troubleshooting

Upgrading is automatic — codevira migrates your memory on the first server start after an upgrade, with no manual steps, and your existing decisions stay put. (After a pipx upgrade codevira, restart your IDE so its MCP server reloads the new binary.)

A server still running the old version refuses instead of mixing versions. The upgrade rewrites the package while your AI tools keep their servers running. From 4.3.0 every tool call first checks that the installed package is still the one the process started with; if not it returns codevira_upgraded, reads and writes nothing, and asks you to restart the AI tool. The shared daemon restarts itself instead, on the same port with the same token.

One exception, if you are coming from 4.1.0 or earlier. A bug could register $HOME itself as a project, and every genuine project below it was then discarded as a "nested sub-store". 4.2.0 stops that happening, but it does not repair a registration that is already wrong — nothing prunes the bad row on upgrade. If projects went missing from an IDE, run this once:

codevira register-all --dry-run   # read-only; shows what IS registered

If that prints one project at your home directory with your real ones listed as excluded nested, that is this bug. Before clearing it, look at what would be removed:

codevira untrack --dry-run "$HOME"   # read-only; lists IDE entries AND the data dir

Read that output. untrack deletes the project's data directory, not just the registry entry. If you were bound to $HOME by mistake, any decisions recorded during that time live in that directory and will go with it. If the dry-run lists a data dir you might want, copy it aside first (cp -R the path it names). Your other projects each have their own directory and are not affected.

Then clear and re-register, and restart the IDE afterwards:

codevira untrack -y "$HOME"
codevira register-all

(codevira doctor will not catch this one: its checks cover the current binding and whether global.db opens, not what is registered inside it.)

Git worktrees. A linked worktree is not a project: it shares its main checkout's memory and is never registered. On the first start after upgrading, codevira removes the leftovers older versions made (cache-only dirs and registry rows of worktrees and vanished paths), then collects worktree caches by itself at most once a day: those of worktrees git no longer lists, and those unused for 30 days. Locked worktrees are kept, and anything holding memory is never removed. The removed list is in ~/.codevira/logs/prune-<time>.json.

If an IDE then shows the wrong project, doesn't show codevira at all, or memory looks missing, it's almost always a stale IDE-config entry rather than lost data. Two fixes cover most cases: remove a stray or temporary entry with codevira untrack <path> (or sweep dead ones with codevira prune --ghosts), then run codevira doctor — it names the bound project and ships the exact fix for each ⚠/✗.

Full guides: IDE config hygiene · Antigravity · FAQ


Frequently asked

How do I give Claude Code persistent memory across sessions?

Install codevira and run codevira init in the project. Every new session starts with get_session_context() — a brief (targeting ~500 tokens) of the project's decisions, current phase and next action — instead of you re-explaining the codebase.

Does this work with Cursor and Antigravity, or only Claude Code?

Memory works everywhere: every tool reads the same in-repo .codevira/decisions.jsonl and the generated AGENTS.md. codevira setup writes MCP server config automatically for the tools that support it (Claude Code, Claude Desktop, Cursor, Antigravity; setup --daemon also configures Codex); Copilot and other agents are covered by the generated AGENTS.md. Hard edit-time blocking is verified on Claude Code only (Antigravity gets a hook too, not yet confirmed in a live session) — every other editor is covered at the commit boundary by codevira engine install-git-hook.

I run many agents, projects and worktrees at once. Does each start its own Codevira?

By default, yes: every AI tool session starts one codevira process for its project. Run codevira daemon install and codevira setup --daemon (add --all-projects for every registered project) and they all share one local process instead. Each tool's entry names its project and is sent with every call, so memory still lands in the right project; a call that names none is refused. Worktrees need nothing: Claude Code uses the main project's entry for them. After daemon install, new projects set up with codevira init join automatically; codevira setup --no-daemon undoes it for a project.

How is this different from a hand-written CLAUDE.md or AGENTS.md?

Those are static text you maintain by hand. Codevira generates AGENTS.md from a queryable decision log, keeps the reasoning attached to each decision, and blocks the edit that would break a locked one.

Does it use vectors or embeddings?

No. Decision search is SQLite FTS5/BM25 keyword search — no ChromaDB, no sentence-transformers, no torch. An AST scan in CI fails the build if any module but egress.py imports a network client.

Is my code or my memory sent anywhere?

No. Everything lives in <repo>/.codevira/ and ~/.codevira/ on your machine. MIT-licensed, no account, no API key, no cloud.

What does it cost in tokens?

Tools return summaries by default, get_session_context() is one call that targets ~500 tokens, and the lean-12 tool profile cuts tools/list from 36 tools to 12 (about 60% smaller: ~31 KB → ~13 KB of JSON, measured on 4.3.0).

Longer answers: FAQ.md.


How Codevira compares

Most memory tools for AI agents retrieve. Codevira also enforces, and it is per-project across many tools rather than per-session inside one. If you need cross-machine cloud memory, a temporal knowledge graph at enterprise scale, or the top LongMemEval score, other tools are the better pick — that comparison is written out honestly, including where codevira loses: Codevira vs other AI memory tools (Mem0, claude-mem, Zep, MemPalace and others).

Deeper reading: Architecture · Wire protocol · How we dogfood it · Roadmap · Changelog · Migrating to 4.0 · How I built persistent memory for AI coding agents


Contributing

Contributions are genuinely welcome, and the backlog is open — see CONTRIBUTING.md for the dev setup and PR checklist.

How the codebase is laid out — layers, the two persistence stacks, and where to add a tool / command / policy

Start here before your first PR. One caveat it makes loud: over 80% of codevira's internal imports sit inside function bodies, so a static import graph draws this codebase as disconnected leaves — the arrows below are runtime call edges. The diagram also marks the boundaries that don't hold, rather than pretending the layering is clean.

Codevira internals: process entry points, the root modules grouped by role, tools/ and engine/ as siblings, two separate persistence stacks (storage/ for decisions, indexer/ for the code graph), the jsonl_store and atomic write choke points, and on-disk layout

Good places to start:

Channels:

If Codevira saves you tokens or sanity, a ⭐ helps other developers find it.

License

MIT — free to use, modify, and distribute. See LICENSE.