# gitmem [Health: Active]

**Category:** 🧠 Knowledge & Memory  
**Repository:** https://github.com/gitmem-dev/gitmem  
**GitHub Stars:** 9  
**npm Downloads (last month):** 1201  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/gitmem

## Description
Persistent institutional memory for AI coding agents. Memory that compounds.

## Tools
Capabilities this server exposes over MCP:

- **recall** — Check institutional memory for relevant scars before taking action. Returns matching scars and their lessons. Integrates variant assignment when issue_id provided.
- **confirm_scars** — Confirm surfaced scars with APPLYING/N_A/REFUTED decisions and evidence. REQUIRED after recall() before consequential actions. Each recalled scar must be addressed. APPLYING: past-tense evidence of compliance. N_A: explain why scar doesn't apply. REFUTED: acknowledge risk of overriding.
- **reflect_scars** — End-of-session scar reflection — the closing counterpart to confirm_scars. Mirrors CODA-1's [Scar Reflection] protocol. Call BEFORE session_close to provide evidence of how each surfaced scar was handled. OBEYED: concrete evidence of compliance (min 15 chars). REFUTED: why it didn't apply + what was done instead (min 30 chars). Session close uses reflections to set execution_successful accurately.
- **session_start** — Initialize session, detect agent, load institutional context (last session, recent decisions, open threads). Scars surface on-demand via recall(). DISPLAY: The result includes a pre-formatted 'display' field visible in the tool result. Output the display field verbatim as your response — tool results are collapsed in the CLI.
- **session_refresh** — Re-surface institutional context (threads, decisions) for the current active session without creating a new session. Use mid-session when you need to remember where you left off, after context compaction, or after a long gap. DISPLAY: The result includes a pre-formatted 'display' field visible in the tool result. Output the display field verbatim as your response — tool results are collapsed in the CLI.
- **session_close** — Persist session with compliance validation. Two modes: (1) Write closing_reflection and other payload to {gitmem_dir}/closing-payload.json, then call with session_id + close_type. (2) Pass closing_reflection directly as a parameter (simpler). Both work — inline params override file payload. task_completion is auto-generated. DISPLAY: Output the display field verbatim.
- **create_learning** — Create scar, win, or pattern entry in institutional memory. Frame as 'what we now know' — lead with the factual/architectural discovery, not what went wrong. Good: 'Fine-grained PATs are scoped to one resource owner'. Bad: 'Should have checked PAT type first'.
- **create_decision** — Log architectural/operational decision to institutional memory
- **record_scar_usage** — Track scar application for effectiveness measurement
- **search** — Search institutional memory by query. Unlike recall (which is action-oriented), search is exploration-oriented — returns matching scars/wins/patterns without side effects.
- **log** — List recent learnings chronologically (like git log). Shows scars, wins, and patterns ordered by creation date.
- **prepare_context** — Generate portable memory payload for sub-agent injection. Formats institutional memory into compact or gate payloads that fit in Task tool prompts.
- **absorb_observations** — Capture observations from sub-agents and teammates. The lead agent parses findings from sub-agent responses, then calls this to persist and analyze them. Identifies scar candidates.
- **list_threads** — List open threads across recent sessions. Shows unresolved work items that carry over between sessions. Use resolve_thread to mark threads as done.
- **resolve_thread** — Mark an open thread as resolved. Use thread_id for exact match or text_match for fuzzy matching. Updates session state and .gitmem/threads.json.
- **create_thread** — Create an open thread to track unresolved work across sessions. Includes semantic dedup: if a similar open thread exists (cosine similarity > 0.85), returns the existing thread instead. Check the 'deduplicated' field in the response.
- **promote_suggestion** — Promote a suggested thread to an open thread. Takes a suggestion_id from session_start's suggested_threads list and creates a real thread from it.
- **dismiss_suggestion** — Dismiss a suggested thread. Incremented dismiss count — suggestions dismissed 3+ times are permanently suppressed.
- **cleanup_threads** — Triage open threads by lifecycle health. Groups threads as active/cooling/dormant with vitality scores. Use auto_archive=true to archive threads dormant 30+ days. Review and resolve stale threads to keep your thread list healthy.
- **health** — Show write health for the current session. Reports success/failure rates for all tracked fire-and-forget operations (metrics, cache, triple writes, embeddings, scar usage). Use this to diagnose silent failures.
- **gitmem-help** — gitmem-help - Show available commands with ASCII art header
- **archive_learning** — Archives a learning (scar/win/pattern) by setting is_active=false and recording archived_at timestamp. Archived learnings are excluded from recall and search results but preserved for audit trail.
- **contribute_feedback** — Submit feedback about gitmem — feature requests, bug reports, friction points, or suggestions. Always saved locally to .gitmem/feedback/. If opted in, sent anonymously to improve gitmem. 10/session limit.
- **index_docs** — Scan a directory of markdown files, chunk them, embed them, and store them in a local doc index for semantic search. Supports incremental indexing: only re-processes changed files. Use search_docs to query the indexed docs.
- **search_docs** — Search indexed repository documentation using semantic similarity (pro/dev tier) or BM25 keyword search (free tier). Returns relevant chunks with file paths for targeted reading. Index docs first with index_docs.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "gitmem": {
    "command": "npx",
    "args": ["-y","gitmem-mcp"]
  }
}
```

## Documentation & README

<p align="center">
  <img src="https://raw.githubusercontent.com/gitmem-dev/gitmem/HEAD/assets/banner.svg" alt="GitMem — Institutional memory for AI coding agents" width="700" />
</p>

<p align="center">
  <a href="https://www.npmjs.com/package/gitmem-mcp"><img src="https://img.shields.io/npm/v/gitmem-mcp?style=flat-square&color=c41920&label=npm" alt="npm version" /></a>
  <a href="https://www.npmjs.com/package/gitmem-mcp"><img src="https://img.shields.io/npm/dm/gitmem-mcp?style=flat-square&color=333333&label=downloads" alt="npm downloads" /></a>
  <a href="https://github.com/gitmem-dev/gitmem/blob/main/LICENSE"><img src="https://img.shields.io/github/license/gitmem-dev/gitmem?style=flat-square&color=c41920" alt="MIT License" /></a>
  <a href="https://github.com/gitmem-dev/gitmem/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/gitmem-dev/gitmem/ci.yml?style=flat-square&color=333333&label=build" alt="Build" /></a>
  <img src="https://img.shields.io/badge/node-%3E%3D18-c41920?style=flat-square" alt="Node.js >= 18" />
</p>

<p align="center">
  <a href="https://gitmem.ai/docs"><strong>Documentation</strong></a> &middot;
  <a href="https://www.npmjs.com/package/gitmem-mcp"><strong>npm</strong></a> &middot;
  <a href="https://gitmem.ai/docs/getting-started"><strong>Getting Started</strong></a> &middot;
  <a href="https://gitmem.ai/docs/tools"><strong>Tool Reference</strong></a>
</p>

---

GitMem is an [MCP server](https://modelcontextprotocol.io/) that gives your AI coding agent **persistent learning memory across agent sessions**. It remembers mistakes (scars), successes (wins), and decisions — so your agent learns from experience instead of starting from scratch every time.

> **What's MCP?** [Model Context Protocol](https://modelcontextprotocol.io/) is how AI coding tools connect to external capabilities. GitMem is an MCP server — install it once and your agent gains persistent memory.

Works with **Claude Code**, **Cursor**, **VS Code (Copilot)**, **Windsurf**, and any MCP-compatible client.

## Quick Start

```bash
npx gitmem-mcp init
```

One command. The wizard auto-detects your IDE and sets up everything:
- `.gitmem/` directory with starter scars
- MCP server config (`.mcp.json`, `.vscode/mcp.json`, `.cursor/mcp.json`, etc.)
- Instructions file (`CLAUDE.md`, `.cursorrules`, `.windsurfrules`, `.github/copilot-instructions.md`)
- Lifecycle hooks (where supported)
- `.gitignore` updated

Already have existing config? The wizard merges without destroying anything. Re-running is safe.

```bash
npx gitmem-mcp init --yes                # Non-interactive
npx gitmem-mcp init --dry-run            # Preview changes
npx gitmem-mcp init --client vscode      # Force specific client
```

## How It Works

```
recall  -->  work  -->  learn  -->  close  -->  recall  -->  ...
```

1. **Recall** — Before acting, the agent checks memory for relevant lessons from past sessions
2. **Work** — The agent does the task, applying past lessons automatically
3. **Learn** — Mistakes become **scars**, successes become **wins**, strategies become **patterns**
4. **Close** — Session reflection persists context for next time

Every scar includes **counter-arguments** — reasons why someone might reasonably ignore it. This prevents memory from becoming a pile of rigid rules.

## What Gets Remembered

| Type | Purpose | Example |
|------|---------|---------|
| **Scars** | Mistakes to avoid | "Always validate UUID format before DB lookup" |
| **Wins** | Approaches that worked | "Parallel agent spawning cut review time by 60%" |
| **Patterns** | Reusable strategies | "5-tier test pyramid for MCP servers" |
| **Decisions** | Architectural choices with rationale | "Chose JWT over session cookies for stateless auth" |
| **Threads** | Unfinished work that carries across sessions | "Rate limiting still needs implementation" |

## Key Features

- **Automatic Recall** — Scars surface before the agent takes similar actions
- **Session Continuity** — Context, threads, and rapport carry across sessions
- **Closing Ceremony** — Structured reflection captures what broke, what worked, and what to do differently
- **20+ MCP Tools** — Full toolkit for memory management, search, threads, and multi-agent coordination
- **Zero Config** — `npx gitmem-mcp init` and you're running
- **Non-Destructive** — Merges with your existing `.mcp.json`, `CLAUDE.md`, and hooks

## Supported Clients

| Client | Setup | Hooks |
|--------|-------|-------|
| **Claude Code** | `npx gitmem-mcp init` | Full (session, recall, credential guard) |
| **Cursor** | `npx gitmem-mcp init --client cursor` | Partial (session, recall) |
| **VS Code (Copilot)** | `npx gitmem-mcp init --client vscode` | Instructions-based |
| **Windsurf** | `npx gitmem-mcp init --client windsurf` | Instructions-based |
| **Claude Desktop** | Add to `claude_desktop_config.json` | Manual |
| **Any MCP client** | `npx gitmem-mcp init --client generic` | Instructions-based |

The wizard auto-detects your IDE. Use `--client` to override.

<details>
<summary><strong>Manual MCP configuration</strong></summary>

Add this to your MCP client's config file:

```json
{
  "mcpServers": {
    "gitmem": {
      "command": "npx",
      "args": ["-y", "gitmem-mcp@latest"]
    }
  }
}
```

| Client | Config file |
|--------|-------------|
| Claude Code | `.mcp.json` |
| Cursor | `.cursor/mcp.json` |
| VS Code | `.vscode/mcp.json` |
| Windsurf | `~/.codeium/windsurf/mcp_config.json` |

</details>

## CLI Commands

| Command | Description |
|---------|-------------|
| `npx gitmem-mcp init` | Interactive setup wizard (auto-detects IDE) |
| `npx gitmem-mcp init --client <name>` | Setup for specific client (`claude`, `cursor`, `vscode`, `windsurf`, `generic`) |
| `npx gitmem-mcp init --yes` | Non-interactive setup |
| `npx gitmem-mcp init --dry-run` | Preview changes |
| `npx gitmem-mcp activate <key>` | Activate Pro tier (auto-applies schema) |
| `npx gitmem-mcp deactivate` | Remove Pro credentials, free device slot |
| `npx gitmem-mcp setup` | Output schema SQL (for manual Supabase setup) |
| `npx gitmem-mcp uninstall` | Clean removal (preserves `.gitmem/` data) |
| `npx gitmem-mcp uninstall --all` | Full removal including data |
| `npx gitmem-mcp check` | Diagnostic health check |

## Pro Tier

Self-hosted on your own Supabase. You bring the infrastructure, gitmem sets it up.

| What you get | Why your agent cares |
|-------------|---------------------|
| **Semantic search** | Recall returns the *right* scars, not keyword noise |
| **Session analytics** | Spot patterns in what keeps going wrong |
| **Sub-agent briefing** | Hand institutional context to sub-agents automatically |
| **Cloud persistence** | Memory survives machine changes, shareable across team |
| **A/B testing analytics** | Measure which scar phrasings actually change agent behavior |

### Quick start

```bash
npx supabase login                                          # one time
export SUPABASE_URL="https://yourproject.supabase.co"
export SUPABASE_SERVICE_ROLE_KEY="eyJ..."
export OPENROUTER_API_KEY="sk-or-v1-..."
npx gitmem-mcp activate <your-license-key>
```

The activate command creates all tables, views, RPC functions, and indexes automatically. No manual SQL needed.

See **[docs/pro-setup-guide.md](https://github.com/gitmem-dev/gitmem/blob/HEAD/docs/pro-setup-guide.md)** for the full guide.

The free tier gives you everything for solo projects. Pro makes recall smarter and memory portable.

## GitMem + MEMORY.md

Your AI agent likely has its own memory file (MEMORY.md, .cursorrules, etc.). Here's how they work together:

| | MEMORY.md | GitMem |
|---|-----------|--------|
| **Loaded** | Every turn (system prompt) | On-demand (tool calls) |
| **Best for** | Preferences, shortcuts, quick reference | Earned lessons, unfinished work, decisions |
| **Updates** | Agent writes directly | Session lifecycle (close ceremony) |
| **Example** | "User prefers terse output" | "Always validate UUID before DB lookup" |

**Tip:** Include `.gitmem/agent-briefing.md` in your MEMORY.md for a lightweight bridge between the two systems.

## Privacy & Data

- **Local-first** — All data stored in `.gitmem/` on your machine by default
- **No telemetry** — GitMem does not collect usage data or phone home
- **Cloud opt-in** — Pro tier Supabase backend requires explicit configuration via environment variables
- **Your data** — Sessions, scars, and decisions belong to you. Delete `.gitmem/` to remove everything

## Development

```bash
git clone https://github.com/gitmem-dev/gitmem.git
cd gitmem
npm install
npm run build
npm test
```

See [CONTRIBUTING.md](https://github.com/gitmem-dev/gitmem/blob/HEAD/CONTRIBUTING.md) for full development setup.

## License

MIT — see [LICENSE](https://github.com/gitmem-dev/gitmem/blob/HEAD/LICENSE).

