Back to MCP Servers

Selvedge

Change tracking for AI-era codebases. AI agents call it to log structured change events (entity + diff + reasoning) before the session ends, then query history with diff, blame, history, changeset, and search. Captures the intent that would otherwise evaporate.

developer-toolsaiagent
By masondelan
20Updated 1 week agoPythonMIT

Installation

npx -y selvedge

Configuration

{
  "mcpServers": {
    "selvedge": {
      "command": "npx",
      "args": ["-y", "selvedge"]
    }
  }
}

How to use

  1. Run the installation command above (if needed)
  2. Open your Claude Code settings file (~/.claude/settings.json)
  3. Add the configuration to the mcpServers section
  4. Restart Claude Code to apply changes
<p align="center"> <img src="docs/wordmark.svg" alt="selvedge" width="480"> </p> <p align="center"> <a href="https://selvedge.sh"><strong>selvedge.sh</strong></a> &nbsp;·&nbsp; <a href="https://pypi.org/project/selvedge/"><strong>PyPI</strong></a> &nbsp;·&nbsp; <a href="https://github.com/masondelan/selvedge"><strong>GitHub</strong></a> </p> <p align="center"> <a href="https://github.com/masondelan/selvedge/actions/workflows/test.yml"><img src="https://github.com/masondelan/selvedge/actions/workflows/test.yml/badge.svg" alt="Tests"></a> <a href="https://pypi.org/project/selvedge/"><img src="https://img.shields.io/pypi/v/selvedge?cacheSeconds=3600" alt="PyPI"></a> <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a> </p> <!-- mcp-name: io.github.masondelan/selvedge -->

Long-term memory for AI-coded codebases — including what was already tried and rejected.

Line attribution tells you who wrote something. Selvedge tells your agent what not to write next: the approaches this codebase already tried, reverted, and why. It's a git blame for AI agents, for the why rather than which model touched which line — captured live, by the agent, as the change happens, so nothing downstream has to guess at it.

Selvedge is a local MCP server. AI coding agents (Claude Code, Cursor, Copilot) call it as they work to log structured change events with reasoning. Your data stays in a SQLite file under .selvedge/ next to your code.

Local-first by default, team-server by choice, zero-LLM always.


Six months ago, your AI agent added a column called user_tier_v2. You don't know why. git blame points to a commit from claude-code with a generated message that says "Update schema." The session that made the change is long gone — and so is the prompt that produced it.

With Selvedge, you run this instead:

$ selvedge blame user_tier_v2

  user_tier_v2
  Changed     2025-10-14 09:31:02
  Agent       claude-code
  Commit      3e7a991
  Reasoning   User asked to add a grandfathering flag for legacy free-tier
              users during the pricing migration. Stores the original tier
              so we can backfill discounts without touching billing history.

That reasoning was captured by the agent in the moment — written into Selvedge from the same context that produced the change. Not inferred from the diff afterward by a second LLM. Not a hand-typed commit message.


<!-- DEMO GIF Record a 30–45 second terminal session showing: 1. `selvedge status` → shows N total events 2. `selvedge blame payments.amount` → full output with reasoning 3. `selvedge diff users --since 30d` → table of recent changes 4. `selvedge search "stripe"` → filtered results Use `vhs` (https://github.com/charmbracelet/vhs) or Asciinema. Replace this comment block with: ![Selvedge demo](docs/demo.gif) -->

Who Selvedge is for

Selvedge has two audiences. Same tool, same pip install, same SQLite file under .selvedge/. Different scale of pain.

Teams running long-term, AI-coded codebases. When the project is big enough that you (or someone else) will touch it again in six months, twelve months, three years — but most of it was written by an agent whose context evaporated the day each PR shipped. git blame tells you what changed. Selvedge tells you why — even after the agent session, the prompt template, the developer who asked for it, and the model version are all long gone. This is the original use case: production codebases, schema decisions, migrations, dependency changes that need an audit trail that survives turnover.

Solo developers using Claude Code on everyday projects. Side projects, weekend builds, the small internal tool you keep poking at. You don't need enterprise governance — you just need to remember why you (or your agent) did the thing you did yesterday, last week, last sprint. Run selvedge init once. Add four lines to your CLAUDE.md. From then on, selvedge blame is muscle memory — a way to talk to your past self when your past self was an LLM.

If you've ever come back to your own AI-built project and thought "what was this for again?", Selvedge is the missing piece.


The problem

Human-written code leaks intent everywhere — commit messages, PR descriptions, inline comments, the Slack thread that preceded it. AI-written code doesn't. The agent has perfect clarity about why it made each decision, but that context lives in the prompt and evaporates when the conversation ends.

Six months later, your team is debugging a schema decision with no trail. git blame tells you what changed and when. It can't tell you why.

Selvedge captures the why — live, by the agent itself, as the change is made. The diff is git's job. The why is Selvedge's.


What's new in v0.3.10

The memory comes to the agent, and the store gets its dials. Two themes, shipped together because the config half is what the rest needed to read settings from.

Delivery. Selvedge already blocked re-edits of reverted entities. What was missing was delivery when there is nothing to veto. Two new hooks:

  • SessionStart injects a compact digest as a session begins — decisions due for a revisit, entities that were tried and reverted, recent changesets.
  • PreCompact fires just before context compaction destroys this session's reasoning and names the watched entities you edited but never logged.

Both are quiet when they have nothing to say, size-capped, read-only, and templated. Neither can block anything — PreCompact deliberately declines the veto the hook API offers it. This is the answer to a measured failure mode: two 2026 papers recorded pull-model memory tools going unused entirely (zero voluntary memory operations across 114 turns against a pre-seeded store) while deterministic injection landed every time.

selvedge export --format markdown renders the store as a reviewable digest to commit next to it, so captured intent shows up in a pull request instead of hiding inside a binary. Deterministic — regenerating with no new events is a zero-line diff.

Config. .selvedge/config.toml is now first-class, with a canonical precedence chain that selvedge doctor prints per setting. It brings:

  • selvedge prune --include-events — the first path that can delete captured reasoning, so it needs both a confirmation and SELVEDGE_DESTRUCTIVE=1. Neither alone is enough, because --yes in a cron entry defeats a prompt and a shell profile defeats an env var. Events retention defaults to never.
  • Event-size bounds (diff_bytes, reasoning_bytes) that truncate loudly — a marker in the text, a warning at write time, a count in selvedge stats.
  • Secret-shape warnings at log_change, extendable via redaction_patterns, plus a doctor row that scans what's already stored. Warn, never reject.

Also: five review issues closed. The enforcement hook's allow path is 40% faster (33.6 ms → 20.1 ms per gated call) and SELVEDGE_HOOK_DISABLE=1 finally short-circuits before the imports it was documented to skip; log_change no longer discards revisit_after / constraint / stale_when on renames and supersedes; the CLI's --json and the MCP tools now return identical structures; and the Docker image no longer ships the maintainer's own database. Tests 826 → 984.


What's new in v0.3.9.3

Fixes a broken install, and lands a full code-quality pass. mcp 2.0.0 (released 2026-07-28) removed mcp.server.fastmcp, and Selvedge declared mcp>=1.0.0 with no upper bound — so any pip install selvedge after that date pulled 2.0.0 and selvedge-server failed at import. This release pins the dependency. If your server stopped starting, this is why — upgrade.

It ships alongside a review that put nine independent passes over the codebase and then tried to disprove every finding before acting on it. Seventeen confirmed defects fixed. The ones you would actually have noticed:

  • The enforcement hook stopped blocking things it shouldn't. Reading a tracked file — cat, git diff, pytest, ruff check — was blocked, and the remediation the error message told you to run was blocked by the same gate, so there was no way out from the CLI. Two more paths fed the same false blocks: a commented-out line of SQL counted as a real deletion, and any commit message merely containing the word "revert" marked every file it touched as reverted.
  • Lookups got fast at scale. The main entity read was scanning every row — measured 7.4 ms → 0.35 ms at 100k events, and the hook had been taking seconds on large stores.
  • selvedge setup can no longer delete parts of your CLAUDE.md, an interrupted backup can no longer destroy your last good one, and upgrading while two Selvedge processes are running no longer crashes with an error that looked like database corruption.

Tests went 739 → 826. No schema change and no tool-surface change, so this is drop-in for anyone on 0.3.9.x.


Where Selvedge fits

<p align="center"> <img src="docs/ecosystem.svg" alt="Where Selvedge fits in the broader AI-coded-codebase tooling stack" width="720"> </p>

AI agents call Selvedge as they work. Selvedge captures the why into a durable, queryable store and emits it back out — as Agent Trace records for cross-tool readers, as observability metadata that links into Sentry/Datadog stack traces, and as compliance artifacts for SOC 2 and EU AI Act audits.

Selvedge does not replace git (line-level what/when), PR review tools (review-time quality), agent observability (LLM call traces), or general-purpose code-host AI features. It sits between them — the provenance-as-first-class-citizen layer that everything else references.


How Selvedge compares

There's a fast-growing "git blame for AI agents" category. Here's where Selvedge fits — and where it deliberately doesn't.

Rejected pathsReasoning sourceGranularityMechanismGroupingStorage
SelvedgeQueryableprior_attempts returns tried → reverted → re-openedCaptured live, by the agent in the same context that produced the changeEntity — DB column, table, env var, dep, API route, functionMCP server — agent calls it as work happensChangesets — named feature/task slugs across many entitiesSQLite, zero deps
OpenLorePurged — rejected is an inactive status, dropped from the queryable store after each decision sync (the annotation survives in the synced spec markdown)Derived — tree-sitter static analysis of code state, plus commit-gated decision notesAST node (18 languages + 12 IaC)MCP server — one-time index + commit-time certificatesCall-graph edgesSQLite graph in .openlore/
AgentDiff (sunilmallya)NoneInferred post-hoc by Claude Haiku from the diff at session endLineClaude Code lifecycle hooks → local daemonSession/taskJSONL on disk
AgentDiff (codeprakhar25)Noneed25519-signed cross-agent provenanceLinePer-agent editor hooks + git hooks (sign at commit)NoneSigned traces in git refs
OriginNone — rework flags reverted AI code post-hoc, without rationalePrompt receipts, captured live per turnLineAgent lifecycle hooks + git post-commit hookNoneGit notes + sessions branch
Git AINoneAttribution metadataLineAgent-invoked checkpoint → Git notes at commitNoneGit notes
BlamePromptNonePrompt receipts — prompt, cost,

View source on GitHub