Skip to content

yahav10/claude-code-memory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 claude-session-memory

Give Claude Code a memory. Never re-explain architectural decisions again.

npm version License: MIT Node.js 100% Local Zero Telemetry

Save decisions. Auto-load context. Prove the ROI. 100% local.


😀 The Problem

Every new Claude Code session starts from scratch.

Session 1: "Let's use JWT for authentication because our microservices need stateless auth..."

Session 14: "Why are we using JWT?" β€” Claude has no idea.

Session 27: You're explaining the same decision for the fifth time.

CLAUDE.md helps but it's static, non-queryable, and becomes a dumping ground.


πŸ’° The Real Cost of Forgetting

Every time Claude doesn't know your project context, you pay for it β€” in tokens, in time, and in wrong answers.

  Without memory                          With memory
  ─────────────────                       ─────────────────
  You: "Add auth to /orders"              You: "Add auth to /orders"
        β”‚                                       β”‚
        β–Ό                                       β–Ό
  Claude: "What auth system                Claude calls query_memory("auth")
   do you use? JWT? Sessions?                    β”‚
   OAuth? What middleware?"                      β–Ό
        β”‚                                 Claude: "Adding JWT middleware
        β–Ό                                  using your existing auth pattern
  You: [5 minutes re-explaining]           from decision #12..."
        β”‚                                       β”‚
        β–Ό                                       β–Ό
  Claude: "Got it. And what                βœ… Correct implementation
   database? What ORM?"                      on first try
        β”‚
        β–Ό
  You: [3 more minutes explaining]
        β”‚
        β–Ό
  Claude builds it wrong anyway
   because context was incomplete

Without memory (session 30)

  • πŸ”„ Re-explain 3-5 decisions per session
  • πŸ’¬ 10-15 extra back-and-forth messages
  • ❌ Wrong assumptions from missing context
  • πŸ”₯ Token burn on repeated explanations
  • ⏱️ ~15 min wasted per session

With memory (session 30)

  • βœ… Claude recalls all 47 decisions instantly
  • πŸ’¬ Skip straight to implementation
  • 🎯 Correct assumptions from day one
  • πŸ“‰ Fewer tokens, faster completions
  • ⏱️ Time saved compounds every session

The math: If you run 3 Claude Code sessions/day and waste ~15 min each re-explaining context, that's 5+ hours/week. With a team of 4, that's 20 hours/week β€” gone. Project memory eliminates this entirely.


πŸ’‘ The Solution

An MCP server that gives Claude Code a queryable SQLite database of your project's architectural decisions β€” plus automatic session intelligence that loads the right context at the right time.

✨ Why Use It

Benefit What it means for you
🧠 Auto session continuity Claude knows what you worked on last session β€” branch, decisions, files changed
🎯 Smart context loading Relevant decisions are surfaced automatically based on your current branch and files
πŸ’° Proven ROI Track token savings, time saved, and hit rate β€” with real numbers
πŸ” Never re-explain decisions Claude remembers what you decided and why, across every session
πŸ“‹ Session review Get prompted to save decisions before ending a session β€” nothing slips through
πŸ”’ 100% local and private SQLite on your machine, zero network calls, zero telemetry

⚑ Quick Start

npx claude-session-memory init

Restart Claude Code. That's it. πŸŽ‰

🧠 Session Intelligence

Every session is smarter than the last:

  Session Start (get_stats)              Session End (review_session)
  ─────────────────────────              ────────────────────────────
  βœ… Last session context                βœ… Decisions saved this session
     Branch, decisions, files               What you captured
  βœ… Relevant decisions                  βœ… Files changed without decisions
     Matched by branch + files              What you might have missed
  βœ… Token savings ROI                   βœ… Suggestions
     Queries, hit rate, time saved          "Consider saving for auth.ts"

How context matching works:

  1. File matching β€” decisions linked to files you're currently modifying
  2. Branch keywords β€” feature/auth β†’ finds decisions tagged auth
  3. Recent fallback β€” always shows latest decisions if no specific match

πŸ”„ How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Claude Code Conversation                               β”‚
β”‚                                                         β”‚
β”‚  You: "Let's use PostgreSQL with Prisma ORM"            β”‚
β”‚                                                         β”‚
β”‚  Claude: "That sounds like an architectural decision.   β”‚
β”‚  Want me to save it?"                                   β”‚
β”‚                                                         β”‚
β”‚  You: "Yes"                                             β”‚
β”‚           β”‚                                             β”‚
β”‚           β–Ό                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  save_decision   │───▢│  .claude/project-memory.dbβ”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

             Β·Β·Β·  Next session  Β·Β·Β·

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  You: "Why did we choose PostgreSQL?"                   β”‚
β”‚           β”‚                                             β”‚
β”‚           β–Ό                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  query_memory    │◀──│  .claude/project-memory.dbβ”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚           β”‚                                             β”‚
β”‚           β–Ό                                             β”‚
β”‚  Claude: "You chose PostgreSQL 16 with Prisma ORM      β”‚
β”‚  because of ACID compliance, JSON support, and strong   β”‚
β”‚  community. Alternatives considered: MySQL, MongoDB."   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ MCP Tools

Tool Description
save_decision πŸ’Ύ Save an architectural decision with title, rationale, alternatives. Auto-detects duplicates via Jaccard similarity
query_memory πŸ” Search decisions using natural language. Logs every query for ROI tracking
list_recent πŸ“‹ List recent decisions across sessions
update_decision ♻️ Deprecate or supersede a decision
get_stats 🧠 Session intelligence β€” last session context, relevant decisions for current work, token savings ROI
review_session πŸ“‹ Review current session before ending β€” shows files changed without decisions, suggests what to save
sync_claude_md πŸ“ Export active decisions into your CLAUDE.md with auto-managed markers

πŸ’¬ Query Examples

"Why did we choose JWT?"
"What decisions affect src/auth.ts?"
"Show me recent decisions"
"Compare Pinia vs Vuex"
"Show deprecated decisions"
"What are the alternatives to Redis?"

πŸ–₯️ CLI Commands

Command Description
npx claude-session-memory init 🏁 Initialize project memory
npx claude-session-memory workspace-setup [dir] πŸ”— Share context memory across all sub-projects in a workspace
npx claude-session-memory export πŸ“€ Export decisions (JSON/Markdown/CSV)
npx claude-session-memory import <file> πŸ“₯ Import decisions from JSON
npx claude-session-memory sync-claudemd πŸ“ Sync active decisions into CLAUDE.md
npx claude-session-memory stats πŸ“Š Show memory statistics

Workspace Setup

If you have a monorepo or workspace with multiple sub-projects (each with their own .git), use workspace-setup to share context memory across all of them:

npx claude-session-memory workspace-setup /path/to/workspace
npx claude-session-memory workspace-setup --dry-run   # Preview changes
npx claude-session-memory workspace-setup --force      # Overwrite existing configs

This symlinks the root .mcp.json into every git sub-project so they all share the same decision history.

Export Formats

npx claude-session-memory export                          # JSON (default)
npx claude-session-memory export --format markdown        # Human-readable
npx claude-session-memory export --format csv             # Spreadsheet
npx claude-session-memory export --output ./backup.json   # Custom path

🧹 Smart Deduplication

When saving a new decision, the server automatically compares it against existing ones using Jaccard similarity on tokenized text:

Similarity Action
> 0.8 Auto-supersedes the older decision β€” you don't need to clean up
0.6 – 0.8 Returns a warning with similar decisions so you can decide
< 0.6 Saved without warnings

No configuration needed β€” dedup runs on every save_decision call.

⏳ Confidence Decay

Decisions tagged temporary or experimental automatically fade over 30 days:

Day  0  β†’ confidence 1.0 (full strength)
Day 15  β†’ confidence 0.5 (half strength)
Day 30  β†’ confidence 0.0 (fully faded)

Faded decisions (confidence < 0.3) are excluded from CLAUDE.md sync but remain queryable. Regular decisions never decay regardless of age.

πŸ“ CLAUDE.md Sync

Auto-generate a structured decisions section in your CLAUDE.md:

npx claude-session-memory sync-claudemd

Or call sync_claude_md as an MCP tool during a conversation. The output is injected between markers:

<!-- DECISIONS:START -->
## Architectural Decisions
_Auto-generated from project memory β€” 5 active decisions_

### Auth
- **Use JWT for authentication** β€” Stateless and scalable [auth, security]

### Database
- **Use PostgreSQL with Prisma** β€” ACID compliance [database]
<!-- DECISIONS:END -->

Any content outside the markers is preserved. If no markers exist, they're appended. If no CLAUDE.md exists, one is created.

πŸ“Š Token Savings & ROI

Every query_memory call is tracked. The dashboard shows real metrics:

Metric What it measures
Total Queries How often Claude queries your memory
Hit Rate % of queries that returned useful results
Tokens Saved Estimated tokens saved vs re-explaining (~300/query)
Time Saved Estimated minutes saved (~2 min/query)

View these in the web dashboard at /analytics or via get_stats in any session.

πŸ—οΈ Architecture

claude-session-memory
β”œβ”€β”€ Storage:      SQLite + FTS5 full-text search, WAL mode
β”œβ”€β”€ Transport:    MCP stdio (spawned by Claude Code)
β”œβ”€β”€ Intelligence: Session continuity, context matching, ROI tracking
β”œβ”€β”€ Dashboard:    Built-in web UI with analytics and AI coach
β”œβ”€β”€ Dependencies: better-sqlite3, @modelcontextprotocol/sdk, commander
└── Privacy:      100% local β€” zero network calls, zero telemetry

πŸ“‹ Requirements

  • Node.js >= 18
  • Claude Code

🀝 Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

πŸ“„ License

MIT β€” use it however you like.


What using project memory actually feels like

Session 1 β€” You save your first decision. Nothing special yet.
Session 5 β€” Claude stops asking what database you use. It knows.
Session 20 β€” Claude auto-loads your last session's context and relevant decisions before you say a word.
Session 50 β€” Dashboard shows 500+ tokens saved, 100+ minutes reclaimed. A new teammate asks "how does auth work?" β€” full history, instantly.

The more you use it, the more valuable it becomes.


Built with ❀️ for the Claude Code community

Stop re-explaining. Start remembering.

About

Give Claude Code a memory. Save architectural decisions during conversations, query them forever. 100% local, zero telemetry.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors