summaryrefslogtreecommitdiff
path: root/plugins/caffeinate/README.md
diff options
context:
space:
mode:
authorDaisy Hollman <daisy@anthropic.com>2026-01-09 22:48:26 +0000
committerDaisy Hollman <daisy@anthropic.com>2026-01-09 22:48:26 +0000
commit95380b3cd58f7fbf575ebda0fe291224ba028317 (patch)
tree36532bcaf5fdea7785ca3fae94214bf00356d2b7 /plugins/caffeinate/README.md
parentf1be96f0fb58d5aaf2840ca7d7036d5c0923742c (diff)
Add caffeinate plugin to prevent blocking sleep commandsdaisy/caffeinate/main
This plugin intercepts sleep commands in Bash and prompts Claude to use background execution (run_in_background: true) instead. This keeps the session responsive during long-running operations. Features: - Blocks sleep commands with helpful retry message - Allows sleep in quoted strings (false positive prevention) - Catches sleep in compound commands (&&, ||, ;) and loops - Allows background commands through (run_in_background: true) :house: Remote-Dev: homespace Claude-Generated-By: Claude Code (cli/claude-opus-4-5=100%) Claude-Steers: 6 Claude-Permission-Prompts: 0 Claude-Escapes: 0
Diffstat (limited to 'plugins/caffeinate/README.md')
-rw-r--r--plugins/caffeinate/README.md58
1 files changed, 58 insertions, 0 deletions
diff --git a/plugins/caffeinate/README.md b/plugins/caffeinate/README.md
new file mode 100644
index 00000000..cd68f8b3
--- /dev/null
+++ b/plugins/caffeinate/README.md
@@ -0,0 +1,58 @@
+# Caffeinate
+
+A Claude Code plugin that blocks `sleep` commands and reminds Claude to use background tasks instead.
+
+## Purpose
+
+When Claude uses `sleep` commands in Bash, it blocks the session unnecessarily. This plugin intercepts these commands and suggests using proper async patterns like:
+
+- `run_in_background: true` parameter for long-running commands
+- Polling for conditions instead of sleeping
+- Proper async/background task patterns
+
+## Installation
+
+```bash
+# From the plugin directory
+claude --plugin-dir /path/to/caffeinate
+```
+
+Or copy to your project's `.claude-plugin/` directory.
+
+## What Gets Blocked
+
+| Command | Blocked? | Reason |
+|---------|----------|--------|
+| `sleep 5` | Yes | Direct sleep command |
+| `sleep $TIMEOUT` | Yes | Sleep with variable |
+| `echo "test" && sleep 5` | Yes | Sleep after separator, outside quotes |
+| `cmd; sleep 10` | Yes | Sleep after semicolon |
+| `echo "sleep 8 hours"` | No | Sleep is inside quotes (not a command) |
+| `echo "foo && sleep 5"` | No | Entire sleep pattern is in a string |
+
+## How It Works
+
+The plugin uses a `PreToolUse` hook on the `Bash` tool to:
+
+1. Check if commands start with `sleep`
+2. Detect `sleep` after command separators (`&&`, `||`, `;`, `|`)
+3. Use quote-counting to avoid false positives when `sleep` appears inside strings
+
+## Alternatives to Sleep
+
+Instead of:
+```bash
+sleep 5 && check_status
+```
+
+Use background execution:
+```bash
+# Run in background with run_in_background: true
+long_running_command
+```
+
+Or poll for conditions:
+```bash
+# Poll for a file to exist
+while [ ! -f /tmp/ready ]; do :; done
+```