Agent Durable Memory and Correction Loop
Add a persistent memory file and a self-correction log so a Claude agent stops re-forgetting your rules every week.
Before & after
Same prompt, same agent — the only difference is the skill.
That's a common issue with long-running agents. Every time the context window gets compressed to stay within limits, important context gets lost, including the instructions and rules you've carefully set up. I could suggest a few approaches to help with this, like more frequent context resets or writing rules in a more explicit format. There are different strategies depending on how your agent is deployed and how often it runs. What's your typical usage pattern?
DURABLE MEMORY SYSTEM INSTALLED TWO-PART SOLUTION Part 1: PERSISTENT MEMORY FILE (memory.md) Location: /agent/memory.md Stored in project repo (survives context compression) Memory Categories: • VOICE: "Write like a product manager. No jargon. Short paragraphs." • WORKFLOW: "Always ask before executing destructive commands." • CONTACTS: "Follow up with customer_A@example.com every Monday." • DECISIONS: "Never recommend service_X. We deprecated it 2024-Q2." Updates automatically when you teach rules via corrections.md Part 2: CORRECTION LOG (corrections.md) Purpose: Every rule change gets timestamped and appended Example entry: "2026-01-15: Added rule – Never use em-dashes in customer emails (feedback from Jane)" Agent retrieval: On every new conversation, agent loads top-20 rules from memory.md IMPLEMENTATION CONFIG Extraction hook: Fires when session tokens > 80,000 Action: Agent summarizes recent decisions → append to corrections.md Retrieval prompt: Loads memory.md + top-5 recent corrections at session start Redaction: Scrubs names/emails before compression (your choice) TRACKING + AUDIT Weekly rule-drift report: Shows which rules agent followed vs ignored Missing rule detection: Catches contradictions between memory.md and recent corrections DELIVERABLE ✓ memory.md template (ready to customize) ✓ corrections.md template with sample entries ✓ Pre-compression extraction prompt (paste into agent config) ✓ Retrieval prompt for agent's session start ✓ Audit checklist (monthly review) EXPECTED OUTCOME Agent stops forgetting rules after context compression Instead of day-7 memory loss, rules persist indefinitely You add rules incrementally via corrections.log Weekly drift reports show exactly what's working/failing
About this skill
name: agent-durable-memory-loop description: Add a persistent memory file and a self-correction log so a Claude agent stops re-forgetting your rules every week. Use when working on agent durable memory and correction loop.
Agent Durable Memory and Correction Loop
Autonomous agents summarize old messages to keep the context window small, which almost always deletes the exact rules you spent hours teaching them. This skill installs two patterns: a persistent memory file that captures decisions before compression, and a correction log that appends every rule change so behavior improves over time. Use once per long-running agent to stop the day-7 memory-loss failure.
What you get
- memory.md template
- Pre-compression extraction prompt
- corrections.md log template
- Retrieval prompt the agent runs at conversation start
- Audit checklist
- Weekly rule-drift report
Customize your output
- Categories to track: voice, brand, workflows, contacts
- Memory file location: dir
- Retrieval trigger phrase: default, custom
- Compression threshold (tokens): 50k, 80k, 120k
- Redaction rules: names, emails, none
- Backup cadence: daily, weekly
Example output
'Installed memory.md and corrections.md. Extraction hook fires when session tokens > 80k. Retrieval loads top-20 rules on new session. First correction logged: never use em dashes in customer emails.'
Best for
Anyone running a persistent agent (Claude Code, OpenClaude, custom SDK loop) that keeps forgetting preferences.
Note: Distinct from cross-session-project-memory in that this is for standalone autonomous agents, not Claude Code project state. High confidence.
SKILL.md preview
---
name: agent-durable-memory-loop
description: Use this skill once per long-running agent to install a persistent memory file and a self-correction log so it stops forgetting user-taught rules after context compresses.
version: 1.0.0
category: AI Systems
author: AgentVolt
license: proprietary
tags:
- ai-systems
- p4
---
# Agent Durable Memory and Correction Loop
Installs two patterns for a long-running agent — a persistent memory file and an append-only correction log — so rules survive context compression instead of being summarized away.
## When to use
… (sign up to view the full skill)