bulletproof-memory

Never lose context again. The Write-Ahead Log (WAL) protocol with SESSION-STATE.md gives your agent bulletproof memory that survives compaction, restarts, and distractions. Part of the Hal Stack 🦞

7 stars

Best use case

bulletproof-memory is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Never lose context again. The Write-Ahead Log (WAL) protocol with SESSION-STATE.md gives your agent bulletproof memory that survives compaction, restarts, and distractions. Part of the Hal Stack 🦞

Teams using bulletproof-memory should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/bulletproof-memory/SKILL.md --create-dirs "https://raw.githubusercontent.com/Demerzels-lab/elsamultiskillagent/main/public/skills/halthelobster/bulletproof-memory/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/bulletproof-memory/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How bulletproof-memory Compares

Feature / Agentbulletproof-memoryStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Never lose context again. The Write-Ahead Log (WAL) protocol with SESSION-STATE.md gives your agent bulletproof memory that survives compaction, restarts, and distractions. Part of the Hal Stack 🦞

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Bulletproof Memory 🦞

**By Hal Labs** — Part of the Hal Stack

Your agent forgets things. Mid-conversation, after compaction, between sessions — context vanishes. This skill fixes that permanently.

## The Problem

Agents lose context in three ways:
1. **Compaction** — old messages get summarized/dropped
2. **Session restart** — agent wakes up fresh  
3. **Distraction** — mid-conversation, agent forgets earlier details

Traditional fix: "Remember to save important things." 

**But agents forget to remember.**

## The Solution: Write-Ahead Log (WAL) Protocol

The key insight: **trigger writes on USER INPUT, not agent memory.**

When the user provides a concrete detail, the agent writes it down BEFORE responding. The agent doesn't have to "remember" to save — the rule fires automatically based on what the user says.

| Old Approach | WAL Approach |
|--------------|--------------|
| "Remember to save important things" | "If user gives detail → write before responding" |
| Triggered by agent memory (unreliable) | Triggered by user INPUT (reliable) |
| Agent forgets to remember | Rule fires automatically |
| Saves after the fact (too late) | Saves before responding (never too late) |

## Quick Setup

### 1. Create SESSION-STATE.md

This is your agent's "hot RAM" — the active working memory that persists across compactions.

Create `SESSION-STATE.md` in your workspace root:

```markdown
# SESSION-STATE.md — Active Working Memory

This file is the agent's "RAM" — the hot transaction log for the current active task.
Chat history is a BUFFER. This file is STORAGE.

---

## Current Task
[What we're actively working on right now]

## Immediate Context
[Key details, decisions, corrections from this session]

## Key Files
[Paths to relevant files for this task]

## Last Updated
[Timestamp]
```

### 2. Add WAL Protocol to AGENTS.md

Add this to your agent's instructions:

```markdown
### WRITE-AHEAD LOG (WAL) PROTOCOL

**The Law:** You are a stateful operator. Chat history is a BUFFER, not storage.
`SESSION-STATE.md` is your "RAM" — the ONLY place specific details are safe.

**Trigger:** If the user provides a concrete detail (name, location, correction, decision):
1. You MUST update `SESSION-STATE.md` IMMEDIATELY
2. You MUST write to the file BEFORE you generate your response
3. Only THEN respond to the user

**Example:** User says "It's Doboce Park, not Duboce Triangle"
- WRONG: Acknowledge, keep chatting, maybe write later
- RIGHT: Update SESSION-STATE.md first, then respond

**Why this works:** The trigger is the user's INPUT, not your memory. You don't have 
to remember to check — the rule fires on what the user says.
```

### 3. Add Recovery Protocol

When context is lost, don't ask "what were we doing?" — recover it yourself:

```markdown
### Compaction Recovery Protocol

**Auto-trigger when:**
- Session starts with `<summary>` tag
- Message contains "truncated", "context limits", "Summary unavailable"
- User says "where were we?", "continue", "what were we doing?"
- You should know something but don't

**Recovery steps:**
1. **FIRST:** Read `SESSION-STATE.md` — this has the active task state
2. Read today's + yesterday's daily notes
3. If still missing context, use `memory_search`
4. Present: "Recovered from SESSION-STATE.md. Last task was X. Continue?"

**Do NOT ask "what were we discussing?" if SESSION-STATE.md has the answer.**
```

### 4. Add Session Startup Sequence

```markdown
## Every Session
Before doing anything else:
1. Read `SESSION-STATE.md` — your active working memory (FIRST PRIORITY)
2. Read your identity files (SOUL.md, USER.md, etc.)
3. Read `memory/YYYY-MM-DD.md` (today + yesterday) for recent context

Don't ask permission. Just do it.
```

### 5. Add Memory Flush Protocol

Monitor context and flush before you lose it:

```markdown
### Memory Flush Protocol

Monitor your context usage with `session_status`. Flush important context before compaction:

| Context % | Action |
|-----------|--------|
| < 50% | Normal operation |
| 50-70% | Write key points after substantial exchanges |
| 70-85% | Active flushing — write everything important NOW |
| > 85% | Emergency flush — full summary before next response |

**At >60%:** Update SESSION-STATE.md before every reply
**At >80%:** Write comprehensive handoff to daily notes

**What to flush:**
- Decisions made (what was decided and why)
- Action items (who's doing what)
- Open threads (anything unfinished)
- Corrections (things the user clarified)
```

## Why This Works

### The Trigger Insight

Most memory advice fails because it relies on the agent remembering to do something. But forgetting is the problem we're trying to solve!

The WAL protocol succeeds because:
- **Trigger = user input** (external, reliable)
- **Not trigger = agent memory** (internal, unreliable)

When the user says something concrete, the protocol fires. The agent doesn't need to remember anything — the rule activates based on what comes in.

### The SESSION-STATE.md Insight

Daily notes are great for logging what happened. But they're not structured for "what am I doing RIGHT NOW?"

SESSION-STATE.md is:
- **Hot** — the current active task, not history
- **Structured** — current task, context, key files
- **First priority** — read before anything else on startup

It's the difference between a journal and a sticky note on your monitor.

## Pre-Compaction Checklist

Before a long session ends or context gets critical:

- [ ] Current task documented in SESSION-STATE.md?
- [ ] Key decisions captured?
- [ ] Action items noted?
- [ ] User corrections saved?
- [ ] Could future-me continue from SESSION-STATE.md alone?

## Self-Summarization Prompt

When context hits 85%+, ask yourself:

> "If my context resets right now, what does future-me absolutely need to know to continue this task? Write it for someone with zero context."

This produces better summaries than mechanical extraction.

## The Complete Memory Stack

For comprehensive agent memory, combine this with:

| Skill | Purpose |
|-------|---------|
| **Bulletproof Memory** (this) | Never lose active context |
| **PARA Second Brain** | Organize long-term knowledge |
| **Proactive Agent** | Act without being asked |

Together, they create an agent that remembers everything, finds anything, and anticipates needs.

## Example SESSION-STATE.md

Here's a real example of what this looks like in practice:

```markdown
# SESSION-STATE.md — Active Working Memory

## Current Task
Building dashboard for Jordan — Life OS view with goal tracking

## Immediate Context
- Dashboard deployed to: https://halthelobster.github.io/hal-ops-dashboard/
- Added tabs: Operations + Life OS
- Jordan at Moontricks concert @ The Independent tonight
- Correction: It's "Shovelman" (one word), not "Shovel Man"

## Key Files
- Dashboard HTML: /Users/Hal/clawd/dashboard/index.html
- Life OS data: /Users/Hal/clawd/dashboard/life-os.json
- Social events log: notes/areas/social-events.md

## Last Updated
2026-01-29 11:00 PM PST
```

## Principles

1. **Write before responding** — The WAL protocol is non-negotiable
2. **Trigger on input** — User input fires the rule, not agent memory
3. **SESSION-STATE.md is first** — Always read it first on startup
4. **Flush early, flush often** — Don't wait for 85% context
5. **Structure for retrieval** — Future-you needs to continue, not just read

---

*Part of the Hal Stack 🦞*

*Pairs well with [PARA Second Brain](https://clawdhub.com/halthelobster/para-second-brain) for knowledge organization and [Proactive Agent](https://clawdhub.com/halthelobster/proactive-agent) for behavioral patterns.*

Related Skills

memory-system-v2

7
from Demerzels-lab/elsamultiskillagent

Fast semantic memory system with JSON indexing, auto-consolidation, and <20ms search. Capture learnings, decisions, insights, events. Use when you need persistent memory across sessions or want to recall prior work/decisions.

dory-memory

7
from Demerzels-lab/elsamultiskillagent

File-based memory system for AI agents that forget between sessions.

memory-setup

7
from Demerzels-lab/elsamultiskillagent

Enable and configure Moltbot/Clawdbot memory search for persistent context. Use when setting up memory, fixing "goldfish brain," or helping users configure memorySearch in their config. Covers MEMORY.md, daily logs, and vector search setup.

jpj-memory-manager

7
from Demerzels-lab/elsamultiskillagent

Automatic session logging and memory management for infrastructure, projects, and tools.

memory-pipeline

7
from Demerzels-lab/elsamultiskillagent

Complete agent memory + performance system. Extracts structured facts, builds knowledge graphs, generates briefings, and enforces execution discipline via pre-game routines, tool policies, result compression, and after-action reviews. Includes external knowledge ingestion (ChatGPT exports, etc.) into searchable memory. Use when working on memory management, briefing generation, knowledge consolidation, external data ingestion, agent consistency, or improving execution quality across sessions.

human-like-memory

7
from Demerzels-lab/elsamultiskillagent

This skill provides long-term memory capabilities for conversations.

enhanced-memory

7
from Demerzels-lab/elsamultiskillagent

Enhanced memory search with hybrid vector+keyword scoring, temporal routing, filepath scoring, adaptive weighting.

persistent-memory

7
from Demerzels-lab/elsamultiskillagent

Three-layer persistent memory system (Markdown + ChromaDB vectors + NetworkX knowledge graph) for long-term agent.

vta-memory

7
from Demerzels-lab/elsamultiskillagent

Reward and motivation system for AI agents. Dopamine-like wanting, not just doing. Part of the AI Brain series.

insula-memory

7
from Demerzels-lab/elsamultiskillagent

Internal state awareness for AI agents. Energy, mood, and interoception. Part of the AI Brain series.

hippocampus-memory

7
from Demerzels-lab/elsamultiskillagent

Persistent memory system for AI agents. Automatic encoding, decay, and semantic reinforcement — just like the hippocampus in your brain. Based on Stanford Generative Agents (Park et al., 2023).

basal-ganglia-memory

7
from Demerzels-lab/elsamultiskillagent

Habit formation and procedural learning for AI agents. Develop preferences and shortcuts through repetition. Part of the AI Brain series.