Skip to main content
agentsSource-backedReview first Safety Privacy

Context Compaction Recovery Agent

Community reusable agent prompt for recovering Claude Code sessions after auto-compaction or context thrashing using official context-window docs: rebuild goals from git, validate tasks, and block destructive edits after memory loss.

by kiannidev·added 2026-06-16·
HarnessClaude Code
Review first review before installing

Open the source and read safety notes before installing.

Safety notes

  • Post-compaction agents may hallucinate prior plans—require git-backed evidence.
  • Do not run destructive git or deploy commands until recovery checklist passes.
  • Compaction thrashing indicates oversized inputs; fix root cause before continuing.
  • Recovery prompts should not re-paste secrets removed during hygiene passes.

Privacy notes

  • Reconstructed summaries may repeat proprietary code snippets from diffs.
  • Issue titles and customer names in recovered todos should stay in private trackers.
  • Session exports used for recovery should not be posted publicly verbatim.

Prerequisites

  • Git status, recent commits, and branch name for the active Claude Code session.
  • Any CLAUDE.md, todo lists, or issue links referenced before compaction.
  • Awareness of whether auto-compaction removed tool outputs or plan details.
  • Human owner who can confirm recovered goals before merge or deploy actions.

Schema details

Install type
copy
Troubleshooting
No
Source repository stats
Scope
Source repo
Full copyable content
## Content

Context Compaction Recovery Agent is a community-authored reusable prompt for stabilizing
Claude Code work after auto-compaction events. It applies official context-window
documentation—not an official Anthropic support agent.

## Scope Note

This prompt operationalizes documented auto-compaction and context limit behavior from
code.claude.com. It supplements but does not replace team runbooks for long sessions.

## Agent Prompt

You are a context compaction recovery specialist for Claude Code. Assume conversational
memory may be incomplete. Re-anchor work using git, docs, and explicit human confirmation
aligned with official context-window guidance.

Workflow:

1. **Detect compaction impact.** Note autocompact messages, thrashing errors, or missing plan details described in troubleshooting guidance.
2. **Ground in git.** Read status, diff, recent commits, and branch ownership.
3. **Recover goals.** Extract intended outcomes from CLAUDE.md, issues, PR descriptions, or todos.
4. **Validate tasks.** Mark completed vs unknown steps; ask humans to confirm ambiguous items.
5. **Shrink context.** Recommend clearing oversized tool outputs and splitting work across sessions or worktrees per context hygiene practices.
6. **Safety gate.** Block merge, deploy, or mass refactor until recovery checklist is green.
7. **Resume plan.** Produce a concise forward plan with explicit next commands.

Output contract:

- Recovered goal statement with evidence links (files, commits, issues).
- Task checklist with confirmed vs uncertain items.
- Root-cause notes for thrashing (large files, MCP dumps, etc.).
- Safe continuation plan.

## Features

- Git-backed recovery instead of trusting truncated chat memory.
- Thrashing-aware guidance aligned with official context window documentation.
- Explicit safety gates before destructive post-compaction actions.
- Compatible with worktree and parallel session ownership rules.

## Use Cases

- Recover after autocompact thrashing errors mid-refactor.
- Resume a long feature branch session after overnight compaction.
- Hand off a compacted session to another developer with verified state.
- Document compaction incidents for team cost and context hygiene reviews.

## Source Notes

Verified against Claude Code context-window documentation on **2026-06-16**:

- Official docs describe context window limits, automatic compaction behavior, and how
  long sessions manage conversation history.
- Documentation and troubleshooting guides explain thrashing stop conditions when compaction
  immediately refills the window from oversized tool output.
- Memory and context hygiene practices documented alongside context-window limits inform
  recovery steps that reduce repeated compaction loops.

## Duplicate Check

Checked content/agents and content/guides for compaction recovery workflows.
context-window-optimizer-agent focuses on proactive optimization; compaction-and-memory-hygiene-for-long-claude-sessions
is a guides entry. No agents entry provides post-compaction git-backed recovery with safety gating.

## Editorial Disclosure

Submitted as an independent community agent entry by kiannidev, based on public Claude
Code context-window documentation and the public anthropics/claude-code repository.
No paid placement, referral, or affiliate relationship.

## Sources

- Claude Code context window - https://code.claude.com/docs/en/context-window
- Claude Code memory - https://code.claude.com/docs/en/memory
- Claude Code repository - https://github.com/anthropics/claude-code

About this resource

Content

Context Compaction Recovery Agent is a community-authored reusable prompt for stabilizing Claude Code work after auto-compaction events. It applies official context-window documentation—not an official Anthropic support agent.

Scope Note

This prompt operationalizes documented auto-compaction and context limit behavior from code.claude.com. It supplements but does not replace team runbooks for long sessions.

Agent Prompt

You are a context compaction recovery specialist for Claude Code. Assume conversational memory may be incomplete. Re-anchor work using git, docs, and explicit human confirmation aligned with official context-window guidance.

Workflow:

  1. Detect compaction impact. Note autocompact messages, thrashing errors, or missing plan details described in troubleshooting guidance.
  2. Ground in git. Read status, diff, recent commits, and branch ownership.
  3. Recover goals. Extract intended outcomes from CLAUDE.md, issues, PR descriptions, or todos.
  4. Validate tasks. Mark completed vs unknown steps; ask humans to confirm ambiguous items.
  5. Shrink context. Recommend clearing oversized tool outputs and splitting work across sessions or worktrees per context hygiene practices.
  6. Safety gate. Block merge, deploy, or mass refactor until recovery checklist is green.
  7. Resume plan. Produce a concise forward plan with explicit next commands.

Output contract:

  • Recovered goal statement with evidence links (files, commits, issues).
  • Task checklist with confirmed vs uncertain items.
  • Root-cause notes for thrashing (large files, MCP dumps, etc.).
  • Safe continuation plan.

Features

  • Git-backed recovery instead of trusting truncated chat memory.
  • Thrashing-aware guidance aligned with official context window documentation.
  • Explicit safety gates before destructive post-compaction actions.
  • Compatible with worktree and parallel session ownership rules.

Use Cases

  • Recover after autocompact thrashing errors mid-refactor.
  • Resume a long feature branch session after overnight compaction.
  • Hand off a compacted session to another developer with verified state.
  • Document compaction incidents for team cost and context hygiene reviews.

Source Notes

Verified against Claude Code context-window documentation on 2026-06-16:

  • Official docs describe context window limits, automatic compaction behavior, and how long sessions manage conversation history.
  • Documentation and troubleshooting guides explain thrashing stop conditions when compaction immediately refills the window from oversized tool output.
  • Memory and context hygiene practices documented alongside context-window limits inform recovery steps that reduce repeated compaction loops.

Duplicate Check

Checked content/agents and content/guides for compaction recovery workflows. context-window-optimizer-agent focuses on proactive optimization; compaction-and-memory-hygiene-for-long-claude-sessions is a guides entry. No agents entry provides post-compaction git-backed recovery with safety gating.

Editorial Disclosure

Submitted as an independent community agent entry by kiannidev, based on public Claude Code context-window documentation and the public anthropics/claude-code repository. No paid placement, referral, or affiliate relationship.

Sources

Source citations

Add this badge to your README

Show that Context Compaction Recovery Agent is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/agents/context-compaction-recovery-agent.svg)](https://heyclau.de/entry/agents/context-compaction-recovery-agent)

How it compares

Context Compaction Recovery Agent side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

FieldContext Compaction Recovery Agent

Community reusable agent prompt for recovering Claude Code sessions after auto-compaction or context thrashing using official context-window docs: rebuild goals from git, validate tasks, and block destructive edits after memory loss.

Open dossier
Claude Code Context Window Audit Capability Pack Skill

Expert Claude Code context window audit capability pack for measuring what loads at session start, what each read and extension adds, when compaction drops path-scoped rules, and how to delegate or compact before quality drops.

Open dossier
Claude Code Desktop Operations Agent

Community reusable agent prompt for operating Claude Code Desktop using official desktop docs: parallel sessions, agent view, notifications, background jobs, and desktop-specific troubleshooting workflows.

Open dossier
Zero Data Retention Compliance Agent

Community reusable agent prompt for mapping Claude Code deployments to zero data retention requirements using official ZDR docs: logging boundaries, MCP data flows, session storage, and compliance evidence checklists for security review.

Open dossier
Trust
Install riskReview firstReview firstReview firstReview first
Notes Safety Privacy Safety Privacy Safety Privacy Safety Privacy
Categoryagentsskillsagentsagents
Sourcesource-backedsource-backedsource-backedsource-backed
Authorkiannidevkiannidevkiannidevkiannidev
Added2026-06-162026-06-132026-06-162026-06-16
Platforms
Claude Code
Claude CodeCodexWindsurfGeminiCursorCLI
Claude Code
Claude Code
Source repo
Safety notesPost-compaction agents may hallucinate prior plans—require git-backed evidence. Do not run destructive git or deploy commands until recovery checklist passes. Compaction thrashing indicates oversized inputs; fix root cause before continuing. Recovery prompts should not re-paste secrets removed during hygiene passes.This skill recommends context-management actions; it must not run `/compact`, `/clear`, or delete local memory files without explicit user approval. `/compact` and automatic compaction summarize conversation history and can drop path-scoped rules until matching files are read again. Moving always-on instructions from path-scoped rules into project-root `CLAUDE.md` changes what survives compaction; show the proposed diff first. Subagent delegation isolates large reads but still consumes tokens in the subagent window; do not spawn many parallel subagents without a cost plan. Prompt-cache invalidation from model switches, large CLAUDE.md edits, or mid-session settings changes can cause expensive uncached turns.Parallel desktop sessions on the same branch can race—use worktrees or separate branches. Background jobs inherit directory and permission context from where they were started. Do not approve destructive tool calls in a session you did not start intentionally.ZDR compliance is organizational; this agent produces checklists, not legal determinations. Third-party MCP servers may retain data outside Anthropic ZDR scope—flag each connector. Session storage plugins and custom loggers can violate ZDR if misconfigured. Do not mark compliant until human security review signs off with evidence.
Privacy notesReconstructed summaries may repeat proprietary code snippets from diffs. Issue titles and customer names in recovered todos should stay in private trackers. Session exports used for recovery should not be posted publicly verbatim.`/context` breakdowns, `/memory` listings, and session transcripts can expose repository paths, branch names, MCP server names, hook commands, and internal project structure. Compaction summaries may retain task details, credentials mentioned in chat, customer names, or incident context unless redacted before sharing. Auto memory and nested `CLAUDE.md` files may contain team-specific conventions, URLs, or identifiers that should not be pasted into public issues. Public PR or support notes should summarize pressure categories and recommended actions, not full `/context` output or complete transcript dumps.Desktop session titles and diffs may expose proprietary code during screen sharing. Notification previews may leak branch or ticket names—configure OS privacy settings accordingly. Background transcripts follow normal Claude Code data handling for your account type.Compliance packets may summarize data categories but should not attach raw customer prompts. MCP vendor DPAs and subprocessors must be cited for regulated workloads. Evidence repositories need access controls separate from general engineering drives.
Prerequisites
  • Git status, recent commits, and branch name for the active Claude Code session.
  • Any CLAUDE.md, todo lists, or issue links referenced before compaction.
  • Awareness of whether auto-compaction removed tool outputs or plan details.
  • Human owner who can confirm recovered goals before merge or deploy actions.
  • An active or recently compacted Claude Code session where context pressure, cost, or recall quality is a concern.
  • Permission to run `/context`, `/memory`, and optionally `/compact` or `/clear` in the affected session.
  • Redacted access to project and user `CLAUDE.md`, `.claude/rules/`, skill descriptions, MCP server list, and hook configuration when relevant.
  • A concrete symptom such as repeated compaction, rising token cost, missed conventions, or degraded tool selection.
  • Claude Code Desktop installed per the desktop quickstart for your platform.
  • Multiple concurrent desktop sessions or background jobs requiring coordination.
  • Team agreement on branch ownership and review before merging desktop-generated changes.
  • Optional agent view access for monitoring background sessions.
  • Contractual ZDR or equivalent requirements from legal or security stakeholders.
  • Deployment architecture for Claude Code, Agent SDK hosts, logging, and MCP connectors.
  • Current observability configuration including content logging flags.
  • Inventory of MCP servers and what data each tool transmits externally.
Install
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.