Sandbox
@blas0/UnseveredMemory

Claude Code memory hooks and markdown files

Unsevered Memory adds a local memory layer to Claude Code with SessionStart, UserPromptSubmit, and SessionEnd hooks. Those hooks load project state, inject a reminder on every prompt, and archive the scratchpad so context survives long sessions. It stores the working memory in markdown files and uses a small orchestrator command for multi-step tasks.

49 stars3 forksShellUpdated 8mo ago
Who it's for

Builders who use Claude Code and want a local memory system that stays active across long sessions.

What it delivers

You can keep project context, decisions, and next steps visible to your agent instead of losing them to compaction.

What it does

Session start loading

Loads `context.md` and `scratchpad.md` when a Claude Code session begins.

Per-prompt reminders

Injects a fresh memory reminder on every `UserPromptSubmit` so context survives compaction.

Session end archiving

Saves the scratchpad to dated session files and reminds you to update `context.md`.

Orchestrator command

Provides `/orchestrate` to break a task into subtasks and delegate work while keeping memory updated.

Local file-based memory

Uses `.claude/memory/` and `.ai/` folders for current state, decisions, workflows, and reusable patterns.

Claude plugin and npx setup

Supports installation through a Claude plugin, `npx`, or a manual shell script.

How to get it

  1. 1Run
    # Add marketplace
    /plugin marketplace add blas0/UnseveredMemory
    
    # Install plugin
    /plugin install unsevered-memory@blas0
  2. 2Then per-project
    cd /path/to/your/project
    /unsevered-memory project
  3. 3Run
    # Global setup
    npx unsevered-memory init
    
    # Per-project setup
    cd /path/to/your/project
    npx unsevered-memory project
  4. 4Run
    git clone https://github.com/blas0/UnseveredMemory.git
    cd UnseveredMemory
    ./setup-global.sh
  5. 5Then per-project
    cd /path/to/your/project
    ~/.claude/setup-project.sh

README

Unsevered Memory

Unsevered Memory

Claude Code Bash Markdown npm

A markdown-based memory system for Claude Code with enforced persistence.

Changelog

  • Added support for Claude plugins + npx packaging

What Makes This Different

Most memory systems inject context at session start and hope Claude remembers. This doesn't work because:

  1. Context compaction loses early instructions
  2. Claude has no obligation to follow suggestions
  3. Long sessions forget the protocol

Unsevered Memory solves this with enforcement:

HookWhenPurpose
SessionStartSession beginsLoad full context
UserPromptSubmitEvery promptInject state reminder
SessionEndSession endsArchive + remind

The UserPromptSubmit hook survives context compaction by being injected fresh on every message.

Architecture

Enforcement Layer
├── SessionStart ──────> Load context.md + scratchpad
├── UserPromptSubmit ──> [Memory] Task: X | Scratchpad: Y lines
└── SessionEnd ────────> Archive scratchpad, remind to update

File Structure
├── .claude/memory/     # Dynamic (every session)
│   ├── context.md      # Current state, next steps
│   ├── scratchpad.md   # Live session operations
│   ├── decisions.md    # Architectural choices
│   └── sessions/       # Daily archives
│
└── .ai/                # Static (when patterns emerge)
    ├── core/           # Tech stack, architecture
    ├── patterns/       # Reusable solutions (after 3+ uses)
    └── workflows/      # Dev processes

Installation

Choose your preferred method:

Option A: Claude Plugin (Recommended)

# Add marketplace
/plugin marketplace add blas0/UnseveredMemory

# Install plugin
/plugin install unsevered-memory@blas0

Then per-project:

cd /path/to/your/project
/unsevered-memory project

Option B: npx

# Global setup
npx unsevered-memory init

# Per-project setup
cd /path/to/your/project
npx unsevered-memory project

Option C: Manual

git clone https://github.com/blas0/UnseveredMemory.git
cd UnseveredMemory
./setup-global.sh

Then per-project:

cd /path/to/your/project
~/.claude/setup-project.sh

What Gets Installed

Global (~/.claude/):

  • CLAUDE.md - Global memory protocol
  • settings.json - Hook configuration (3 hooks)
  • hooks/ - memory-load, memory-remind, memory-save
  • skills/orchestrate/ - Workflow instructions
  • commands/orchestrate.md - Orchestrator command

Per-Project:

project/
├── CLAUDE.md               # Project instructions
├── .ai/                    # Static documentation
│   ├── core/
│   │   ├── technology-stack.md
│   │   └── architecture.md
│   ├── patterns/
│   └── workflows/
└── .claude/
    └── memory/
        ├── context.md      # Cross-session state
        ├── scratchpad.md   # Live session log
        ├── decisions.md    # Decision log
        └── sessions/       # Daily archives

Workflow

Session Start

  1. Hook loads context.md and scratchpad.md
  2. Claude sees current state and any unfinished work
  3. Hook hints about .ai/ documentation

During Session

Every prompt shows:

[Memory] Task: Fix auth bug | Scratchpad: 24 lines | .ai/ updated: 2024-01-15

Claude writes to scratchpad.md as it works:

## Session: 2024-01-15 14:30

### Operations
- [14:35] Found issue in validateToken() at src/auth.ts:142
- [14:40] Fixed: was comparing wrong field

### Decisions
- Keep backward compatibility by checking both fields

Claude updates .ai/ when patterns emerge (3+ uses).

Session End

  1. Hook archives scratchpad to sessions/YYYY-MM-DD.md
  2. Hook reminds to update context.md
  3. Claude updates context with current state

Orchestrator Mode

For complex multi-step tasks:

/orchestrate Implement user authentication with JWT

The orchestrator:

  1. Reads all memory files
  2. Breaks task into subtasks
  3. Delegates to specialized agents
  4. Updates memory after each step
  5. Never loses context

File Purposes

FileContentUpdate Frequency
context.mdCurrent state, next stepsEnd of session
scratchpad.mdOperations, findingsDuring session
decisions.mdArchitectural choicesWhen decisions made
.ai/core/Tech stack, architectureWhen they change
.ai/patterns/Reusable solutionsAfter 3+ uses

Repository Structure

UnseveredMemory/
├── .claude-plugin/           # Plugin manifest
│   ├── plugin.json
│   └── marketplace.json
├── package.json              # npm package
├── bin/cli.js                # npx entry point
├── src/commands/             # CLI commands
├── setup-global.sh           # Manual installer
├── scripts/                  # Hook scripts (plugin)
├── hooks/                    # Hook scripts + hooks.json
├── skills/
│   └── orchestrate/
│       └── SKILL.md
├── commands/
│   └── orchestrate.md
└── templates/
    └── [all templates]

Philosophy

  • Enforced - UserPromptSubmit hook survives context compaction
  • Simple - Bash + markdown, no databases, no APIs
  • Offline - Everything is local files
  • Native - Uses Claude Code's built-in hooks system
  • Proactive - Claude updates .ai/ during work, not after

Enforcement Levels

ApproachReliability
CLAUDE.md only~30%
+ SessionStart~50%
+ UserPromptSubmit~75%
+ /orchestrate orchestrator~95%

Uninstall

# npx
npx unsevered-memory uninstall

# Manual
rm -rf ~/.claude/hooks/memory-*.sh
rm -rf ~/.claude/skills/orchestrate
rm -rf ~/.claude/commands/orchestrate.md

# Project files (optional)
rm -rf .claude/memory
rm -rf .ai

Files in the repo

Repository payload20 top-level entries
  • .claude
  • .claude-plugin
  • bin
  • commands
  • hooks
  • node_modules
  • scripts
  • skills
  • src
  • templates
  • .gitignore
  • .npmignore
  • CLAUDE.md
  • LICENSE
  • package-lock.json
  • package.json
  • PLAN.md
  • README.md
  • setup-global.sh
  • Unsevered.jpeg

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 hooks

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

80k

Warcraft III Peon voice notifications (+ more!) for Claude Code, Codex, IDEs, and any AI agent. Stop babysitting your terminal. Employ a Peon today.

5k
bahni-m/
code-with-quran

Read the Qur'an while Claude Code works. Start a session with 'claude --cwq' and a reader beside it walks forward through the Qur'an one ayah per prompt, resuming where you left off — in a terminal pane or a browser tab. Zero dependencies, fully offline.

48
zachahn/
vomit

Clean up Claude's token vomit with a separate LLM. Save your tokens, Opus is hopeless

193

A pre-execution guard for AI coding agents. It blocks destructive Git and file system commands, plus common attempts to access sensitive files, before a tool call runs. Supports Amp Code, Antigravity CLI, Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot CLI, Grok Build, Hermes Agent, Kimi Code, OpenClaw, OpenCode, and Pi.

1.5k