Sandbox
@DomDemetz/claude-soul

Claude Code memory and hooks for local sessions

Claude Soul adds a local memory layer to Claude Code with semantic recall, correction tracking, and reflection cycles. It uses an MCP server and Claude Code hooks to load identity and frameworks at session start, record signals during work, and index or reflect when the session ends.

88 stars9 forksTypeScriptUpdated 3mo ago
Who it's for

Builders who use Claude Code and want cross-session memory, correction tracking, and automatic reflection.

What it delivers

You can stop re-explaining context and let your agent learn from the way you correct it over time.

What it does

Cross-session memory

Saves facts, decisions, and lessons in local SQLite, with optional Ollama embeddings for semantic search.

Correction tracking

Detects repeated corrections like “that’s wrong” or “stop doing that,” classifies them, and tracks whether the pattern improves.

Reflection cycles

Runs quick, deep, or meta reflection to promote useful frameworks and retire ones that keep failing.

Claude Code hooks and MCP tools

Loads identity, frameworks, and memory through official Claude Code extension points, with tools like `soul_context`, `memory_save`, `memory_search`, and `soul_reflect`.

Local soul files

Keeps editable files such as `SOUL.md`, `SHADOW.md`, `STORY.md`, and `CORRECTIONS.md` under `~/.soul/files/`.

CLI inspection commands

Provides `claude-soul status`, `claude-soul shadow`, `claude-soul index`, and `claude-soul upgrade` for inspecting and maintaining the system.

How to get it

  1. 1Run
    npx claude-soul init --starter
  2. 2Semantic search finds memories by meaning — "auth decision" finds a memory stored as…
    # 1. Install Ollama (https://ollama.com)
    # 2. Pull the embedding model
    ollama pull nomic-embed-text
    # 3. Then install as usual
    npx claude-soul init --starter
  3. 3Run
    npx claude-soul init --starter --skip-identity
  4. 4Run
    npm install -g claude-soul@latest
    claude-soul upgrade

README

Claude Soul

npm version npm downloads License: MIT

Claude Code forgets everything between sessions. Claude Soul doesn't.

npx claude-soul init --starter

One command. No API key, no cloud, everything local.

Prerequisites: Node.js >= 18, Claude Code (Pro or Max plan).

Three things it does

1. Remembers across sessions

Cross-session memory with semantic search. Facts, decisions, lessons — all searchable by meaning, not just keywords. Uses local SQLite + optional Ollama embeddings.

You: "what did we decide about the auth flow last week?"
Claude: [searches memory → finds the decision, context, and reasoning]

2. Tracks your corrections

Every time you correct your Claude — "that's wrong", "you missed this", "stop doing that" — the system detects the pattern, classifies it, and tracks whether it's getting better or worse.

$ claude-soul shadow --brief

  premature_done: 26 corrections across 10 sessions ↑ [active]
  robot_mode: 7 corrections across 6 sessions ↓↓ [internalized]
  authenticity: 5 corrections across 5 sessions ↓↓ [internalized]

Patterns move through lifecycle stages: new → active → improving → internalized. After 200 sessions of real data: robot_mode went from 0.8 corrections/session to zero.

3. Develops judgment over time

The system extracts behavioral signals from every session and periodically reflects on them. Frameworks that keep working get promoted. Bad ones get retired. After a few weeks, you get a Claude that pushes back on bad ideas, catches its own confabulation, and develops techniques you never prompted.

Install

Quick start (no extra dependencies)

npx claude-soul init --starter

Add this to your CLAUDE.md:

## Soul System
Call `soul_context()` at the start of every conversation.
Use `soul_reflect` when you have idle time.

Done. Memory works with keyword search, everything else runs automatically.

With semantic memory

Semantic search finds memories by meaning — "auth decision" finds a memory stored as "chose JWT tokens for login." Without it, search is keyword-based (still works, just less flexible).

# 1. Install Ollama (https://ollama.com)
# 2. Pull the embedding model
ollama pull nomic-embed-text
# 3. Then install as usual
npx claude-soul init --starter

The system auto-detects Ollama. No configuration needed.

For agents (non-interactive)

npx claude-soul init --starter --skip-identity

Skips the name/context questions. Add the CLAUDE.md snippet to your agent's working directory and it works the same way — memory, correction tracking, and framework evolution all run through Claude Code's hooks and MCP server regardless of whether a human is typing or an agent is running.

Already installed? Upgrade

npm install -g claude-soul@latest
claude-soul upgrade

Your soul files, frameworks, and data stay untouched. The upgrade re-registers hooks and MCP server with the latest version and adds any new features.

After upgrading, run claude-soul index once to backfill existing data into the memory system.

What's new in v0.2
  • Memory system — 6 new MCP tools (memory_save, memory_search, recall, etc.) for cross-session fact storage with semantic search
  • Correction tracking — auto-detects when you correct your Claude and classifies the pattern
  • Shadow analysisclaude-soul shadow shows behavioral patterns with trend arrows and lifecycle stages
  • Indexingclaude-soul index loads your existing journals and soul files into the memory database
CLI commands

These are optional — the system runs automatically. The CLI is for inspecting collected data from your terminal.

CommandWhat it does
claude-soul statusSystem health — frameworks, signals, phase
claude-soul shadowYour correction patterns with trends
claude-soul shadow --generateAuto-generate a SHADOW.md from your data
claude-soul indexIndex existing files into memory database
claude-soul upgradeUpdate hooks without touching your data

How it works

Session N
  │
  ├─ Load identity + frameworks + memory
  │
  ├─ Normal Claude Code usage
  │
  ├─ Session ends → extract signals + corrections + index to memory
  │
  └─ Reflection threshold? → evolve frameworks → Session N+1

Everything runs through Claude Code's official extension points: an MCP server (15 tools) and hooks (signal extraction, journaling, memory indexing, correction tracking).

MCP Tools (15 total)

Identity & Learning

ToolPurpose
soul_contextLoad identity + frameworks + state at session start
soul_activateSelect relevant frameworks for current conversation
soul_frameworkLoad a single framework with full evidence history
soul_signalRecord observed interaction patterns
soul_reflectTrigger a reflection cycle (quick/deep/meta)
soul_self_evaluateRecord a self-evaluation of a complex response
soul_readRead soul files (SOUL.md, SHADOW.md, etc.)
soul_writeWrite to user-editable soul files
soul_statusGet current system status

Memory

ToolPurpose
memory_saveSave facts, decisions, or lessons
memory_searchSemantic search across all memories
memory_journalSearch or browse conversation journals
memory_recentList recently saved memories
memory_statsMemory system statistics
recallUnified "ask anything about the past" search
Soul files (in ~/.soul/files/)
FilePurposeManaged by
SOUL.mdYour identity — who you are, how you workYou + Claude
SHADOW.mdBlind spots and behavioral tendenciesYou + Claude
STORY.mdTimeline of growth and key momentsYou + Claude
CORRECTIONS.mdPatterns to avoid, learned from mistakesYou + Claude
STATE.mdSystem telemetry (confidence, phase, counts)Auto
FRAMEWORKS.mdActive framework indexAuto
Configuration

All settings in ~/.soul/config.json:

{
  "signals": { "enabled": true, "maxLogSizeKb": 50 },
  "reflection": {
    "enabled": true,
    "quickSignalThreshold": 20,
    "deepSignalThreshold": 100,
    "quickModel": "haiku",
    "deepModel": "sonnet"
  },
  "contextBudget": { "maxTokens": 4500 },
  "tensions": { "enabled": true },
  "metaOptimization": { "enabled": true },
  "writeProtection": { "enabled": true }
}

Philosophy

  1. Evidence over assertion — Frameworks earn their place through repeated confirmation.
  2. Local-first — No cloud, no accounts, no telemetry.
  3. Invisible when working — Extracts signals automatically, reflects in the background.

Contributing

Contributions welcome. Open an issue to discuss before submitting large PRs.

License

MIT

Files in the repo

Repository payload14 top-level entries
  • .github
  • docs
  • hooks
  • packages
  • scripts
  • .gitignore
  • Dockerfile
  • glama.json
  • LICENSE
  • package-lock.json
  • package.json
  • README.md
  • record-demo.sh
  • tsconfig.base.json

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More connectors

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

43k

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code

14k
okf-memory/
okf-agent-memory

Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300µs in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.

547
tirth8205/
code-review-graph

Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.

31k
2akouwu/
reverify

Stop your AI from making things up — it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.

1.1k
t8y2/dbxConnectors

20 MB lightweight cross-platform database client for 90+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 90+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP Server。

19k