Make Claude Code compact itself: a CLAUDE.md rule plus a script that types /compact into its own tmux pane once the turn ends A developer published a workaround that lets Claude Code trigger its own /compact command, since the tool cannot invoke it internally. A rule added to CLAUDE.md has Claude run a compact-self script as its final action, and the script waits for the turn to end before typing /compact plus the context to keep into Claude's own tmux pane and pressing Enter. The approach requires tmux, and the author notes it will not type into a pane that has been scrolled back and can collide with user input if typing begins just as a turn ends. Claude Code can't run /compact on itself, so this does it from outside. A rule in CLAUDE.md has Claude run compact-self "