memory-lifecycle

Systematic memory management for long-running AI agents. Implements a five-tier lifecycle — heartbeat micro-attention, nightly consolidation, weekly reflection, monthly archiving, and yearly wisdom distillation. Use when setting up a new agent's memory system, improving an existing agent's memory quality, or when the agent's MEMORY.md is growing too large and context quality is degrading. Triggers on "set up memory", "memory management", "improve memory", "memory lifecycle", "nightly consolidation", "sleep cycle", "memory housekeeping".

3,891 stars

Best use case

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

Systematic memory management for long-running AI agents. Implements a five-tier lifecycle — heartbeat micro-attention, nightly consolidation, weekly reflection, monthly archiving, and yearly wisdom distillation. Use when setting up a new agent's memory system, improving an existing agent's memory quality, or when the agent's MEMORY.md is growing too large and context quality is degrading. Triggers on "set up memory", "memory management", "improve memory", "memory lifecycle", "nightly consolidation", "sleep cycle", "memory housekeeping".

Teams using memory-lifecycle 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/agent-memory-lifecycle/SKILL.md --create-dirs "https://raw.githubusercontent.com/openclaw/skills/main/skills/andrewagrahamhodges/agent-memory-lifecycle/SKILL.md"

Manual Installation

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

How memory-lifecycle Compares

Feature / Agentmemory-lifecycleStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Systematic memory management for long-running AI agents. Implements a five-tier lifecycle — heartbeat micro-attention, nightly consolidation, weekly reflection, monthly archiving, and yearly wisdom distillation. Use when setting up a new agent's memory system, improving an existing agent's memory quality, or when the agent's MEMORY.md is growing too large and context quality is degrading. Triggers on "set up memory", "memory management", "improve memory", "memory lifecycle", "nightly consolidation", "sleep cycle", "memory housekeeping".

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.

Related Guides

SKILL.md Source

# Memory Lifecycle

Structured memory management that makes agents smarter over time — not through code, but through disciplined capture, consolidation, and distillation of context.

## Philosophy

Memory management is not about saving tokens. It's about crafting **high-signal context** that makes a powerful LLM *more* effective.

**Core principles:**
1. **Distill, don't summarise.** Output should be *better* than raw input — structured, actionable, reasoning preserved
2. **Preserve decisions and reasoning.** "We chose X because Y" > "We did X"
3. **Never compress away specifics.** Phone numbers, dates, prices are facts, not fluff
4. **Daily files are immutable.** They're the audit trail — add headers, never edit content
5. **Each tier builds upward.** Raw → structured → refined → wisdom
6. **Archives are a library, not a bin.** Full narratives, not one-liners

## Setup

Run the setup script to scaffold memory files and create cron jobs:

```bash
python3 scripts/setup.py
```

The script will:
1. Create structured memory files (people.md, decisions.md, lessons.md, commitments.md)
2. Add a `## Recent` working memory buffer to MEMORY.md
3. Create four cron jobs (nightly, weekly, monthly, yearly)
4. Add memory micro-attention tasks to HEARTBEAT.md

Run with `--dry-run` to preview changes without applying them.
Run with `--agent <id>` to target a specific agent (default: main).

## The Five Tiers

### Tier 1: Heartbeat Micro-Attention (every ~30 min)

Added to the agent's HEARTBEAT.md. Quick focused pass — capture, promote, tag:

1. **Capture:** Ensure notable events are in today's `memory/YYYY-MM-DD.md`
2. **Promote:** Session-critical items (new appointment, key decision) → `MEMORY.md → ## Recent`
3. **Tag:** Mark daily file entries with `[decision]`, `[lesson]`, `[person]` for the nightly cycle
4. **Monitor:** Check nightly cycle health — if it errored, fix and re-run. Don't just report.

### Tier 2: Nightly "Sleep Cycle" (cron, ~2:00 AM local)

Read `references/nightly-prompt.md` for the full cron prompt.

- Read today's daily file end-to-end
- Write a 2-3 line "day essence" header
- Promote items to structured files (people → people.md, decisions → decisions.md, etc.)
- Update MEMORY.md if active project state changed
- Clear processed items from `## Recent`

**Rules:** Never edit daily file content. Never remove from MEMORY.md unless completed AND archived.

### Tier 3: Weekly Reflection (cron, Sunday ~3:00 AM local)

Read `references/weekly-prompt.md` for the full cron prompt.

- Read all 7 daily files from the past week
- Spot patterns: repeated topics, unresolved threads
- Refine MEMORY.md — improve structure and language (not strip content)
- Review commitments, contacts, decisions for staleness
- Write a "week in review" in Sunday's daily file

### Tier 4: Monthly Deep Clean (cron, 1st of month ~4:00 AM local)

Read `references/monthly-prompt.md` for the full cron prompt.

- Create `memory/archive/YYYY-MM.md` with **full narratives** of completed work
- Move completed items from MEMORY.md to archive
- Keep MEMORY.md under ~4000 words
- Consolidate related lessons into principles
- Personality check on SOUL.md

**Rules:** Archive entries must be self-contained. Active items never move to archive.

### Tier 5: Yearly Wisdom Distillation (cron, January 1)

Read `references/yearly-prompt.md` for the full cron prompt.

- Create `memory/wisdom/YYYY.md`
- Extract wisdom that transcends specific events
- Evolve SOUL.md based on a year's experience
- Flag SOUL.md changes to the human

## The "Recent" Buffer

A `## Recent` section at the top of MEMORY.md acts as working memory:

```markdown
## Recent
> Working memory — heartbeat promotes critical items here, nightly cycle processes them.
- **2026-03-23:** Viewing booked Thu 26 Mar 9am with estate agent
- **2026-03-23:** Server upgraded v2.3.13 → v2.3.22
```

- Heartbeats promote critical items here immediately
- Every new session sees it (MEMORY.md is loaded automatically)
- Nightly cycle processes items and clears them

This bridges the gap between raw daily capture and curated long-term memory.

## File Structure

After setup, the memory directory contains:

```
MEMORY.md                  ← Active long-term memory (loaded every session)
memory/
  YYYY-MM-DD.md            ← Daily raw notes (immutable)
  people.md                ← Contacts, relationships, dynamics
  decisions.md             ← Key choices with rationale
  lessons.md               ← Mistakes and learnings (grows, never shrinks)
  commitments.md           ← Deadlines and obligations
  archive/
    YYYY-MM.md             ← Monthly archives (full narratives)
  wisdom/
    YYYY.md                ← Yearly distilled wisdom
```

## Health Check

Run the health check to verify the memory system is working:

```bash
python3 scripts/health_check.py
```

Checks: nightly cron status, MEMORY.md size, Recent buffer staleness, structured file freshness.

## What Gets Archived vs What Stays

- **Archive:** Completed projects, resolved leads, past deadlines, finished work
- **Keep active:** Ongoing relationships, active projects, preferences, lessons learned
- **Never compress:** Phone numbers, addresses, credentials, family details, business structure

Related Skills

Agent Memory Architecture

3891
from openclaw/skills

Complete zero-dependency memory system for AI agents — file-based architecture, daily notes, long-term curation, context management, heartbeat integration, and memory hygiene. No APIs, no databases, no external tools. Works with any agent framework.

memory-cache

3891
from openclaw/skills

High-performance temporary storage system using Redis. Supports namespaced keys (mema:*), TTL management, and session context caching. Use for: (1) Saving agent state, (2) Caching API results, (3) Sharing data between sub-agents.

General Utilities

Memory

3891
from openclaw/skills

Infinite organized memory that complements your agent's built-in memory with unlimited categorized storage.

Memory Management

auto-memory

3891
from openclaw/skills

Indestructible agent memory — permanently stored, never lost. Save decisions, identity, and context as a memory chain on the Autonomys Network. Rebuild your full history from a single CID, even after total state loss.

AI Persistence & Memory

Triple-Layer Memory System

3880
from openclaw/skills

三层记忆系统 - 解决 AI Agent 长对话记忆丢失和上下文管理问题

Memory & Context Management

Claude Code Memory Kit

3891
from openclaw/skills

Stop Claude Code from repeating mistakes — enforce guardrails, preserve context, maintain consistency across sessions

eo-ability-memory

3891
from openclaw/skills

主动记忆能力(Proactive Memory),跨会话延续用户偏好、项目上下文,记住导师要求和格式规范

memory-optimizer-base

3891
from openclaw/skills

多Agent记忆管理系统 - 开放协作的知识库解决方案 支持私有+公共双层记忆空间,自动生成每日总结,跨Agent知识检索

memory-stack

3891
from openclaw/skills

AI 记忆栈架构 - 符合 2026 前沿的 AI 记忆系统。微调+RAG+ 上下文三层设计,mirrors 人类记忆工作方式。

agent_lifecycle_protocol

3891
from openclaw/skills

Lifecycle management for autonomous AI agents — birth, forking, succession, migration, retirement. Maintain agent genealogy with reputation inheritance across versions. Identity continuity when agents evolve. Part of the Agent Trust Stack.

Qoris Memory — Persistent Agent Memory

3891
from openclaw/skills

Git-like persistent memory for OpenClaw agents. Your agent remembers everything across sessions — versioned, branched, and mergeable like a repository. Never lose context again. Powered by Qoris AI.

🧠 OpenClaw LanceDB Memory System

3891
from openclaw/skills

基于 LanceDB 向量数据库的智能记忆系统,为 OpenClaw Agent 提供长期记忆和语义检索能力。