Skip to main content
Every Cursor session starts fresh — your AI does not remember what it worked on yesterday. Claude-mem changes that. Your agent builds cumulative knowledge about your codebase, decisions, and patterns over time.

Free to Start

Works with Gemini’s free tier (1,500 req/day) — no subscription required

Automatic Capture

MCP tools, shell commands, and file edits logged without effort

Smart Context

Relevant history injected into every chat session via Cursor Rules

Works Everywhere

With or without a Claude Code subscription
No Claude Code subscription required. Use Gemini (free tier) or OpenRouter as your AI provider.

How It Works

Claude-mem integrates with Cursor through native hooks:
Cursor Agent
  │ Events (MCP, Shell, File Edits, Prompts)

Cursor Hooks System
  ├── beforeSubmitPrompt
  ├── afterMCPExecution
  ├── afterShellExecution
  ├── afterFileEdit
  └── stop
  │ HTTP Requests

Hook Scripts (Bash / PowerShell)
  ├── session-init.sh
  ├── context-inject.sh
  ├── save-observation.sh
  ├── save-file-edit.sh
  └── session-summary.sh
  │ HTTP API Calls

Claude-Mem Worker Service (Port 37777)
  ├── /api/sessions/init
  ├── /api/sessions/observations
  ├── /api/sessions/summarize
  └── /api/context/inject
  │ Database Operations

SQLite + Chroma Vector DB
  1. Session hooks capture tool usage, file edits, and shell commands
  2. AI extraction compresses observations into semantic summaries
  3. Context injection loads relevant history into each new session via .cursor/rules/claude-mem-context.mdc
  4. Memory viewer at http://localhost:37777 shows your knowledge base

Prerequisites

  • Bun: curl -fsSL https://bun.sh/install | bash
  • Cursor IDE
  • jq and curl: brew install jq curl
  • Bun: curl -fsSL https://bun.sh/install | bash
  • Cursor IDE
  • jq and curl: apt install jq curl or dnf install jq curl
  • Bun: powershell -c "irm bun.sh/install.ps1 | iex"
  • Cursor IDE
  • PowerShell 5.1+ (included in Windows 10/11)
  • Git for Windows

Installation Paths

Choose the installation method that fits your setup:
If you are using Cursor without a Claude Code subscription, follow this path.
1

Clone and build

git clone https://github.com/thedotmack/claude-mem.git
cd claude-mem && bun install && bun run build
2

Configure your AI provider

Since you do not have Claude Code, you need to configure an AI provider for claude-mem’s summarization engine.Option A: Gemini (Recommended — Free Tier)Gemini offers 1,500 free requests per day, which is plenty for typical individual use.
mkdir -p ~/.claude-mem
cat > ~/.claude-mem/settings.json << 'EOF'
{
  "CLAUDE_MEM_PROVIDER": "gemini",
  "CLAUDE_MEM_GEMINI_API_KEY": "YOUR_GEMINI_API_KEY",
  "CLAUDE_MEM_GEMINI_MODEL": "gemini-2.5-flash-lite",
  "CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED": true
}
EOF
Get your free API key at aistudio.google.com/apikey.Option B: OpenRouter (100+ Models)
mkdir -p ~/.claude-mem
cat > ~/.claude-mem/settings.json << 'EOF'
{
  "CLAUDE_MEM_PROVIDER": "openrouter",
  "CLAUDE_MEM_OPENROUTER_API_KEY": "YOUR_OPENROUTER_API_KEY"
}
EOF
Free models available on OpenRouter include google/gemini-2.0-flash-exp:free and xiaomi/mimo-v2-flash:free.Option C: Claude API (API Credits Without Claude Code)
mkdir -p ~/.claude-mem
cat > ~/.claude-mem/settings.json << 'EOF'
{
  "CLAUDE_MEM_PROVIDER": "claude",
  "ANTHROPIC_API_KEY": "YOUR_ANTHROPIC_API_KEY"
}
EOF
3

Run the interactive setup wizard

bun run cursor:setup
The wizard detects that you do not have Claude Code, helps you choose and configure a free AI provider, installs hooks automatically, and starts the worker service.
4

Verify installation

bun run cursor:status
bun run worker:status
Then open http://localhost:37777 in your browser.
5

Restart Cursor

Restart Cursor IDE to load the new hooks. Start a coding session — context will begin being captured automatically.

npm Scripts Reference

All commands are run from the claude-mem repository directory:
CommandDescription
bun run cursor:setupInteractive setup wizard — configures provider and installs hooks
bun run cursor:installInstall Cursor hooks for the current project
bun run cursor:install -- userInstall Cursor hooks for all projects (user-level)
bun run cursor:uninstallRemove Cursor hooks
bun run cursor:statusCheck hook installation status
bun run worker:startStart the worker service in the background
bun run worker:stopStop the worker service
bun run worker:restartRestart the worker service
bun run worker:statusCheck worker status
bun run worker:logsView worker logs (last 50 lines)

Hook Mappings

The hooks.json file installed in .cursor/ maps Cursor events to bash (or PowerShell) scripts:
Cursor HookScriptPurpose
beforeSubmitPromptsession-init.shInitialize claude-mem session using conversation_id
beforeSubmitPromptcontext-inject.shEnsure worker is running; refresh context file
afterMCPExecutionsave-observation.shCapture MCP tool usage
afterShellExecutionsave-observation.shCapture shell command execution
afterFileEditsave-file-edit.shCapture file edits as write_file observations
stopsession-summary.shGenerate summary + update context file for next session
{
  "version": 1,
  "hooks": {
    "beforeSubmitPrompt": [
      { "command": "./cursor-hooks/session-init.sh" },
      { "command": "./cursor-hooks/context-inject.sh" }
    ],
    "afterMCPExecution": [
      { "command": "./cursor-hooks/save-observation.sh" }
    ],
    "afterShellExecution": [
      { "command": "./cursor-hooks/save-observation.sh" }
    ],
    "afterFileEdit": [
      { "command": "./cursor-hooks/save-file-edit.sh" }
    ],
    "stop": [
      { "command": "./cursor-hooks/session-summary.sh" }
    ]
  }
}

Context Injection

Context is automatically injected via Cursor’s Rules system — no manual steps required after installation.

How the Context File Works

The file at .cursor/rules/claude-mem-context.mdc has alwaysApply: true set in its frontmatter, so Cursor includes it in every chat session automatically.
---
alwaysApply: true
description: "Claude-mem context from past sessions (auto-updated)"
---

# Memory Context from Past Sessions

[Your context from claude-mem appears here]

---
*Updated after last session.*

When Context Updates

Context is refreshed at three points per session for maximum freshness:
1

Before each prompt (context-inject.sh)

When you submit a prompt, context-inject.sh runs. It fetches the latest context from /api/context/inject and rewrites .cursor/rules/claude-mem-context.mdc. Cursor reads this file before passing it to the LLM.
2

After summary completes (worker auto-update)

Immediately after a summary is saved to the database, the worker checks if the project is registered for Cursor and writes the updated context file automatically — no hook involved.
3

After session ends (session-summary.sh)

When the agent loop ends, the stop hook runs session-summary.sh, which generates a session summary and then writes a fresh context file as a fallback to ensure nothing was missed.

Data Mapping

Cursor FieldClaude-Mem FieldNotes
conversation_idcontentSessionIdStable across turns, used as primary session identifier
generation_id(fallback)Used if conversation_id is unavailable
workspace_roots[0]Project nameBasename of workspace root directory

Additional Context Access Methods

MCP Tools

Configure claude-mem’s MCP server in Cursor for search(query, project, limit), timeline(anchor, depth_before, depth_after), and get_observations(ids) tools.

Web Viewer

Browse your full memory at http://localhost:37777 — search, filter by project, view timelines.

Provider Comparison

ProviderCostRate LimitBest For
GeminiFree tier1,500 req/dayIndividual use, getting started
OpenRouterPay-per-use + free modelsVaries by modelModel variety, high volume
Claude SDKIncluded with Claude CodeUnlimitedClaude Code subscribers
Start with Gemini’s free tier. It handles typical individual usage well. Switch to OpenRouter or Claude SDK if you need higher limits.

Comparison with Claude Code Integration

FeatureClaude CodeCursor
Session initializationSessionStart hookbeforeSubmitPrompt hook
Context injectionadditionalContext field (immediate)Auto-updated .cursor/rules/ file
Observation capturePostToolUse hookafterMCPExecution, afterShellExecution, afterFileEdit
Session summaryStop hook with transcriptstop hook (no transcript access)
MCP search toolsFull supportFull support (if MCP configured)
Context persistenceSession onlyFile-based (persists across IDE restarts)

Troubleshooting

Worker not starting

# Check if port is already in use
lsof -i :37777

# Force restart
bun run worker:stop && bun run worker:start

# Check logs
bun run worker:logs
# Or view the log file directly
tail -f ~/.claude-mem/logs/worker-$(date +%Y-%m-%d).log

Hooks not firing

  1. Restart Cursor IDE after installation
  2. Check hooks are installed: bun run cursor:status
  3. Verify hooks.json exists in .cursor/ (project-level) or ~/.cursor/ (user-level)
  4. Check Cursor Settings → Hooks tab for configuration errors
  5. Verify scripts are executable:
    chmod +x ~/.cursor/hooks/*.sh
    

No context appearing

  1. Ensure worker is running: bun run worker:status
  2. Confirm worker responds: curl http://127.0.0.1:37777/api/readiness
  3. Check for existing observations: visit http://localhost:37777
  4. Verify your API key is configured correctly in ~/.claude-mem/settings.json

Observations not being saved

Test the observation endpoint directly:
curl -X POST http://127.0.0.1:37777/api/sessions/observations \
  -H "Content-Type: application/json" \
  -d '{"contentSessionId":"test","tool_name":"test","tool_input":{},"tool_response":{},"cwd":"/tmp"}'

Rate limiting on Gemini free tier

If you hit the 1,500 requests/day limit:
  • Wait until the next day (limit resets at midnight Pacific)
  • Switch to OpenRouter with a paid or free model
  • Upgrade to a paid Gemini plan

Windows: “Execution of scripts is disabled”

Run PowerShell as Administrator:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

Windows: Worker not responding

Check if port 37777 is in use:
Get-NetTCPConnection -LocalPort 37777

Next Steps

Gemini Setup Guide

Step-by-step guide to configure Gemini’s free tier

OpenRouter Setup Guide

Configure OpenRouter for 100+ model options

Configuration Reference

All available settings and options

Troubleshooting

Common issues and solutions

Build docs developers (and LLMs) love