Logo vun Memory Setup

Memory Setup

Communautéit
exiao
memory-setup

Set up a persistent memory system for any AI coding agent (Claude Code, OpenCode, Assistant Runtime, OpenClaw, etc.). Covers workspace files, memory entry format, session-end extraction, daily garbage collection, multi-tier recall, and optional vector search. Use when someone wants their agent to remember things across sessions, set up memory, or configure persistent context.

Iwwersiicht

Editeurexiao
Repositoryskills
Skill-Nummmemory-setup
Stären
40
Forks
12
Matgeliwwert Fichieren
Nëmmen Instruktiounen
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Vum exiao op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Memory Setup an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/exiao/skills/tree/main/memory/memory-setup
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/exiao/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/memory/memory-setup .claude/skills/memory-setup
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Memory Setup an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Memory Setup automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Memory Setup net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Memory Setup

Set up persistent memory for an AI coding agent so it remembers context, preferences, decisions, and lessons across sessions. This is agent-agnostic — works with Claude Code, OpenCode, Hermes Agent, OpenClaw, or any agent that can read/write files.

Core Principle

AI agents have no memory between sessions unless you write things to disk. Memory = files. This skill sets up the file structure, entry format, lifecycle hooks, and maintenance routines that make memory work end-to-end.


Architecture Overview

                    SESSION START
                    ─────────────
                    Load MEMORY.md + USER.md → system prompt (frozen snapshot)
                    Load SOUL.md / AGENTS.md / CLAUDE.md → operating instructions
                            │
                            ▼
                    DURING SESSION
                    ──────────────
                    Agent writes to MEMORY.md / USER.md via tool or direct edit
                    Full transcript saved to session store (SQLite, JSONL, etc.)
                            │
                            ▼
                    SESSION END
                    ───────────
                    Extract durable facts from transcript → MEMORY.md / USER.md
                    Write episode summary → episodes/YYYY-MM-DD.md
                            │
                            ▼
                    DAILY MAINTENANCE (memory-gc)
                    ────────────────────────────
                    Decay stale entries │ Drain pending overflow
                    Promote durable facts from episodes │ Prune old files

Step 1: Create the Workspace

Pick a home directory for your agent's memory. Common conventions:

AgentDefault Location
Claude Code~/.claude/ or project .claude/
OpenCode~/.opencode/
Hermes Agent~/.hermes/
OpenClaw~/.openclaw/workspace/
Generic~/.agent/
bash
WORKSPACE="$HOME/.agent"  # adjust for your agent
mkdir -p "$WORKSPACE/memories"
mkdir -p "$WORKSPACE/episodes"
mkdir -p "$WORKSPACE/plans"
mkdir -p "$WORKSPACE/plans/archive"
mkdir -p "$WORKSPACE/sessions"

Step 2: Create Core Memory Files

MEMORY.md — Long-term curated memory

The primary memory file. Loaded into system prompt at session start. Contains durable facts, preferences, project context, and lessons learned.

markdown
# MEMORY.md

> Durable facts and context. Loaded every session.
> Entry format: [YYYY-MM-DD][category] content
> Categories: fact, pref, env, proj:<path>, rel:<name>, task, tmp, rule, meta

§

Entry format: [YYYY-MM-DD][cat] content

CategoryPurposeDecay
factDurable facts60 days
prefUser preferences60 days
envEnvironment/infra30 days
proj:<path>Project-specific context30 days
rel:<name>Info about a personNever
taskActive tasks/goals14 days
tmpEphemeral notes7 days
ruleHard behavioral constraintsNever
metaSystem configurationNever

Rules:

  • Date = creation date only, never updated
  • § separator between entries
  • [rule] entries are hard constraints the agent must follow
  • Keep under ~100 entries — use memory-gc to prune

USER.md — User profile

Loaded every session alongside MEMORY.md. Contains stable info about the user.

markdown
# USER.md

- **Name:** (your name)
- **Timezone:** (e.g. America/New_York)
- **Communication style:** (how you like to be talked to)
- **Key preferences:** (tools, languages, frameworks you prefer)

SOUL.md — Agent persona (optional)

Sets tone, personality, and boundaries. Some agents load this automatically; others need it referenced in CLAUDE.md or AGENTS.md.

markdown
# SOUL.md

## Vibe
Direct, concise, casual. No corporate speak.

## Boundaries
- Private things stay private
- Ask before acting externally (emails, posts, deploys)

## Continuity
These files are your memory. Read them. Update them.

AGENTS.md / CLAUDE.md — Operating instructions

Tell the agent HOW to use memory. Add a memory section to your existing context file:

markdown
## Memory

- **Capture is automatic.** Session-end hooks extract durable memories.
  For urgent items, write inline: `[YYYY-MM-DD][cat] content`
- **Entry format:** `[YYYY-MM-DD][cat] content`
  Categories: fact, pref, env, proj:<path>, rel:<name>, task, tmp, rule, meta
- **[rule] entries** are hard behavioral constraints for the session.
- **Past-session queries** → use recall skill (hot → episodes → sessions).
  Never fabricate history.
- **Never fabricate a creation date.** If unsure, use today's.

Step 3: Session-End Memory Extraction

At the end of each session, extract durable facts from the conversation and write them to memory files. This can be done via:

Option A: Agent hook/plugin (recommended)

If your agent supports session-end hooks, configure one that:

  1. Pulls the last 30-40 turns from the session transcript
  2. Sends them to a fast model (e.g. Haiku, GPT-4o-mini) with an extraction prompt
  3. Writes extracted entries to MEMORY.md / USER.md
  4. Writes an episode summary to episodes/YYYY-MM-DD.md

Extraction prompt template:

Review this conversation. Extract durable memories worth keeping.

Return JSON:
{
  "entries": [
    {"cat": "fact|pref|env|task|tmp|rule", "target": "MEMORY|USER", "content": "..."}
  ],
  "episode": {
    "summary": "One paragraph summary of the session",
    "tags": ["tag1", "tag2"]
  }
}

Rules:
- Only extract what's worth remembering across sessions
- Skip small talk, debugging noise, routine commands
- Prefer specific facts over vague summaries
- Use the correct category for each entry
- If nothing worth saving, return empty arrays

Option B: Manual prompt at end of session

If hooks aren't available, end sessions with:

"Before we end, write any important decisions, preferences, or facts from this session to MEMORY.md using the [YYYY-MM-DD][cat] content format."

Option C: CLAUDE.md instruction

Add to your CLAUDE.md:

markdown
## Session End
Before ending any session, review the conversation for durable facts, decisions,
or corrections. Write them to MEMORY.md in `[YYYY-MM-DD][cat] content` format.
Write a 1-paragraph episode summary to episodes/YYYY-MM-DD.md.

Step 4: Episode Summaries

Episodes are daily session summaries that form the middle tier of recall. Each day gets one file with all sessions appended:

File: episodes/YYYY-MM-DD.md

markdown
## Episode — 2:30 PM

**Summary:** Set up CI pipeline for the new API. Decided on GitHub Actions over CircleCI. Fixed a flaky test in the auth module.

**Tags:** devops, ci, testing, auth

---

## Episode — 7:15 PM

**Summary:** Reviewed PR #42, discussed pricing strategy for the Pro tier. User prefers value-based pricing over cost-plus.

**Tags:** code-review, pricing, product

Step 5: Multi-Tier Recall

When the agent needs to remember something from the past, search in order:

TierSourceMethodSpeed
1. Hot memoryMEMORY.md + USER.mdAlready in contextInstant
2. Episodesepisodes/*.mdGrep by tag/date, then readFast
3. SessionsRaw transcriptsFull-text search (FTS5, ripgrep)Slow

Stop when confidence plateaus. Don't search deeper tiers if you already found the answer.

Always use both:

  • Semantic search (vector/embedding) for fuzzy concept matching
  • Exact search (grep/ripgrep) for specific strings, names, IDs

Step 6: Daily Garbage Collection

Run memory-gc daily (via cron, scheduled task, or manual) to keep memory files clean:

  1. Decay: Remove stale entries by category (tmp=7d, task=14d, env=30d, fact/pref=60d, rule/meta=never)
  2. Drain: Process .pending.md overflow into MEMORY.md
  3. Promote: Scan last 7 days of episodes, promote 0-3 durable facts not already in memory
  4. Prune: Delete memory files >90 days old, session files >180 days

See the memory-gc skill for the full implementation.

Step 7: Optional — Vector Search

For large memory stores, add semantic vector search:

bash
# Example: index memory files with embeddings
# Provider options: OpenAI, Gemini, Voyage, Ollama (local)

# Gemini (free tier available)
# Get key at https://aistudio.google.com/app/apikey
export GEMINI_API_KEY="your-key"

# OpenAI
export OPENAI_API_KEY="your-key"

Configure your agent's memory search to index both memories/ and sessions/ directories. The exact config depends on your agent platform.

Step 8: Overflow Handling

When MEMORY.md gets too large (>100 entries), new entries should go to .pending.md instead. The daily GC drains pending entries after decaying old ones to make room.

memories/
├── MEMORY.md          ← Hot memory (target: ~60-100 entries)
├── USER.md            ← User profile
├── .pending.md        ← Overflow queue (drained by memory-gc)
└── .gc.log            ← GC audit log

Step 9: Backup

Treat your agent's memory as irreplaceable. Back it up:

bash
cd "$WORKSPACE"
git init
echo -e ".DS_Store\n.env\n**/*.key\n**/*.pem\n**/secrets*" > .gitignore
git add memories/ episodes/ SOUL.md
git commit -m "Initial memory setup"

# Push to a PRIVATE repo
gh repo create agent-memory --private --source . --push

Consider a periodic backup (cron every 30 min or daily) that auto-commits and pushes.

File Layout Summary

$WORKSPACE/
├── SOUL.md                 ← Agent persona (optional)
├── AGENTS.md / CLAUDE.md   ← Operating instructions
├── memories/
│   ├── MEMORY.md           ← Hot memory (loaded every session)
│   ├── USER.md             ← User profile (loaded every session)
│   ├── .pending.md         ← Overflow queue
│   └── .gc.log             ← GC audit log
├── episodes/
│   └── YYYY-MM-DD.md       ← Daily session summaries
├── sessions/
│   └── *.jsonl             ← Raw transcripts (optional)
├── plans/
│   ├── <task>.md            ← Active plans
│   └── archive/             ← Completed plans
└── skills/                  ← Skill definitions

Verification

After setup, test the memory loop:

  1. Tell your agent: "Remember that my favorite color is blue."
  2. End the session (or trigger session-end extraction)
  3. Start a new session
  4. Ask: "What's my favorite color?"

The agent should find it in MEMORY.md or via recall.

Troubleshooting

ProblemFix
Agent doesn't remember anythingCheck MEMORY.md is being loaded into system prompt at session start
Memory grows unboundedSet up memory-gc cron job, check decay rules
Session-end extraction misses thingsIncrease turn count in extraction (try 40-50), check model isn't skipping
Recall returns nothingUse both grep (exact) AND semantic search (fuzzy) — one alone misses things
.pending.md keeps growingGC isn't running or MEMORY.md is at capacity — decay more aggressively

Heefeg gestallte Froen

Wat mécht de KI-Skill Memory Setup?

Set up a persistent memory system for any AI coding agent (Claude Code, OpenCode, Assistant Runtime, OpenClaw, etc.). Covers workspace files, memory entry format, session-end extraction, daily garbage collection, multi-tier recall, and optional vector search. Use when someone wants their agent to remember things across sessions, set up memory, or configure persistent context.

Firwat Memory Setup op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Memory Setup besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Memory Setup an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/exiao/skills/tree/main/memory/memory-setup an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Memory Setup benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Memory Setup benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Memory Setup domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Memory Setup gratis?

De Skill gëtt vum exiao op GitHub publizéiert. Kuckt am Repository no de Lizenzbedéngungen. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇