CommunityWriting & Editinggithub.com

dancepower22/pi-memory-evo

pi-native persistent memory & self-evolving skill: zero-dependency, always-active, 3-layer memory (fact/pattern/lesson) + lesson routing.

What is pi-memory-evo?

This skill provides a fully autonomous, zero-dependency persistent memory and self-evolving system for AI agents such as Claude Code. It maintains a three-layer memory architecture: facts (user preferences, decisions), patterns (recurring behaviors detected 2+ times), and lessons (learned experiences, debugging conclusions). The skill is always active: it automatically saves relevant information as soon as it is encountered, without waiting for user prompts. It also performs session summarization and lesson routing: when a lesson describes a reusable methodology, the skill can create or update a separate agent skill file in ~/.agents/skills/ to make that knowledge automatically available in future sessions. This enables the AI agent to continuously improve its understanding and behavior over time, adapting to the user's workflow and environment. The skill stores all data as JSON in ~/.agents/memory/ and provides CLI tools for adding, searching, updating, and syncing memories. It respects user privacy by never saving sensitive credentials and honoring explicit forget commands.

Works with~Claude Code~Codex CLI~Cursor
npx skills add dancepower22/pi-memory-evo

Installed? Explore more Writing & Editing skills: steipete/notion, langchain-ai/langchain, bytedance/podcast-generation · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Persistent Memory & Self-Evolution (memory)

Core Principle: Save proactively, don't wait for the user to ask. Turn the user's environment into a system that "understands you better the more you use it": Three-layer granular memory (fact/pattern/lesson) + session summaries + lesson routing (self-evolution).

🚀 Session Start (each new session)

  1. If ~/.agents/memory/MEMORY.md exists, read it first to quickly understand the user's background, preferences, and recent sessions.
  2. When details are needed, use memory.py get <id> or memory.py search <keyword> to dive deeper.
  3. Show the user the key remembered information (briefly) to demonstrate continuity.

📌 Active Saving (ALWAYS ACTIVE, save on encounter, don't wait for session end)

When any of the following situations occur, immediately call memory.py add <type> <content> to save:

TypeWhen to SaveExample
factUser reveals a preference/habit/identity info; important project decisions, tech choices, conventions; user explicitly says "remember""User prefers Chinese replies" "Project uses pnpm + TypeScript"
patternSame behavior/issue appears 2+ times (including this time)"Every time a skill is installed, the user asks to evaluate dependencies first"
lessonExperience learned from a pitfall, troubleshooting conclusion, discovered gotcha"DuckDuckGo's ddgs default backend goes through Yandex and times out; must use backend='html'"
  • Saving can include --tag a,b for easier retrieval.
  • The tool automatically performs approximate deduplication; duplicate content will prompt rather than store again.

🗂️ Session End (or user asks "summarize session / solidify")

Execute in order:

  1. Review this session and extract 2-5 most important pieces of information.
  2. Classify and save: fact (new preferences/decisions) → pattern (new regularities) → lesson (new experiences).
  3. Lesson Routing (Self-Evolution): For each lesson, determine:
    • If it is a reusable methodology (e.g., standard workflow for a certain task) → create or update a skill in ~/.agents/skills/ (using write/edit tools) so it takes effect automatically next session;
    • If it is a one-time fact → save as fact;
    • If it is environment/account specific (e.g., configuration needed for a tool) → save as lesson only.
  4. Use memory.py session-save "<one-sentence summary of this session>" --key keyword1,keyword2 to save the session record.
  5. Run memory.py sync to refresh the MEMORY.md overview.

🔍 Querying Memory

When the user asks "I said before / last time / my preferences" etc. → memory.py search <keyword>; list all → memory.py list.

⚙️ Quick Tool Reference

P=~/.agents/skills/pi-memory-evo/memory.py
$P init                       # First-time initialization
$P add fact "content" --tag preference    # Save fact/pattern/lesson
$P session-save "summary" --key a  # Save session summary
$P search keyword                # Search
$P list                          # List all
$P get <id> / update <id> <new content> / delete <id>   # Management
$P stats                         # Statistics
$P sync                          # Refresh overview MEMORY.md

📂 Storage Locations

  • Data: ~/.agents/memory/memory.json (four-layer memory, JSON)
  • Overview: ~/.agents/memory/MEMORY.md (read at session start)
  • Skill itself: ~/.agents/skills/pi-memory-evo/ (tool + this documentation)

⚠️ Boundaries

  • Do not store sensitive credentials: tokens, passwords, keys are never saved.
  • Respect user wishes: if the user says "don't record this", it is not saved; if the user says "forget X", call delete on the corresponding entry.
  • Memory is an aid, not a replacement for confirmation: for important operations, the user's current intent still takes precedence.

Related Skills