claude-code - 💡(How to fix) Fix [FEATURE] Session-pinned memory: persist specific memory file contents through context compaction

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix / Workaround

Why existing workarounds fail

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

In long sessions, critical procedures documented in memory files are forgotten after context compaction. The memory system writes files to disk and indexes them in MEMORY.md, but after compaction only the index titles survive — the agent sees the title but does not re-read the file before acting, repeating documented mistakes.

Real-world impact: a 12+ hour debugging session required a specific launch procedure documented in a memory file. After each compaction, the agent forgot this rule and used the wrong procedure, wasting 3+ hours on multiple occasions. The rule was in memory the whole time — just never re-read.

Proposed Solution

Allow users to pin memory files to the current session so their contents survive context compaction. Pinned files are re-loaded into every context window for the remainder of the session, similar to how CLAUDE.md is always loaded — but scoped to one session, not all sessions.

Example usage: /pin-memory my_procedure.md

The pinned file contents would be included in the post-compaction context window alongside the compaction summary, ensuring the agent has the procedures available without needing to proactively read the file.

Why this must be session-scoped, not global

  • CLAUDE.md (global): Always loaded in every session. Domain-specific procedures should not pollute unrelated sessions.
  • auto_load: true in frontmatter (global): Same problem — loads in every session regardless of relevance.
  • Session-pinned: Only loads in sessions where the user explicitly pins it. Different sessions can pin different files. No cross-session pollution.

Why existing workarounds fail

  • MEMORY.md index: Only titles visible after compaction. Adding "MUST READ" to the description does not reliably trigger the agent to open the file.
  • User instruction "read memory first": Also summarized away during compaction.
  • Putting all content in MEMORY.md: Not scalable — truncated after 200 lines.
  • Re-telling the agent each time: Defeats the purpose of having a memory system.

Alternative Solutions

No response

Priority

High - Significant impact on productivity

Feature Category

Configuration and settings

Use Case Example

  1. User runs /pin-memory <file> during a session
  2. The file contents are marked as session-pinned
  3. On every context compaction within that session, pinned file contents are included in the new context window
  4. Pins expire when the session ends
  5. Multiple files can be pinned per session

Additional Context

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [FEATURE] Session-pinned memory: persist specific memory file contents through context compaction