Agent Rule Memory and Correction Log
Make a long-running agent keep the rules you teach it: capture corrections instantly, reload past compaction, and test each rule.
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
Your agent stops forgetting the rules you taught it after its context gets summarized. Corrections are captured the moment you give them and reloaded where compaction cannot reach.
What it does
- Diagnoses where a rule is being lost: chat-only storage, load timing, burial, conflicts, or vague wording
- Installs a short rules file with ids and scopes plus an append-only correction log
- Loads rules through the always-sent instruction slot for Claude Code, the Agent SDK, or a raw API loop
- Guards against memory poisoning and adds a regression test per high-impact rule
What you get
A memory setup: diagnosis, file locations, capture and load mechanics, seeded rules, regression tests, and a consolidation cadence.
Best for
Anyone running a persistent assistant or autonomous agent that keeps repeating mistakes it was already corrected on.
SKILL.md preview
---
name: agent-durable-memory-loop
… (sign up to view the full skill)More ai & agents skills
View all AI & Agents skills →New Skill Scaffolder
Create a new Claude Code skill correctly: right mechanism, valid name and folder, a triggering description, and a smoke test.
Skill Library Lint and Overlap Report
Lint every skill in a repo at once: frontmatter, name-folder match, weak descriptions, overlapping triggers, broken refs, plus a CI script.
Self-Verifying Agent Loop: Plan, Check, Retry, Close
Turns a goal into a task plan with machine-run checks, executes with retry caps, escalates, and refuses to close until verified.
Skill Test Runner (Trigger and A/B)
Test a skill in fresh sessions: ready-to-run prompts, commands, and rubric for trigger recall, false triggers, and blind A/B.