memini
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
**Never the same mistake twice.** Mistake-prevention guardrails and persistent project memory for AI coding agents.
AI coding agents are stateless: every session starts with amnesia. The agent that broke your build editing vercel.json on Monday will happily try the exact same edit on Thursday. memini gives each repo a persistent memory of **failed attempts, fragile files, decisions, and deployment rules** — and *force-feeds* the relevant warning to the agent at the moment it's about to repeat history.
Not a notebook the agent may choose to read. A guardrail it can't skip.
How it works
1. **Memories live in your repo** — a .memini/ folder with a local SQLite index and human-readable, PR-reviewable markdown views. Local-first: nothing leaves your machine.
2. **Hooks enforce guardrails** — when the agent tries to edit a file with recorded risks, the edit is intercepted *before it happens* and the recorded lesson is injected:
> [WARNING] Editing vercel.json broke the build (recorded 2026-07-03) — Tried changing buildCommand; deploy failed. Actual fix: move checkout server-side and set VITE_STRIPE_USE_SERVER=true.
- warn severity: the agent is warned once per session, then may proceed.
- block severity: the edit is always denied until a human archives the memory.
3. **Session start injects a digest** of the most important memories (severity-first, token-budgeted).
4. **MCP tools** let the agent record what it learns: remember_failed_attempt, remember_fragile_file, remember_decision, end_session_summary, plus recall_project_context and check_before_editing.
5. **Git-aware staleness** — memories hash the files they reference; pm stale flags memories whose evidence has changed, and stale memories stop firing guardrails until re-verified.
Quickstart (90 seconds)
That's it. Next time any Claude Code session in this repo tries to edit vercel.json, it gets the warning first.
**Cursor, Windsurf, and other MCP clients:**
**Enforcement is a chain of gates, and memini covers several:**
- **Before the edit** — the edit to a guardrailed file is blocked before it happens.
block → denied, warn → the user is prompted with the recorded history. Supported on:
- **Claude Code** — pm init installs it
- **Cursor** (1.7+) — pm install-mcp --write cursor
- **GitHub Copilot** — CLI, cloud coding agent, and VS Code agent mode (preview) — pm install-copilot
- **Before the commit — every tool** — a git pre-commit guardrail blocks a commit that touches
a block-severity file, no matter which IDE or agent made the edit (Windsurf, Cline, a human…).
Installed by pm init (or pm install-hooks --git). Fails open; overridable with
git commit --no-verify.
- **Advisory — any MCP client** — the check_before_editing / recall_project_context tools,
plus an always-applied Cursor rule steering the agent to use them.
Keeping memory useful over time
A memory tool is only as good as what's in it, and it rots if left alone. memini keeps it healthy:
- **Auto-capture** — a Claude Code session-end hook nudges the agent to record durable lessons
(a fix that worked, a fragile file, a failed approach) when a session actually changed files,
so you don't have to remember to pm remember. It stays silent on idle sessions.
- **Usefulness tracking** — every time a guardrail actually fires, memini counts it. pm stats