Skip to main content

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:

  1. You type -> direction = "input"
  2. Command starts producing output (past the echo window) -> the command is busy -> snake starts after start_grace of sustained output
  3. Command keeps producing output (status updates, streaming tokens, tool output) -> snake keeps running
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

idlesnake-0.0.1.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

idlesnake-0.0.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

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

Hashes for idlesnake-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b0ea4db4987bf86465712f703002ef84386ee44266d4c7d039658beb6b946156
MD5 2bdfe5c210ab15801994ca353ef982f7
BLAKE2b-256 567a6941a1d07366763875382061538b2d3f5e1886344928b809c1a66fc9355d

See more details on using hashes here.

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

Hashes for idlesnake-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 725831028f9ed0a4fc765468af03e5e2c47d6c10281519ad526a5bed205f77f8
MD5 24b0705435e8ab8ca3140d8796c18fff
BLAKE2b-256 241d31ead7ddd86fb7033c0dcabeeb2a5c7d4e9f828c7e74f128c1cbac2879e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page