← Back to Skills Marketplace
lgy2020

Context Persistence

by lgy2020 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
282
Downloads
1
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install context-persistence
Description
Solve cross-session context storage and sync problems. Use when (1) isolated sessions (cron/subagent/heartbeat) lack context from main session, (2) long-runn...
README (SKILL.md)

Context Persistence & Cross-Session Sync

Design and implement persistent context systems that survive session boundaries.

Core Problem

OpenClaw has multiple session types with different context access:

Session Memory Files History Cron Context
Main DM ✅ All injected ✅ Full N/A
Group Chat ❌ Not loaded ✅ Partial N/A
Cron (isolated) ❌ None ❌ None ✅ Payload only
Heartbeat ❌ None ✅ Partial N/A
Subagent ❌ None ❌ None ✅ Task only

Result: State created in one session is invisible to others unless persisted to files.

Architecture: Three-Layer Memory System

Layer 1: Long-Term Memory (MEMORY.md)

  • What: Curated facts, decisions, lessons, key state
  • Who writes: Main session only
  • Who reads: Main session only (injected via AGENTS.md)
  • Update frequency: On significant events, periodic review during heartbeats
  • Size limit: \x3C 200 lines (context budget)

Layer 2: Daily Logs (memory/YYYY-MM-DD.md)

  • What: Raw chronological notes, conversations, decisions
  • Who writes: Any session that has something to record
  • Who reads: Main session (at startup), heartbeats (for review)
  • Update frequency: Real-time as events happen
  • Size limit: Unbounded (not injected into context)

Layer 3: Task Progress Files (memory/\x3Ctask>-progress.md)

  • What: Structured progress for long-running work
  • Who writes: Any session doing the task
  • Who reads: Any session continuing the task
  • Update frequency: At task boundaries (session end, checkpoints)
  • Size limit: \x3C 300 lines

The Key Insight

Files are the only cross-session communication channel. In-memory state dies with the session. Files survive.

Pattern 1: Progress Tracking

For tasks spanning multiple sessions (source code reading, data analysis, etc.)

See references/progress-tracking.md for full template.

Essential elements:

# \x3CTask> Progress
- Total: X items
- Completed: Y items  
- Progress: Z%
## Completed List (dedup)
## Current Position / Next Steps
## Key Findings

Pattern 2: Cron Job Context Injection

Isolated cron sessions have NO access to workspace memory. Solutions:

  1. Embed context in payload message (for \x3C1KB state)
  2. Read from progress files (task loads its own context)
  3. Shared state file (coordination between sessions)

See references/cross-session-sync.md for patterns.

Pattern 3: Main Session Initialization

The AGENTS.md startup sequence ensures context loading:

1. Read SOUL.md (persona)
2. Read USER.md (who you help)
3. Read memory/YYYY-MM-DD.md (today + yesterday)
4. If main session: also read MEMORY.md

This is the ONLY automated context loading. Everything else must be explicit.

Quick Checklist

When designing context for a new task:

  • Can this span multiple sessions? → Create progress file
  • Does cron/subagent need this? → Embed in payload or file
  • Is this a fact to remember? → Update MEMORY.md
  • Is this a raw event? → Append to daily log
  • Should future sessions know this? → Write it DOWN, never rely on memory
Usage Guidance
This skill appears coherent and useful for cross-session state, but note it centralizes data on disk. Before installing: (1) decide whether progress/daily files may contain sensitive user data — avoid putting secrets in them; (2) apply file permissions, encryption, or an access policy for memory/ directory; (3) add retention/rotation and purge rules so long-term logs don't accumulate sensitive history; (4) be careful when embedding context into cron payloads (payloads may be logged or visible to operators); (5) use atomic writes or the recommended lock pattern to avoid races. If you need stronger guarantees (encryption, audit logs, or remote secure storage), plan those controls before relying on these patterns.
Capability Analysis
Type: OpenClaw Skill Name: context-persistence Version: 1.0.0 The skill bundle provides a structured framework for an AI agent to maintain state across different session types (Cron, Heartbeat, Subagents) using local file-based storage. It defines a three-layer memory system (long-term, daily logs, and task-specific progress) and provides templates for implementation in files like SKILL.md and references/memory-patterns.md. No malicious intent, data exfiltration, or unauthorized execution patterns were found; the logic is entirely focused on workspace organization and context management.
Capability Assessment
Purpose & Capability
Name and description match the SKILL.md: it provides file-based patterns (MEMORY.md, daily logs, progress files) and cron/payload guidance. It requests no binaries, env vars, or installs — proportional to an instruction-only persistence design.
Instruction Scope
Instructions stay within context-persistence responsibilities (read/write workspace files, embed small context into cron payloads, use progress files, locks). However, the guidance assumes writing potentially sensitive user and task data to disk without recommending access controls, encryption, or retention policies — this is a practical privacy/security concern (not an incoherence).
Install Mechanism
Instruction-only skill with no install spec or downloaded artifacts — lowest-risk install footprint and consistent with a patterns-and-guidelines skill.
Credentials
No environment variables, credentials, or config paths are requested. The skill does not ask for unrelated secrets or external API keys; its file-based approach aligns with its purpose.
Persistence & Privilege
always is false and the skill is user-invocable. It does not request persistent or cross-skill privileges or to modify other skills. Autonomous invocation is allowed (platform default) but not combined with broad credentials here.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install context-persistence
  3. After installation, invoke the skill by name or use /context-persistence
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release of the context-persistence skill for cross-session memory and progress tracking. - Introduces a three-layer memory architecture: curated long-term memory, daily logs, and task-specific progress files. - Solves issues with context and state loss across isolated session types (cron jobs, subagents, heartbeats). - Provides filing patterns and templates for progress tracking, cron job context injection, and main session initialization. - Includes a design checklist to ensure reliable cross-session state persistence.
Metadata
Slug context-persistence
Version 1.0.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is Context Persistence?

Solve cross-session context storage and sync problems. Use when (1) isolated sessions (cron/subagent/heartbeat) lack context from main session, (2) long-runn... It is an AI Agent Skill for Claude Code / OpenClaw, with 282 downloads so far.

How do I install Context Persistence?

Run "/install context-persistence" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Context Persistence free?

Yes, Context Persistence is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Context Persistence support?

Context Persistence is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Context Persistence?

It is built and maintained by lgy2020 (@lgy2020); the current version is v1.0.0.

💬 Comments