Memory Graph Builder logo

Memory Graph Builder

Community
ArchieIndian
memory-graph-builder

Parses OpenClaw's flat MEMORY.md into a structured knowledge graph — detects duplicates, contradictions, and stale entries, then builds a compressed memory digest optimized for system prompt injection.

Overview

PublisherArchieIndian
Repositoryopenclaw-superpowers
Skill namememory-graph-builder
Stars
74
Forks
14
Bundled files
3
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by ArchieIndian on GitHub. Read the source before you install it.

Installation

Install the Memory Graph Builder AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/ArchieIndian/openclaw-superpowers/tree/main/skills/openclaw-native/memory-graph-builder
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ArchieIndian/openclaw-superpowers.git /tmp/openclaw-superpowers
mkdir -p .claude/skills
cp -r /tmp/openclaw-superpowers/skills/openclaw-native/memory-graph-builder .claude/skills/memory-graph-builder
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Memory Graph Builder in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Memory Graph Builder on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Memory Graph Builder is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Memory Graph Builder

What it does

OpenClaw stores agent memory in a flat MEMORY.md file — one line per fact, no structure, no relationships. This works until your agent has 200+ memories and half of them are duplicates, three contradict each other, and the whole file costs 4,000 tokens every session.

Memory Graph Builder treats MEMORY.md as a raw data source and builds a structured knowledge graph on top of it. Each memory becomes a node with typed relationships to other nodes. The graph enables:

  • Duplicate detection — "User prefers dark mode" and "User likes dark theme" are the same fact
  • Contradiction detection — "User uses Python 3.8" vs "User uses Python 3.12"
  • Staleness detection — Facts older than a configurable threshold that haven't been referenced
  • Memory digest — A compressed, relationship-aware summary that replaces raw MEMORY.md in the system prompt, saving 30-60% tokens

Inspired by OpenLobster's Neo4j-backed graph memory system, adapted to work on top of OpenClaw's existing MEMORY.md without requiring a database.

When to invoke

  • Automatically, nightly at 10pm (cron)
  • After bulk memory additions (e.g., after project-onboarding)
  • When the agent's context initialisation feels slow (memory bloat)
  • Manually to audit memory quality

Graph structure

Each memory line becomes a node:

yaml
nodes:
  - id: "mem_001"
    text: "User prefers Python for backend work"
    category: preference    # preference | fact | project | person | tool | config
    entities: ["user", "python", "backend"]
    added_at: "2026-03-01"
    last_referenced: "2026-03-15"
    confidence: 0.9
edges:
  - from: "mem_001"
    to: "mem_014"
    relation: related_to    # related_to | contradicts | supersedes | depends_on

How to use

bash
python3 graph.py --build                    # Parse MEMORY.md, build graph
python3 graph.py --duplicates               # Show duplicate clusters
python3 graph.py --contradictions           # Show contradicting pairs
python3 graph.py --stale --days 30          # Show memories not referenced in 30 days
python3 graph.py --digest                   # Generate compressed memory digest
python3 graph.py --digest --max-tokens 1500 # Digest with token budget
python3 graph.py --prune --dry-run          # Show what would be removed
python3 graph.py --prune                    # Remove duplicates + stale entries
python3 graph.py --stats                    # Graph statistics
python3 graph.py --status                   # Last build summary
python3 graph.py --format json

Cron wakeup behaviour

Nightly at 10pm:

  1. Read MEMORY.md
  2. Rebuild graph (incremental — only re-processes new/changed lines)
  3. Detect duplicates and contradictions
  4. Flag stale entries (>30 days unreferenced by default)
  5. Generate fresh memory digest
  6. Write digest to ~/.openclaw/workspace/memory-digest.md
  7. Log summary to state

Memory digest

The digest is a compressed representation of the knowledge graph optimized for LLM consumption. Instead of dumping every raw line, it:

  • Groups related memories by category
  • Merges duplicate facts into single entries
  • Marks contradictions with [CONFLICT] so the agent can resolve them
  • Omits stale entries below a confidence threshold
  • Respects a configurable max-token budget

Example digest output:

markdown
## Preferences
- Prefers Python for backend, TypeScript for frontend
- Dark mode everywhere; compact UI layouts
- Commit messages: imperative mood, max 72 chars

## Active Projects
- openclaw-superpowers: skill library, 40 skills, MIT license
- personal-site: Next.js 14, deployed on Vercel

## People
- Alice (teammate): works on auth, prefers Go

## Conflicts (needs resolution)
- [CONFLICT] Python version: "3.8" vs "3.12" — ask user to clarify

Procedure

Step 1 — Build the graph

bash
python3 graph.py --build

Step 2 — Review duplicates and contradictions

bash
python3 graph.py --duplicates
python3 graph.py --contradictions

Fix contradictions by editing MEMORY.md directly or asking the agent to clarify.

Step 3 — Prune stale entries

bash
python3 graph.py --prune --dry-run
python3 graph.py --prune

Step 4 — Generate and use the digest

bash
python3 graph.py --digest --max-tokens 1500

Point OpenClaw's memory injection at ~/.openclaw/workspace/memory-digest.md instead of raw MEMORY.md.

State

Graph structure, digest cache, and audit history stored in ~/.openclaw/skill-state/memory-graph-builder/state.yaml.

Fields: last_build_at, node_count, edge_count, duplicate_count, contradiction_count, stale_count, digest_tokens, build_history.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Memory Graph Builder AI skill do?

Parses OpenClaw's flat MEMORY.md into a structured knowledge graph — detects duplicates, contradictions, and stale entries, then builds a compressed memory digest optimized for system prompt injection.

Why use Memory Graph Builder on TypingMind?

Because you install it once and use it with any model. Memory Graph Builder is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Memory Graph Builder in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ArchieIndian/openclaw-superpowers/tree/main/skills/openclaw-native/memory-graph-builder. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Memory Graph Builder?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Memory Graph Builder?

As many as you like. As long as a model supports skills, you can use Memory Graph Builder with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Memory Graph Builder AI skill free?

It is published on GitHub by ArchieIndian. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇