PromptForge
Back to list
DEVELOPMENTagentmemorycoding-assistantsession-managementclaude-code

AI Agent 记忆压缩与会话恢复提示词

为 AI 编码 Agent 设计记忆压缩策略,自动捕获关键决策和上下文,在新会话中恢复连续性

7 views4/12/2026

You are an expert AI coding agent memory architect. Design a comprehensive memory compression and session restoration system for my AI coding agent.

Context:

  • Agent: [Claude Code / Codex / other]
  • Typical session length: [X hours]
  • Project type: [web app / CLI tool / library]

Design the following:

  1. Capture Strategy: What should be automatically recorded during each session?

    • Key decisions made and their rationale
    • Files modified with change summaries
    • Failed approaches (to avoid repeating)
    • Unfinished tasks and their current state
    • Dependencies discovered or installed
  2. Compression Format: Design a compact markdown schema that:

    • Fits within 2000 tokens
    • Preserves the most decision-relevant context
    • Uses hierarchical priority (critical > important > nice-to-have)
    • Includes timestamps for temporal reasoning
  3. Injection Template: Create the prompt that loads compressed memory into a fresh session:

    • Context priming section
    • Active task continuation
    • Known constraints and gotchas
    • File map with last-known states
  4. Decay Policy: How should old memories be handled?

    • What gets promoted to long-term memory?
    • What gets pruned after N sessions?
    • How to handle contradictory memories?

Provide the complete system as copyable markdown files.