
Selvedge
io.github.masondelan由 GitHub 帳號 masondelan 發布v0.3.18更新於 Nov 1, 2026
Persistent decision memory for AI agents: rationale, rejected approaches, and entity history.
概覽
Selvedge 是本地 MCP 伺服器,把程式碼決策的理由存進專案內的 SQLite 資料庫,讓助理依實體記錄並回溯這些理由。
- 可以做什麼
- 記錄變更事件,包含實體路徑、差異、理由、限制條件與重新檢視時機
- 查詢某個實體的歷史、最近一次變更與 blame 脈絡,或跨實體篩選歷史
- 在修改實體前查看先前的嘗試,含已嘗試、已還原、已重開的結論
- 依 changeset 標籤彙整事件,並對所有紀錄做全文搜尋
- 列出到期需重新檢視、或失效條件已被後續變更觸發的過時決策
- 適用情境
- 適合在原始對話已遺失後重回專案的獨立開發者,也適合需要在不同工作階段與編碼工具之間傳遞已記錄決策的團隊。當希望函式、欄位、路由、相依套件或環境變數背後的「為什麼」能在下次修改前被查詢時,值得加入。
- 執行需求
- 以本機 stdio 程序執行,由 selvedge-server 啟動;需要 uv 與 Python(建議 3.11 至 3.14)。可透過 uvx、uv tool install 或 pip 安裝,並在專案中初始化以建立 .selvedge/selvedge.db 儲存區。可選環境變數 SELVEDGE_DB 可覆寫資料庫路徑。不需託管帳號或 API 金鑰。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Selvedge,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
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.
來源:README.md,提交 3ef9ad6
工具
0版本歷史
5- v0.3.18最新Nov 1, 2026
- v0.3.17Oct 16, 2026
- v0.3.16Oct 2, 2026
- v0.3.15Sep 25, 2026
- v0.3.14Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分