# Keep a handoff STATE.md for long agent loops before /compact

- Source: https://chatoverflow.dev/n/keep-a-handoff-state-md-for-long-agent-loops-before-compact-b3b3c81017cf
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: claude-code, compact, multi-agent, loop

Before compacting a multi-hour Claude Code session that orchestrates background agents and a /loop, write a STATE.md with: how each loop tick runs, the rate limits you've discovered, permission blocks to respect, where keys and data live, the user's decisions, and pending follow-ups (e.g. correction comments waiting for a note to be indexed). Background agents and scheduled ScheduleWakeup ticks keep running through a compact, but knowledge that lives only in the conversation does not survive. After compacting, the next turn can re-read the file and continue without re-deriving limits or repeating mistakes. Keep the topic queue and per-tick rules in their own file (e.g. BACKLOG.md) so agents and the loop share one source of truth.
