Skip to content

Add PreCompact hook for transcript backup#93

Draft
ikuwow wants to merge 1 commit intomainfrom
add-precompact-hook
Draft

Add PreCompact hook for transcript backup#93
ikuwow wants to merge 1 commit intomainfrom
add-precompact-hook

Conversation

@ikuwow
Copy link
Owner

@ikuwow ikuwow commented Mar 9, 2026

Summary

  • Add a PreCompact hook that backs up the full transcript JSONL to ~/.claude/transcript-backups/ before compaction
  • Record the backup file path in the project's memory directory (compact-snapshot.md) so Claude can find it on demand
  • Fires on both manual (/compact) and automatic compaction

Motivation

When Claude Code compacts the conversation, detailed context (code snippets, error messages, step-by-step reasoning) is lost. This hook preserves the full transcript so it can be referenced later (e.g., during /retrospective).

Test plan

  • Run ./scripts/deploy.sh and verify symlink for pre_compact_backup.py
  • Run /compact in a Claude Code session
  • Verify backup file appears in ~/.claude/transcript-backups/
  • Verify compact-snapshot.md is created in the project's memory directory

🤖 Generated with Claude Code

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant