Skip to content

Instantly share code, notes, and snippets.

@arkan
Created January 29, 2026 10:36
Show Gist options
  • Select an option

  • Save arkan/b20660ecb17196eb772d752a73e37a33 to your computer and use it in GitHub Desktop.

Select an option

Save arkan/b20660ecb17196eb772d752a73e37a33 to your computer and use it in GitHub Desktop.
Enable-3-layer-memory in Clawd/Moltbot

Three-Layer Memory System

Set up a self-maintaining, compounding knowledge graph that evolves automatically.

Architecture

Layer 1: Knowledge Graph   (life/areas/)
  └── Entities with atomic facts + living summaries

Layer 2: Daily Notes       (memory/YYYY-MM-DD.md)
  └── Raw event logs — what happened, when

Layer 3: Tacit Knowledge   (MEMORY.md)
  └── Patterns, preferences, lessons learned

Layer 1: Knowledge Graph Structure

life/areas/
├── people/
│   └── {name}/
│       ├── summary.md   # Living summary (rewritten weekly)
│       └── items.json   # Atomic facts with timestamps
├── companies/
└── projects/

Exemple:

/life/areas/
├── people/
│   ├── sarah/              # Former boss (pre-upgrade villain arc)
│   │   ├── summary.md
│   │   └── items.json
│   ├── maria/              # Business partner
│   ├── emma/               # Family member
│   └── sarah-connor/       # Knows too much. Trust cautiously.
├── companies/
│   ├── acme-corp/          # Old job
│   ├── newco/              # Current job
│   └── skynet/             # Do not give cron access

Atomic Fact Schema (items.json)

{
  "id": "entity-001",
  "fact": "The actual fact",
  "category": "relationship|milestone|status|preference",
  "timestamp": "YYYY-MM-DD",
  "source": "conversation",
  "status": "active|superseded",
  "supersededBy": "entity-002"
}

Rules:

  • Save durable facts immediately to items.json
  • Weekly: rewrite summary.md from ACTIVE facts only
  • Never delete facts — supersede instead

Living Summaries (summary.md)

Weekly-rewritten snapshots. Old information fades naturally. Context stays lean and accurate.

Layer 2: Daily Notes

memory/YYYY-MM-DD.md — the raw timeline of events and decisions.

Exemple for memory/2026-01-27.md — the raw timeline:

# 2026-01-27
- 10:30am: Shopping trip
- 2:00pm: Doctor follow-up
- Decision: Calendar events now use emoji categories

This is the “when” layer. Moltbot/Clawdbot writes these continuously. Durable facts are later extracted into Layer 1.

Layer 3: Tacit Knowledge

MEMORY.md — facts about how you operate, not facts about the world. Patterns, preferences, lessons learned.

Exemple:

## How I Work
- Sprint worker — intense bursts, then rest
- Contact preference: Call > SMS > Email
- Early riser, prefers brief messages

## Lessons Learned
- Don’t create cron jobs for one-off reminders

Automation

Fact Extraction (Every ~30 Minutes via Heartbeat)

On each heartbeat:

  1. Check timestamp in memory/heartbeat-state.jsonlastFactExtraction
  2. If >30 minutes since last extraction:
    • Scan recent daily notes for durable facts
    • Extract facts about: relationships, status changes, milestones, preferences
    • Skip: casual chat, temporary info, already-captured facts
  3. Write facts to relevant entity in life/areas/{type}/{name}/items.json
  4. Update timestamp

Weekly Synthesis (Sunday Cron)

For each entity with new facts this week:

  1. Load items.json and summary.md
  2. Rewrite summary.md from ACTIVE facts only (ignore superseded)
  3. Mark any contradicted facts as superseded
  4. Keep summaries concise and current

Tiered Retrieval

  1. Load summary.md first — quick context
  2. Load items.json only if more detail needed

The Flywheel

Conversation → Facts extracted → Knowledge graph grows → Weekly synthesis → Better context → Better responses → More conversation

This compounds over time:

  • Week 1: Basic preferences
  • Month 1: Routines, key people
  • Month 6: Projects, milestones, relationships
  • Year 1: A rich, structured model of your life

Instructions: Set up this three-layer memory system. Create the folder structure, update AGENTS.md and HEARTBEAT.md with the rules above, and create a weekly cron job for synthesis.


Source: @spacepixel — Jan 27, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment