← Reddit

I made a Tetris game that runs entirely in the shell, while Claude Code compacts your session - so you don’t get bored

Reddit · dragosroua · June 12, 2026
A Tetris game that runs entirely within the shell has been created to provide entertainment while Claude Code performs session compaction tasks. The implementation relies on the Python 3 standard library using only the curses module, requiring zero external dependencies. The PreCompact hook can be configured globally or per project and set to trigger at random intervals.

Detailed Analysis

A developer has built a terminal-based Tetris game designed to activate automatically during Claude Code's context compaction process, turning what would otherwise be idle waiting time into an opportunity for gameplay. The project, hosted on GitHub under the repository "compaction-tetris," leverages Claude Code's PreCompact hook system — a mechanism that allows custom scripts or actions to fire before a session compaction event occurs. The implementation is deliberately lightweight, relying exclusively on Python 3's standard library and the `curses` module, meaning users can install and run it with zero external dependencies. The hook can be configured either globally across all Claude Code projects or on a per-project basis, and an additional option allows it to trigger at random intervals independent of compaction events.

Context compaction is a necessary operational feature in long-running Claude Code sessions, where the accumulated conversation history and context window must be periodically summarized or truncated to stay within model token limits. This process introduces a brief but noticeable pause in the developer workflow — a moment where the user is waiting for the system to complete an internal maintenance task before continuing. The Tetris game addresses this dead time directly by injecting entertainment into what would otherwise be a passive interruption, effectively reframing a system limitation as a feature opportunity.

The project reflects a broader pattern of developer creativity around the tooling ecosystems that have emerged alongside AI coding assistants. Claude Code, Anthropic's terminal-based agentic coding tool, exposes a hooks architecture that allows developers to customize and extend its behavior at key lifecycle moments. The PreCompact hook is one such extension point, and this Tetris implementation demonstrates how that API surface can be used for purposes well beyond its original intent — in this case, user experience enhancement through humor and utility.

This kind of community-driven tooling extension is characteristic of how rapidly AI developer tools are being adopted and remixed. As agentic AI coding environments like Claude Code, GitHub Copilot Workspace, and similar platforms mature, their ecosystems increasingly resemble those of traditional development environments, complete with plugins, themes, and community-built utilities. The compaction-tetris project, while whimsical, signals that developers are investing enough in these tools to build ancillary experiences around them — a meaningful indicator of platform stickiness and community engagement.

The project also subtly highlights a real ergonomic tension in working with large language model-based tools: the inherent latency and interruption introduced by context management operations. As AI sessions grow longer and more complex, compaction becomes more frequent, and the cumulative idle time can meaningfully disrupt flow states. Creative solutions like this one point toward an open design question for AI toolmakers — whether such interruptions should be minimized, masked, or, as this project proposes, productively reoccupied.

Read original article →