Skip to content

Instantly share code, notes, and snippets.

@behindthegarage
Created February 9, 2026 19:21
Show Gist options
  • Select an option

  • Save behindthegarage/1ba947e919f515ee847c107c415555b7 to your computer and use it in GitHub Desktop.

Select an option

Save behindthegarage/1ba947e919f515ee847c107c415555b7 to your computer and use it in GitHub Desktop.
OpenClaw: Cross-Session Context Pattern Solves the problem where MEMORY.md only loads in your main 1:1 session — leaving group chats, crons, and sub-agents blind to project context. The fix: Self-contained project docs in projects/ that are readable from any session. • Standardized template (Overview, Stack, API guide, Status) • Living registry …

Project Knowledge Base for OpenClaw

A pattern for solving cross-session context loss

The Problem

By default, OpenClaw loads MEMORY.md and USER.md only in your main 1:1 session. This means:

  • Group chats → No access to personal context
  • Isolated cron jobs → No memory of past conversations
  • Sub-agents → Flying blind on project details

You end up repeating yourself, or the AI makes wrong assumptions because it lacks context.

The Solution: Project Knowledge Base

Instead of relying on restricted memory files, create self-contained project docs that live in a projects/ directory. These are accessible from any session — DMs, groups, crons, sub-agents.

How It Works

1. Directory Structure

workspace/
├── projects/
│   ├── TEMPLATE.md          # Copy this for new projects
│   ├── INDEX.md             # Master registry of all projects
│   ├── data-dashboard.md    # Example: Analytics system
│   ├── automation-engine.md # Example: Task automation
│   └── research-summer.md   # Example: Research project
├── AGENTS.md                # Updated with auto-update rules
└── HEARTBEAT.md             # Updated with project audit check

2. The Template (TEMPLATE.md)

Every project doc follows the same structure:

# Project Name
> One-line description

## Overview
What it is, who it's for, what problem it solves

## Tech Stack
Language, hosting, deployment, auth, etc.

## User Guide
How humans use it day-to-day

## AI Guide  
API endpoints, data formats, how I should interact
- What I can do autonomously
- What requires asking first
- Cross-session safe info

## Architecture
Data flow, key decisions, gotchas

## Status
What's working, what's broken, what's planned

## History
Major milestones and dates

3. INDEX.md — The Registry

A living list of all projects with status:

Project Doc Status One-liner
Data Dashboard data-dashboard.md ✅ Active Real-time analytics and reporting system
Automation Engine automation-engine.md ✅ Active Self-improving task automation system
Research Project research-summer-2026.md ✅ Active Comprehensive field study documentation

4. Auto-Update Rule (AGENTS.md)

Add this to your AGENTS.md:

"When working on a project in any session, check if the project doc needs updating. If significant changes were made (new features, status changes, decisions, architecture changes), update projects/<name>.md before the session ends. No one should have to ask."

This means the AI keeps docs current automatically — no manual maintenance.

5. Heartbeat Audit (HEARTBEAT.md)

Add to your heartbeat checklist:

"- [ ] Projects Audit — Any workspace projects missing a doc? Flag drift."

Catches new projects that haven't been documented yet.

Key Benefits

Before After
AI forgets project details in groups AI references full project context anywhere
You repeat yourself every session AI reads the doc, knows the history
No structured project info Standardized, searchable project library
MEMORY.md gets cluttered Projects live in their own docs
Context lost in isolated sessions Projects are cross-session safe

Real Example

User: "Check the dashboard for upcoming events"

Before: In a group chat, I'd have no idea what "dashboard" means or how to access it.

After: I read projects/data-dashboard.md, see the API endpoint (/api/events), auth method (API key), and make the call immediately.

How to Implement

Step 1: Create the directory

mkdir -p ~/workspace/projects

Step 2: Copy TEMPLATE.md

cp TEMPLATE.md your-project-name.md

Step 3: Fill it out

Write the doc before writing code. It forces clarity.

Step 4: Add to INDEX.md

Keep the registry current.

Step 5: Update AGENTS.md

Add the auto-update rule.

Step 6: Update HEARTBEAT.md

Add the projects audit check.

Tips

Make it exhaustive. Include API endpoints, auth details, phone numbers, pricing — anything you'd need to work on this without asking.

Write for three audiences:

  • You (human) — Quick reference
  • AI in any session — Technical details to get things done
  • Future collaborators — Context and history

Let the AI update it. Don't maintain it manually. The auto-update rule means significant changes get captured automatically.

Cross-session by design. These docs are explicitly not in the restricted context. They're meant to be readable everywhere.

Advanced: Project Pipeline

You can extend this into a full project pipeline:

  1. Idea capture → Add to INDEX.md with status "💤 Idea"
  2. Evaluation → Fill out Overview and Status sections
  3. Prioritization → Tag with category (work, personal, infrastructure)
  4. Active dev → Full doc, auto-updates as you build
  5. Archive → Move to "💤 Dormant" or "✅ Complete"

The INDEX.md becomes your project dashboard.


Pattern developed: February 2026 License: Steal this idea

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