
Selvedge
io.github.masondelanPublished by GitHub account masondelanv0.3.18Updated Nov 1, 2026
Persistent decision memory for AI agents: rationale, rejected approaches, and entity history.
Overview
Selvedge is a local MCP server that stores the reasons behind code decisions in a project SQLite file and lets an assistant log and recall them by entity.
- What you can do
- Log a change event with entity path, diff, reasoning, constraint and revisit condition
- Look up an entity's history, latest change and blame context, or filter history across entities
- Check prior attempts on an entity before editing, with tried, reverted and reopened outcomes
- Group events by changeset slug and run full-text search across all records
- Surface stale decisions whose revisit date passed or whose invalidation condition matched a later change
- When to use it
- Useful for solo developers or teams returning to a codebase after the original conversation is gone, and for passing recorded rationale between sessions or coding tools. It fits when you want the why behind a function, column, route, dependency or environment variable to be queryable before the next edit.
- Requirements
- Runs as a local stdio process launched as selvedge-server; needs uv and Python (3.11 to 3.14 recommended). Install via uvx, uv tool install or pip, then initialize the project so a .selvedge/selvedge.db store exists. The optional SELVEDGE_DB variable overrides the database path. No hosted account or API key is required.
Installation
In SourceWeft
- Open Selvedge in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
selvedge.sh · DevHunt · PyPI · GitHub
Persistent decision memory for AI agents.
Save why you chose an approach, what you rejected, and what would change your mind. Retrieve that context in the next coding session, using a function, database column, API route or dependency as the lookup key.
Selvedge is for anyone using a compatible agent. Connect through local MCP
over stdio, or use the CLI from an agent with shell access. Decisions stay in
the same SQLite store in .selvedge/ when you switch tools.
No hosted account is required; core storage and retrieval make no LLM calls.
Get started · Documentation · Agent compatibility
Requires uv and Python. Python 3.11–3.14 is recommended; Python 3.10 remains compatible but is end of life. The demo uses a temporary database. Follow the quickstart to connect your agent to a real project.
Use selvedge demo --mcp to save through a local stdio MCP server, restart it
and retrieve the same record. Add --json for the checked IDs and versions.
This tests the Python installation running Selvedge with disposable data;
your agent's configuration, activation and hooks still need a separate check.
Who Selvedge is for
- Solo developers returning to a project after the original conversation is gone.
- Teams that need to pass recorded decisions between sessions and coding tools.
The problem
Code shows the chosen approach. It may leave out the constraint that shaped it or the alternative you ruled out. Selvedge gives those explanations a place in the project and tools to retrieve them before the next edit.
Only explicitly saved decisions can be recalled. A saved explanation is an account supplied by a person or agent; Selvedge does not verify that it is true or guarantee that an agent will consult it. Verify one decision across two sessions to test your setup.
What's new in v0.3.18
Read the recorded reasons before routine review metadata. The optional GitHub review Action puts rejected and reverted approaches, revisions and constraints first. Its comment defaults to a 6,000-character budget, counts omitted events and links to the trusted base store and longer job summary. Unchanged reruns leave the comment untouched.
Healthy runs with no matching history keep the job summary without creating a new comment; an existing comment is refreshed and broken chains remain visible. Missing history is unknown, not approval. The Action still uses only publication-approved base history and never executes PR-head code.
A regression check also protects the library's local save/reopen/retrieve path with site packages unavailable and socket access blocked. No new runtime dependencies, migrations, MCP tools or model calls. Python 3.10 compatibility is retained; use supported Python 3.11–3.14 for new installations. Native Action execution and review usefulness remain unverified.
What's new in v0.3.17
Check recorded decisions before a review. Generate a Markdown digest, then
run selvedge export --format markdown -o DECISIONS.md --check to catch drift.
An identical digest exits 0 silently; a stale or missing digest exits 1 with a
unified diff and regeneration guidance. Check mode preserves the digest and
stored records. Review exported reasoning before publishing it.
selvedge demo --mcp saves a synthetic rejection through a real local MCP
server, restarts it and retrieves the same record. It uses disposable state;
it does not verify your agent's configuration or hook activation.
CLI output now preserves literal brackets in user data, and blame and Markdown
exports distinguish rejected approaches from changes that were tried and reverted.
Python 3.10 compatibility remains for this patch, but that runtime is now
upstream end of life; use tested,
supported Python 3.11–3.14 for new installations. No new runtime dependencies,
migrations or MCP tools.
Where Selvedge fits
- Save a decision. You or your coding agent record a choice, its reason, and any rejected approaches through MCP or the CLI.
- Keep it with the project. Selvedge stores the record in local SQLite, keyed to the function, column, route or other entity it concerns.
- Recall it before the next edit. A later session queries the same store and checks whether the earlier constraint still applies.
Git keeps the code history; review tools check changes; observability shows runtime behavior. Selvedge adds the recorded reasons behind decisions. How it works · Agent Trace interchange
How Selvedge compares
Choose the simplest memory mechanism that fits your workflow:
These approaches can be used together. Read the source-linked comparison and instructions versus ADRs versus decision memory for specific selection criteria and limitations.
Why entity history matters. users.email, env/STRIPE_SECRET_KEY,
api/v1/checkout and deps/stripe remain useful query targets when their code
moves. Explicit rejection and superseding records let a later session inspect
what was tried and whether the original constraint still applies.
Why capture time matters. Recording a reason while the context is available can preserve information a diff does not contain. It does not make the reason infallible. Retrieval uses stored records; the coding agent remains responsible for checking applicability and testing its change.
Why changesets matter. Tag events with a shared changeset such as
add-stripe-billing to retrieve a task's decisions across tables, environment
variables, routes and functions.
Agent Trace interchange. selvedge export --format agent-trace and
selvedge import --format agent-trace exchange Agent Trace v0.1.0 records.
Reasoning and entity history travel in the dev.selvedge metadata.
The mapping and limits document the format;
Selvedge vendors the schema and has no runtime dependency on the upstream project.
Quickstart
Connect your agent
With uv installed:
Setup detects supported clients. To select a preset explicitly, use
--agent with claude-code, codex, copilot, cursor, gemini or windsurf;
repeat the flag for multiple clients. These presets are conveniences, not a
compatibility limit. For another agent with local stdio MCP support, follow
manual setup. Agents with shell access can use the CLI.
Prefer pip? Use python -m pip install --upgrade selvedge in a virtual environment.
The selvedge-server executable must be on your editor's PATH; launch the editor
from that environment or use the executable's absolute path in its MCP config.
Setup asks before changing files, backs up existing content, installs MCP and agent instructions, initializes the project, and offers a Git post-commit hook. Configuration files and lifecycle hooks vary by client. See the compatibility guide for preset paths, activation requirements and limitations.
Restart your agent in the project and approve Selvedge's tools if prompted. Follow your client's project-trust requirements. Ask the agent:
Use Selvedge to record one real approach we considered and rejected in this project. Include the entity, why, and what would change our mind. Do not invent a decision. Show the saved entity path and record ID.
Start a new session and look up the same entity to verify that the decision carries forward. Follow the first-decision verification guide and cross-agent handoff guide for observable checks. MCP access does not automatically capture every decision: the installed instructions guide the agent to use it. Native lifecycle adapters cover supported client events; startup delivery, watched-edit checks and compaction notifications vary by harness. See the agent hook guide before enabling them.
For CI bootstrap or devcontainer.json postCreateCommand:
Verify the wiring — open a second terminal in the same project:
Make any change in your AI tool — add a column, rename a function, add an
env var. selvedge watch should print the new event within a second of
the agent calling log_change. If nothing arrives, run selvedge doctor
for a single-command health check that tells you which step is silently
broken.
Query your history:
Manual install — if you'd rather wire it up yourself
If you don't want to run the wizard, the four manual steps it automates:
1. Initialize in your project
2. Register the MCP server
Configure your client to launch selvedge-server as a local stdio MCP server.
Use its absolute path if it is not on the client's PATH, and set SELVEDGE_DB
to the project database if the client starts outside your project. Configuration
syntax varies; see connection examples.
3. Tell your agent to use it
Replace path/to/agent-instructions.md with the actual file your client reads — the block
itself is identical across clients:
This installs the canonical agent-instructions block, sentinel-bracketed
(<!-- selvedge:start --> / <!-- selvedge:end -->) so future
--install calls update the bracketed region without disturbing
anything else in the file. To print the block for copying:
Prefer to copy-paste? The same block is one click away on the website: selvedge.sh/prompt-block — with a copy button and notes on what your agent does with it.
4. Install the post-commit hook
That's the same four steps the wizard runs.
Works with compatible agents
Selvedge has no required agent brand or model provider. Its MCP interface uses
local stdio: a compatible client must be able to launch selvedge-server and
call its tools. Remote-HTTP-only clients need a separate stdio bridge; Selvedge
does not provide a hosted endpoint. An agent with shell access can instead use
selvedge log and the read commands.
The integrations below are examples. Choose the one matching your client, or configure another stdio MCP client using its own settings format:
Claude Code
Optional Claude Code plugin
Two commands, inside Claude Code. No prior pip install — the plugin
bootstraps the server itself via uvx (or pipx):
That's the whole agent-facing surface in one step:
- the MCP server — 8 tools (
log_change,prior_attempts,blame,diff,history,changeset,search,stale_decisions); - a skill that tells the agent when to call them — before editing a tracked entity, after any substantive change;
- the PreToolUse enforcement hook — schema/migration edits are blocked
until
prior_attemptshas been checked this session, with the prior reasoning in the block message; - slash commands —
/selvedge:status,/selvedge:blame <entity>,/selvedge:history,/selvedge:prior-attempts <entity>.
The store (.selvedge/selvedge.db) creates itself on the first logged change.
Two optional extras stay CLI-side: the post-commit hook that stamps each event
with its commit hash (selvedge install-hook), and — if you want the
selvedge command on your own shell PATH — pip install selvedge, which the
launcher then prefers over uvx for an exact pinned version.
Plugin or
selvedge setupfor Claude Code? Pick one. Both wire the MCP server; running both registers it twice. The plugin is the lighter path and the one that updates itself. If you're on the plugin and only want the post-commit commit-hash stamping, runselvedge install-hookon its own.
Manual MCP connection
Or commit a project-level .mcp.json so your whole team gets it:
Cursor
.cursor/mcp.json (project) or ~/.cursor/mcp.json (global):
Cursor's newer schema also accepts an explicit "type": "stdio"; the
command-only form works too (Cursor infers stdio from command).
Docs: https://cursor.com/docs/mcp
Windsurf
~/.codeium/windsurf/mcp_config.json:
Windsurf hot-reloads the file — no restart needed. The in-app Plugins → View raw config button opens the exact file Cascade reads. Docs: https://docs.devin.ai/desktop/cascade/mcp
Codex CLI
~/.codex/config.toml:
Or run codex mcp add selvedge -- selvedge-server.
Docs: https://learn.chatgpt.com/docs/config-file/config-reference
Gemini CLI
~/.gemini/settings.json (or .gemini/settings.json per project):
Or run gemini mcp add -s user selvedge selvedge-server.
Docs: https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md
Any other MCP client
Most clients share the same JSON shape — point yours at:
If selvedge-server isn't found, use its absolute path (which selvedge-server).
How it works
Selvedge runs as a local MCP server or CLI. Compatible agents call its tools as they work, logging structured change events to a local SQLite database.
Each event records:
- What changed (entity path, change type, diff)
- When (timestamp)
- Who (agent, session ID)
- Why (reasoning — captured from the agent's context in the moment)
- Where (git commit, project)
The diff is git's job. The why is Selvedge's.
Selvedge tracks its own history
This repo dogfoods Selvedge: its .selvedge/selvedge.db is committed, so a
fresh clone ships with Selvedge's own why-history. Clone it and ask why any
part of Selvedge changed:
Every event was logged by the agents that built Selvedge — the same
log_change calls this README asks you to make in your own project.
Entity path conventions
Prefix queries work everywhere: users returns users, users.email,
users.created_at, and any other entity under the users. namespace.
MCP tools
When connected as an MCP server, Selvedge exposes:
CLI reference
All read commands support --json for machine-readable output.
Relative time in --since:
15m→ last 15 minutes (m= minutes)24h→ last 24 hours7d→ last 7 days5mo→ last 5 months (moormon= months)1y→ last year
Unparseable inputs (e.g. --since yesterday) exit with a clear error
rather than silently returning empty results. ISO 8601 timestamps
are also accepted and normalized to UTC.
Configuration
.selvedge/config.toml
Every key is optional; a missing file means the defaults below. Precedence is
CLI flag → env var → project .selvedge/config.toml → global
~/.selvedge/config.toml → default. SELVEDGE_DB is the one exception: it
always wins for database resolution, because the config file is found by
resolving that path. selvedge doctor prints the effective value and the step
that produced it for every setting.
Every key also has an env override (SELVEDGE_DIFF_BYTES,
SELVEDGE_RETENTION_DAYS_EVENTS, …).
Reviewing captured intent in a pull request
.selvedge/selvedge.db is a SQLite file, so the reasoning inside it doesn't
show up in a diff. If you want a reviewable copy, export a Markdown digest:
The digest is grouped by entity with reverted and rejected decisions first.
Explicit reject events appear under Considered and rejected, separate from
Tried and reverted. The latest event determines the section; a later
supersede moves either kind to Re-opened while retaining the full history.
Human-readable blame also labels explicit rejections as "rejected". For API
compatibility, JSON status and trail phase keep the existing reverted
negative-verdict category; change_type: "reject" identifies a rejection.
The digest is deterministic — regenerating with no new events produces a zero-line diff, so it stays reviewable instead of becoming noise everyone learns to skip. Heading anchors derive from the entity path, so links into it keep working as it grows. Regenerate it in the same commit as the code, or from a pre-commit hook.
To catch a stale or missing digest in a hook or CI, use the same filters and
output path with --check:
The check exits 0 silently when the UTF-8, LF-terminated bytes match,
1 with a unified diff when stale or missing (or an error when unreadable),
and 2 for invalid arguments. It requires Markdown and an explicit file;
stdout and other formats are rejected. It does not rewrite the digest, create
or migrate a database, change stored records, or start background update and
telemetry checks. Use an existing initialized store in CI, selected through the
normal database resolution or SELVEDGE_DB. SQLite may maintain its normal WAL
locking files while reading. Regenerate without --check to update the digest.
Publishing either the digest or database is optional. Review captured reasoning and metadata for secrets and private information before committing or sharing them; a generated diff can also expose that information in CI logs.
Coverage checking
Wondering how often your agent actually calls log_change? Two ways to check:
The coverage script compares your git log against Selvedge events and shows
which commits have associated change events. Low coverage usually means the
system prompt needs strengthening — see docs/fallbacks.md for guidance.
In CI (GitHub Action)
The same check ships as the Selvedge Coverage Check composite Action, so you can track agent coverage on every push — and optionally fail the build when it drops:
It writes a coverage summary to the job summary and exposes coverage-ratio,
covered, and total as step outputs. The action cross-references your git
history against the Selvedge event log, so the runner needs the project's
.selvedge/selvedge.db (commit it, or restore it before this step) and full
git history (fetch-depth: 0). Inputs: since, window, limit,
fail-under, selvedge-version, python-version, working-directory,
db-path.
Contributing
Read the feedback and review process for reporting problems, evaluating feature requests and following up on discussions.
See CLAUDE.md for architecture details and the phase roadmap.
License
MIT — see LICENSE.
Decision context for reviewers
The shared ledger and PR review Action shows recorded reasons, rejected paths, actor/session attribution and integrity for touched entities. The matched injection pilot reports every trial and limits its conclusion to the tested synthetic tasks.
Source: README.md at commit 3ef9ad6
Tools
0Version history
5- v0.3.18LatestNov 1, 2026
- v0.3.17Oct 16, 2026
- v0.3.16Oct 2, 2026
- v0.3.15Sep 25, 2026
- v0.3.14Sep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts