Queue Claude Code prompts and execute them when token limits reset.
Project description
Claude Code Queue
A tool to queue Claude Code prompts and automatically execute them when token limits reset, preventing manual waiting during 5-hour limit windows.
Features
- Markdown-based Queue: Each prompt is a
.mdfile with YAML frontmatter - Automatic Rate Limit Handling: Detects rate limits and waits for reset windows
- Priority System: Execute high-priority prompts first
- Retry Logic: Automatically retry failed prompts
- Persistent Storage: Queue survives system restarts
- Prompt Bank: Save and reuse templates for recurring tasks
- Interactive Prompt Box: Browse and select files interactively with fuzzy search
- CLI Interface: Simple command-line interface
Installation
pip install claude-code-queue
Note: The interactive prompt box is built with Rust. If installing from source (not from PyPI), you'll need the Rust toolchain installed.
Or, for local development:
cd claude-code-queue
pip install -e .
Quick Start
After installation, use the claude-queue command:
-
Test Claude Code connection:
claude-queue test
-
Add a quick prompt:
claude-queue add "Fix the authentication bug" --priority 1
-
Create a detailed prompt template:
claude-queue template my-feature --priority 2 # Edit ~/.claude-queue/queue/my-feature.md with your prompt
-
Launch the interactive prompt box:
claude-queue prompt-box -
Start the queue processor:
claude-queue start
Usage
Adding Prompts
Quick prompt:
claude-queue add "Implement user authentication" --priority 1 --working-dir /path/to/project
Template for detailed prompt:
claude-queue template auth-feature
This creates ~/.claude-queue/queue/auth-feature.md:
---
priority: 0
working_directory: .
context_files: []
max_retries: 3
estimated_tokens: null
---
# Prompt Title
Write your prompt here...
## Context
Any additional context or requirements...
## Expected Output
What should be delivered...
Managing the Queue
Check status:
claude-queue status --detailed
List prompts:
claude-queue list --status queued
Cancel a prompt:
claude-queue cancel abc123
Running the Queue
Start processing:
claude-queue start
Start with verbose output:
claude-queue start --verbose
Prompt Bank (Template Management)
The Prompt Bank allows you to save and reuse templates for recurring tasks like daily documentation updates, weekly reports, or standard maintenance tasks.
Saving Templates to Bank
Create a new template in the bank:
claude-queue bank save update-docs --priority 1
This creates ~/.claude-queue/bank/update-docs.md which you can edit:
---
priority: 1
working_directory: /path/to/project
context_files:
- README.md
- docs/
max_retries: 3
estimated_tokens: 1500
---
# Update Project Documentation
Please review and update the project documentation:
## Tasks
1. Update README.md with latest features
2. Check code examples are current
3. Update API documentation
4. Fix any broken links
## Context
This is the daily documentation review task.
Managing Templates
List available templates:
claude-queue bank list
Use a template (adds to queue):
claude-queue bank use update-docs
Delete a template:
claude-queue bank delete update-docs
Typical Workflow for Recurring Tasks
-
One-time setup:
# Create and customize your template claude-queue bank save daily-standup --priority 1 # Edit ~/.claude-queue/bank/daily-standup.md with your specific requirements
-
Daily usage:
# Simply add to queue whenever needed claude-queue bank use daily-standup claude-queue start
This eliminates the need to recreate the same prompt structure every time!
Interactive Prompt Box
The prompt box provides an interactive terminal UI for browsing and selecting files with fuzzy search capabilities.
Launching the Prompt Box
claude-queue prompt-box
Features
- Fuzzy File Search: Type to filter files by name or path
- Real-time Preview: See file contents as you navigate
- Keyboard Navigation: Use arrow keys to browse files
- File Selection: Select files to include in prompts
- Directory Traversal: Browse through project directories
- Copy to Clipboard: Copy file paths or contents
Keyboard Shortcuts
Input Mode:
↑/↓: Navigate history←/→: Move cursor left/rightHome/End: Move cursor to beginning/endEnter: Submit inputTab: Trigger file picker for @ mentionsCtrl+C: Copy to clipboardCtrl+Q: Quit applicationOptn+Enter: Move cursor to newline
Picker Mode (file selection):
↑/↓: Navigate through filesEnter: Select current fileEsc: Exit picker mode- Type to search files with fuzzy matching
The prompt box is built with Rust for fast file indexing and responsive UI, making it easy to explore large codebases and select relevant files for your Claude Code prompts.
How It Works
- Queue Processing: Runs prompts in priority order (lower number = higher priority)
- Rate Limit Detection: Monitors Claude Code output for rate limit messages
- Automatic Waiting: When rate limited, waits for the next 5-hour window
- Retry Logic: Failed prompts are retried up to
max_retriestimes - File Organization:
~/.claude-queue/queue/- Pending prompts~/.claude-queue/completed/- Successful executions~/.claude-queue/failed/- Failed prompts~/.claude-queue/bank/- Saved template library~/.claude-queue/queue-state.json- Queue metadata
Configuration
Command Line Options
claude-queue --help
Key options:
--storage-dir: Queue storage location (default:~/.claude-queue)--claude-command: Claude CLI command (default:claude)--check-interval: Check interval in seconds (default: 30)--timeout: Command timeout in seconds (default: 3600)
Prompt Configuration
Each prompt supports these YAML frontmatter options:
---
priority: 1 # Execution priority (0 = highest)
working_directory: /path/to/project # Where to run the prompt
context_files: # Files to include as context
- src/main.py
- README.md
max_retries: 3 # Maximum retry attempts
estimated_tokens: 1000 # Estimated token usage (optional)
---
Examples
Basic Usage
# Add a simple prompt
claude-queue add "Run tests and fix any failures" --priority 1
# Create template for complex prompt
claude-queue template database-migration --priority 2
# Launch interactive file browser
claude-queue prompt-box
# Save a reusable template
claude-queue bank save update-docs --priority 1
# Use a saved template
claude-queue bank use update-docs
# Start processing
claude-queue start
Complex Prompt Template
---
priority: 1
working_directory: /Users/me/my-project
context_files:
- src/auth.py
- tests/test_auth.py
- docs/auth-requirements.md
max_retries: 2
estimated_tokens: 2000
---
# Fix Authentication Bug
There's a bug in the user authentication system where users can't log in with special characters in their passwords.
## Context
- The issue affects passwords containing @, #, $ symbols
- Error occurs in the password validation function
- Tests are failing in test_auth.py
## Requirements
1. Fix the password validation to handle special characters
2. Update tests to cover edge cases
3. Ensure backward compatibility
## Expected Output
- Fixed authentication code
- Updated test cases
- Documentation update if needed
Rate Limit Handling
The system automatically detects Claude Code rate limits by monitoring:
- "usage limit reached" messages
- Claude's reset time information
- Standard rate limit error patterns
When rate limited:
- Prompt status changes to
rate_limited - Naively loop every fixed interval until rate limit is lifted (there's probably a way smarter way to find the end time of rate limit window, open to contributions)
- Once the rate limit is lifted, continue processing the requests
Troubleshooting
Queue not processing:
# Check Claude Code connection
claude-queue test
# Check queue status
claude-queue status --detailed
Prompts stuck in executing state:
- Stop queue processor (Ctrl+C)
- Restart with
claude-queue start - Executing prompts will reset to queued status
Rate limit not detected:
- Check if Claude Code output format changed
- File an issue with the error message you received
Directory Structure
~/.claude-queue/
├── queue/ # Pending prompts
│ ├── 001-fix-bug.md
│ └── 002-feature.executing.md
├── completed/ # Successful executions
│ └── 001-fix-bug-completed.md
├── failed/ # Failed prompts
│ └── 003-failed-task.md
├── bank/ # Saved template library
│ ├── update-docs.md
│ ├── daily-standup.md
│ └── weekly-report.md
└── queue-state.json # Queue metadata
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 claude_code_queue-0.2.1.tar.gz.
File metadata
- Download URL: claude_code_queue-0.2.1.tar.gz
- Upload date:
- Size: 41.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
773936f3914571fe23722c8714af966da10c642f2af1ee2097399327d80434d3
|
|
| MD5 |
d6d4f5b50064ffe4d938a2fd140a2caa
|
|
| BLAKE2b-256 |
838c5665ffc2974893c476c7ba68cb36db39e14105d10e8b3f113f5bf703b29f
|
File details
Details for the file claude_code_queue-0.2.1-cp311-cp311-macosx_10_9_universal2.whl.
File metadata
- Download URL: claude_code_queue-0.2.1-cp311-cp311-macosx_10_9_universal2.whl
- Upload date:
- Size: 662.4 kB
- Tags: CPython 3.11, macOS 10.9+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbd9557afd68965b7410be0028fe9a5727f3acb66226346e416b752d44f4c991
|
|
| MD5 |
057751516814fc2f73e22a39d6b7b54d
|
|
| BLAKE2b-256 |
bbfbbd42bb97cc62635bb532f94cf9cfd4881c800e3ec4758752557237bcf9af
|