# Can you force Claude to write a handoff .md file before a chat gets compacted? — retained record

> Retained reddit record from reddit:ClaudeAI.

Canonical: https://highsignal.app/data/records/e3c892625c43edfa

[← sources](https://highsignal.app/data)


source: [reddit](https://highsignal.app/data/reddit) (reddit:ClaudeAI)  published 2026-09-30 21:55 ingested 2026-10-01 02:38

[original source ↗](https://www.reddit.com/r/ClaudeAI/comments/1wui0hj/can_you_force_claude_to_write_a_handoff_md_file/)

## retained text



```
>**Edit:** Thanks for all the replies! Quick clarification: I'm not a developer and I don't use Claude Code or the terminal. I just use the regular Claude app on my Mac, the normal chat window. So things like hooks and git worktrees are a bit over my head 😄 

Long chats with Claude eventually get compacted, and every time it happens I lose detail: decisions we made, file names, where we left off.  
  
 first idea was to have Claude write a handoff .md file right before compaction. The problem is the agent can't reliably tell when compaction is about to happen, so a handoff written "just in time" is often late or slightly out of date.

My

So here's my workaround: don't wait for compaction at all. Tell the agent to update the handoff file after every single response. Whenever compaction hits, the latest state is already saved.

This is the instruction I'm testing:

>After every response, create or update a file called HANDOFF.md in the working folder. Keep it short and current. Include: the goal of this chat, decisions made so far, files created or changed, open questions, and the exact next step. Overwrite outdated information instead of appending a full transcript. If the chat is compacted or I start a new chat, read HANDOFF.md first before doing anything else.

Questions for the community:

1. Has anyone set this up, and does the agent actually stick to it over a long session?
2. Is there a cleaner way to trigger a save right before compaction?
3. Does updating a file every turn slow things down or burn through usage noticeably?

Would love to hear what's working for you.

Note: I have it overwrite instead of append, since a file that logs every turn grows large and becomes its own context problem. I know Claude Code has a PreCompact hook, but I'm looking for something that also works in regular chats.
```



document fetched 2026-10-01 00:24 · canonical https://reddit.com/r/ClaudeAI/comments/1wui0hj/can_you_force_claude_to_write_a_handoff_md_file
