By kodareef5
Automatic plan file backup and recovery after context compacting. Never lose a plan to compaction again.
npx claudepluginhub kodareef5/plan-guardAutomatic plan file backup and recovery for Claude Code.
Never lose a plan to context compaction again.
Claude Code's plan mode writes plans to ~/.claude/plans/*.md. After context compacting, writes to these files frequently fail with "Error writing file" — wasting tokens and losing your work.
Known issues:
plan-guard uses three hooks to protect your plan files:
| Hook | Event | What it does |
|---|---|---|
| Backup | PreCompact | Backs up active plan files before compaction happens |
| Re-inject | SessionStart (compact) | Feeds plan content back to Claude after compaction |
| Recovery | PostToolUseFailure | Catches write failures, creates a recovery file, and tells Claude to use it |
/plugin marketplace add kodareef5/plan-guard
/plugin install plan-guard
claude --plugin-dir ./plan-guard
Once installed, plan-guard runs automatically. No configuration needed.
~/.claude/plans/.backups/ (last 20 kept)-recovered-<timestamp> suffix/plan-guard:plan-status to see your backup inventoryBefore every compaction (auto or manual), all plan files modified in the last 30 minutes are copied to .backups/.
After compaction, the most recent plan file's content (first 150 lines) is fed back to Claude as context, so it remembers the plan file path and contents.
When a Write or Edit to a plan file fails:
jq (pre-installed on macOS, apt install jq on Linux)MIT
Qiushi Skill: methodology skills for AI agents guided by seeking truth from facts, with Claude Code, Cursor, OpenClaw, Codex, OpenCode, and Hermes guidance.
Modifies files
Hook triggers on file write and edit operations
No model invocation
Executes directly as bash, bypassing the AI model