Play snake while your CLI thinks
Project description
idlesnake
Play snake while your CLI thinks.
idlesnake wraps any command-line tool in a PTY and automatically overlays a snake game when it detects idle time. When the tool starts producing output again, the game instantly stops and shows you the output.
Install
pip install idlesnake
Usage
idlesnake claude # play snake while Claude thinks
idlesnake ssh prod-server # play while connecting
idlesnake npm install # play during dependency resolution
Controls
- Arrow keys or WASD to move the snake
- q to quit the game early (returns to terminal)
- Game starts automatically while the wrapped command is producing output after your input
- Game stops when the command goes quiet (response complete)
Options
idlesnake [OPTIONS] COMMAND [ARGS...]
Options:
--quiet-threshold SECONDS Silence that ends a response (default: 3.0)
--start-grace SECONDS Sustained output before snake starts (default: 0.3)
--watchdog-grace SECONDS Wait for Claude hooks before fallback (default: 10.0)
--echo-window SECONDS Echo filter window (default: 0.2)
--no-hooks Skip hook injection for Claude
--debug Write log to /tmp/idlesnake_debug.log
--version Show version
-h, --help Show help
--idle-threshold is kept as a deprecated alias for --quiet-threshold.
How It Works
idlesnake sits between your terminal and the wrapped command using a PTY (pseudoterminal). It uses activity-tracking to decide when the snake is welcome:
- You type -> direction = "input"
- Command starts producing output (past the echo window) -> the command is busy -> snake starts after
start_graceof sustained output - Command keeps producing output (status updates, streaming tokens, tool output) -> snake keeps running
- Command goes quiet for
quiet_threshold-> response is complete -> snake stops, output is revealed
This means the snake runs throughout the busy part of a response — including streaming output — and steps aside cleanly when the command is done.
Claude Code behavior
When the wrapped command is claude (or claude-code), idlesnake first tries signal mode: it writes hook scripts to ~/.local/share/idlesnake/hooks/, generates a temp settings file, and passes it to Claude via --settings. The hooks signal the wrapper on UserPromptSubmit (start snake) and Stop (stop snake), giving precise transitions.
Signal mode is best-effort. Some Claude installs (notably Enterprise-managed) may not invoke hooks declared via --settings. If no hook signal arrives within watchdog_grace seconds of the first child output, idlesnake prints a one-line stderr warning and falls back to activity-tracking for the rest of the session. Pass --no-hooks to skip signal mode entirely.
Troubleshooting: if the snake never appears while Claude is thinking, run idlesnake --debug claude ... and inspect /tmp/idlesnake_debug.log — it records mode selection, signal arrival, and each snake transition with reasons.
Features
- Zero config — no hooks, no settings files, just a prefix command
- Works with any CLI tool
- Pure Python, no dependencies (uses stdlib: curses, pty, select)
- High scores persist across sessions
- Terminal state always restored cleanly on exit
Platform
Unix and macOS only. Requires pty, termios, and curses which are not available on Windows.
Also runs as a module
python -m idlesnake claude
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file idlesnake-0.0.1.tar.gz.
File metadata
- Download URL: idlesnake-0.0.1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0ea4db4987bf86465712f703002ef84386ee44266d4c7d039658beb6b946156
|
|
| MD5 |
2bdfe5c210ab15801994ca353ef982f7
|
|
| BLAKE2b-256 |
567a6941a1d07366763875382061538b2d3f5e1886344928b809c1a66fc9355d
|
File details
Details for the file idlesnake-0.0.1-py3-none-any.whl.
File metadata
- Download URL: idlesnake-0.0.1-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
725831028f9ed0a4fc765468af03e5e2c47d6c10281519ad526a5bed205f77f8
|
|
| MD5 |
24b0705435e8ab8ca3140d8796c18fff
|
|
| BLAKE2b-256 |
241d31ead7ddd86fb7033c0dcabeeb2a5c7d4e9f828c7e74f128c1cbac2879e4
|