https://github.com/ramakay/claude-self-reflect
Enable claude to self reflect.
https://github.com/ramakay/claude-self-reflect
ai-memory claude claude-desktop conversation-memory mcp qdrant semantic-search vector-search
Last synced: about 1 month ago
JSON representation
Enable claude to self reflect.
- Host: GitHub
- URL: https://github.com/ramakay/claude-self-reflect
- Owner: ramakay
- License: mit
- Created: 2025-07-25T03:13:42.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-25T06:15:30.000Z (11 months ago)
- Last Synced: 2025-07-25T07:37:24.476Z (11 months ago)
- Topics: ai-memory, claude, claude-desktop, conversation-memory, mcp, qdrant, semantic-search, vector-search
- Language: Python
- Size: 799 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-claude-code - **claude-self-reflect**
- awesome-AI-driven-development - Claude Self-Reflect - Give Claude perfect memory of all your conversations. Search past discussions instantly. Never lose context again. (Project & Knowledge Management / Other IDEs)
README
# Claude Self-Reflect

[](https://www.npmjs.com/package/claude-self-reflect) [](https://www.npmjs.com/package/claude-self-reflect) [](https://opensource.org/licenses/MIT) [](https://github.com/ramakay/claude-self-reflect/releases/latest) [](https://github.com/anthropics/claude-code) [](https://modelcontextprotocol.io/) [](https://github.com/ramakay/claude-self-reflect/tree/main/csr-engine) [](https://github.com/ramakay/claude-self-reflect) [](https://github.com/ramakay/claude-self-reflect/stargazers)
**Claude forgets everything. This fixes that.**
Single 44MB binary. No databases. No containers. No API keys required.
[Install](#install) | [How It Works](#how-it-works) | [MCP Tools](#mcp-tools) | [FAQ](https://ramakay.github.io/claude-self-reflect/#/docs/troubleshooting)
## Table of Contents
- [The Problem](#the-forgetting-problem) — Why Claude needs memory
- [The Architecture](#one-binary-44mb) — How CSR solves it
- [The Pipeline](#the-pipeline) — Progressive enrichment (9.3x improvement)
- [Install](#install) — One command setup
- [What You'll Ask](#what-youll-ask) — Natural language, no syntax
- [Performance](#performance) | [MCP Tools](#mcp-tools) | [Hooks](#hooks) | [CLI](#cli-reference)
- [AI Narratives](#ai-narratives-optional) | [Upgrading](#upgrading-from-v7x) | [Troubleshooting](#troubleshooting)
---
## The Forgetting Problem

Claude starts fresh every session. Solutions you found, architectures you designed, bugs you debugged — all gone.
Context retention drops below **20% after 10 sessions**. CSR fixes this with a single binary that gives Claude perfect memory.
No special syntax. No commands. Install once, and past context appears automatically when you need it.
> **[Explore the full documentation →](https://ramakay.github.io/claude-self-reflect/)**
---
## One Binary. 44MB.

Everything runs locally in a single process. No Docker, no database server, no API keys required.
- **SQLite** — storage for chunks, embeddings, enrichment state
- **HNSW** — sub-millisecond vector search (<1ms p95)
- **FastEmbed** — 384-dim local embeddings
- **AST** — code-aware search across 6 languages
**6 hooks** fire across the session lifecycle. **12 MCP tools** for explicit search.
> **[Explore the full documentation →](https://ramakay.github.io/claude-self-reflect/#/docs/architecture)**
---
## The Pipeline

Three layers progressively improve search quality from raw chunks to AI-enriched narratives — **9.3x improvement**.
Higher quality context. Better decisions. Fewer tokens.
> **[Explore the full documentation →](https://ramakay.github.io/claude-self-reflect/#/docs/enrichment)**
---
## Install
```bash
curl -fsSL https://raw.githubusercontent.com/ramakay/claude-self-reflect/main/scripts/install.sh | sh
```
One command. Downloads the binary, runs setup, registers MCP server, installs 6 hooks. Restart Claude Code.
| Platform | Support |
|----------|---------|
| macOS (Apple Silicon) | Prebuilt binary |
| Linux x86_64 / WSL | Prebuilt binary |
| Linux ARM64 | Prebuilt binary |
| macOS (Intel) | Build from source |
Alternative: npm
```bash
npm install -g claude-self-reflect
```
Build from source
```bash
git clone https://github.com/ramakay/claude-self-reflect.git
cd claude-self-reflect/csr-engine
cargo build --release
cp target/release/csr-engine ~/.local/bin/
csr-engine setup
```
What You'll Ask — after install, just ask Claude naturally
- *"How did we solve re-renders on this component?"*
- *"What did we tell Joe about that commit?"*
- *"What were our frustrations with this approach?"*
- *"Where did we put the auth middleware config?"*
No special syntax. No commands. CSR finds relevant past context and injects it automatically.
Performance — sub-millisecond search, 93ms startup
| Metric | Value |
|--------|-------|
| **Cached startup** | 93ms |
| **Search latency (p95)** | <1ms |
| **Binary size** | 44MB |
| **Import speed** | ~20 conversations/sec |
| **Embedding** | 0.73ms/text (batch) |
MCP Tools — 12 tools available to Claude
| Tool | Description |
|------|-------------|
| `csr_reflect_on_past` | Semantic search across past conversations |
| `store_reflection` | Store insights for future retrieval |
| `csr_quick_check` | Fast existence check (count + top match) |
| `search_by_recency` | Time-constrained search ("last week") |
| `get_recent_work` | "What did we work on?" with session grouping |
| `get_timeline` | Activity timeline with statistics |
| `csr_search_by_file` | Find conversations that touched a file |
| `csr_search_by_concept` | Theme-based search ("security", "testing") |
| `csr_search_insights` | Aggregated patterns from search results |
| `csr_get_more` | Paginate through additional results |
| `get_full_conversation` | Retrieve complete JSONL conversation |
| `get_session_learnings` | Iteration-level memory for Ralph loops |
Hooks — 6 session lifecycle hooks
| Hook | What it does |
|------|-------------|
| **SessionStart** | Surfaces relevant past context at conversation start |
| **UserPromptSubmit** | Predicts and injects context before Claude responds |
| **PostToolUse** | Tracks file edits with session-scoped dedup |
| **Stop** | Stores iteration learnings, detects stuck patterns |
| **PreCompact** | Backs up state before context compaction |
| **SessionEnd** | Stores session narrative for future retrieval |
All hooks use catch-all error handling. They never block Claude Code.
AI Narratives — optional 9.3x quality boost
Transform raw conversations into rich, searchable narratives. Requires an Anthropic API key.
```bash
csr-engine daemon
```
| Metric | Without | With AI Narratives |
|--------|---------|-------------------|
| Search quality | 0.074 | 0.691 (9.3x) |
| Token compression | 100% | 18% (82% reduction) |
| Cost per conversation | - | ~$0.012 (Batch API) |
CLI Reference
```
csr-engine Start MCP server (default)
csr-engine setup One-shot setup: import + MCP + hooks
csr-engine status System status (JSON)
csr-engine status --compact One-line statusline output
csr-engine daemon Background enrichment daemon
csr-engine hook install --apply Install Claude Code hooks
csr-engine eval Quick eval (5 tests)
csr-engine eval --full Full eval (20 tests)
csr-engine quality AST-based code quality analysis
```
Upgrading from v7.x
v8.0 replaces the Python/Docker stack with a single Rust binary.
```bash
docker compose down 2>/dev/null
curl -fsSL https://raw.githubusercontent.com/ramakay/claude-self-reflect/main/scripts/install.sh | sh
```
Your conversation data (`~/.claude/projects/`) is untouched. The new engine re-imports from the same JSONL files.
Troubleshooting
| Symptom | Fix |
|---------|-----|
| No search results | Run `csr-engine setup` |
| MCP tools not available | Run `csr-engine setup`, restart Claude Code |
| "spawn ENOENT" in MCP | Ensure `csr-engine` is in PATH |
| Slow first startup | Normal (~14s for index rebuild, subsequent: ~93ms) |
Full guide: [Documentation](https://ramakay.github.io/claude-self-reflect/#/docs/troubleshooting)
Uninstall
```bash
claude mcp remove claude-self-reflect
rm -rf ~/.claude-self-reflect/
rm ~/.local/bin/csr-engine
npm uninstall -g claude-self-reflect # if installed via npm
```
Contributors (v1–v7)
- **[@TheGordon](https://github.com/TheGordon)** - Fixed timestamp parsing (#10)
- **[@akamalov](https://github.com/akamalov)** - Ubuntu WSL insights
- **[@kylesnowschwartz](https://github.com/kylesnowschwartz)** - Security review (#6)
---
[Documentation](https://ramakay.github.io/claude-self-reflect/) | [npm](https://www.npmjs.com/package/claude-self-reflect) | [Issues](https://github.com/ramakay/claude-self-reflect/issues) | MIT License