⌨️PreCompact Hook
Also known as PreCompact
The event just before the chat is cut down. A hook can save it first.
Think of it like
It is like you take a photo of a whiteboard. Then you wipe it.
Example
Jack wants each long chat kept in full. His hook copies the whole chat before the summary takes its place.
Why it matters
Compaction throws detail away. This is the moment to keep it.
Definition
Example code
json
{
"hooks": {
"PreCompact": [
{ "matcher": "auto", "hooks": [{ "type": "command", "command": "./backup-transcript.sh" }] }
]
}
}Common mistake
Key takeaways
- 1Before compaction. Manual or auto.
- 2Can block. Exit 2.
- 3Save first. The full chat.