Never miss a Claude Code renewal window again! Automatically maintains your 5-hour usage blocks with optional scheduled start times.
Claude Code operates on a 5-hour subscription model that renews from your first message. If you:
- Start coding at 5pm (block runs 5pm-10pm)
- Don't use Claude again until 11:01pm
- Your next block runs 11pm-4am (missing an hour!)
Session Burning Problem: Starting the daemon at random times can waste precious hours of your block. If you want to code from 9am-2pm but start the daemon at 6am, you've burned 3 hours!
Solution: CC AutoRenew prevents both gaps AND session burning:
- π« Prevents Gaps - Automatically starts new sessions when blocks expire
- β° Prevents Session Burning - Schedule when monitoring begins (
--at "09:00") - π― Perfect Timing - Start your 5-hour block exactly when you need it
- π Automatic Renewal - Starts Claude sessions exactly when needed
- β° Scheduled Start Times - Set when daemon begins monitoring (
--at "09:00") - π Scheduled Stop Times - Set when daemon stops monitoring (
--stop "17:00") - π Daily Auto-Restart - Automatically resumes next day at start time
- π Smart Monitoring - Integrates with ccusage for accurate timing
- π― Intelligent Scheduling - Checks more frequently as renewal approaches
- π Detailed Logging - Track all renewal activities with WAITING/ACTIVE/STOPPED states
- π Live Dashboard - Real-time monitoring with progress bars and renewal schedules
- π¬ Custom Messages - Use
--messageto send contextual renewal messages instead of generic greetings - π‘οΈ Failsafe Design - Multiple fallback mechanisms and prevents renewals near stop time
- π₯οΈ Cross-platform - Works on macOS and Linux
- β‘ Clock-only Mode - Use
--disableccusageflag to bypass ccusage entirely
# Clone the repository
git clone https://github.com/aniketkarne/CCAutoRenew.git
cd CCAutoRenew
# Make scripts executable
chmod +x *.sh
# Interactive setup (recommended)
./setup-claude-cron.sh
# OR manual daemon start
./claude-daemon-manager.sh start
./claude-daemon-manager.sh start --at "09:00" # with start time
./claude-daemon-manager.sh start --at "09:00" --stop "17:00" # with start/stop times
./claude-daemon-manager.sh start --message "continue working on my project" # with custom message
./claude-daemon-manager.sh start --at "09:00" --stop "17:00" --disableccusage # clock-only modeThat's it! The daemon will now run in the background and automatically renew your Claude sessions.
- Claude CLI installed and authenticated
- Bash 4.0+ (pre-installed on macOS/Linux)
- (Optional) ccusage for precise timing
First, ensure you have Claude Code installed:
# Follow the official installation guide
# https://www.anthropic.com/claude-codeFor accurate renewal timing:
# Option 1: Global install
npm install -g ccusage
# Option 2: Use without installing
npx ccusage@latest
bunx ccusage# Clone this repository
git clone https://github.com/aniketkarne/CCAutoRenew.git
cd cc-autorenew
# Make all scripts executable
chmod +x *.sh
# Test your setup
./test-claude-renewal.sh# Start the auto-renewal daemon
./claude-daemon-manager.sh start
# Start with scheduled activation time
./claude-daemon-manager.sh start --at "09:00"
./claude-daemon-manager.sh start --at "2025-01-28 14:30"
# Start with both start and stop times
./claude-daemon-manager.sh start --at "09:00" --stop "17:00"
./claude-daemon-manager.sh start --at "2025-01-28 09:00" --stop "2025-01-28 17:00"
# Start with clock-only mode (bypass ccusage entirely)
./claude-daemon-manager.sh start --at "09:00" --stop "17:00" --disableccusage
# Start with custom renewal message (useful for context continuity)
./claude-daemon-manager.sh start --message "continue working on the React feature"
./claude-daemon-manager.sh start --at "09:00" --message "resume our Python project"
# Check daemon status
./claude-daemon-manager.sh status
# Live dashboard with real-time updates
./claude-daemon-manager.sh dash
# View logs
./claude-daemon-manager.sh logs
# Follow logs in real-time
./claude-daemon-manager.sh logs -f
# Stop the daemon
./claude-daemon-manager.sh stop
# Restart the daemon (with same start/stop times if previously set)
./claude-daemon-manager.sh restart
./claude-daemon-manager.sh restart --at "10:00" # new start time
./claude-daemon-manager.sh restart --at "09:00" --stop "17:00" # new scheduleThe new live dashboard provides real-time monitoring of your Claude renewal status:
# Launch the interactive dashboard
./claude-daemon-manager.sh dashDashboard Features:
- π§ Daemon Status - Current state (WAITING/ACTIVE/STOPPED) with PID and timing details
- β±οΈ Progress Bar - Visual progress showing time until next renewal reset (color-coded)
- π Today's Plan - Estimated renewal trigger times throughout the day
- π Live Activity - Real-time log entries and recent daemon actions
- π Auto-Updates - Refreshes every minute automatically
- π― Smart Layout - Clean interface with clear sections and formatting
Progress Bar Colors:
- π’ Green - More than 1 hour remaining
- π‘ Yellow - 30-60 minutes remaining
- π΄ Red - Less than 30 minutes remaining
Usage:
- Press Ctrl+C to exit the dashboard
- Dashboard updates automatically every 60 seconds
- Works only when daemon is running
- Shows "No renewal tracking" when no activity file exists
Example dashboard output:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Claude Auto-Renewal Dashboard β
β Wednesday, August 06, 2025 - 16:54:07 β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π§ DAEMON STATUS:
PID: 12345
Status: β
ACTIVE - Auto-renewal monitoring enabled
β±οΈ TIME TO NEXT RESET:
ββββββββββββββββββββββββββββββββββββββββ 60% (1h 59m remaining)
Next renewal at: 18:53
π
TODAY'S RENEWAL PLAN:
β’ 18:53 (NEXT)
β’ 23:53
π RECENT ACTIVITY:
[2025-08-06 16:53:20] Renewal successful!
[2025-08-06 16:53:10] Starting Claude session for renewal...
- Monitors your Claude usage using ccusage (or time-based fallback)
- Detects when your 5-hour block is about to expire
- Waits until just after expiration (within scheduled hours)
- Starts a minimal Claude session (custom message or random greeting)
- Stops monitoring at configured stop time
- Automatically restarts the next day at start time
- Logs all activities for transparency
Default Behavior (without --message): The daemon automatically sends random greetings ("hi", "hello", "hey there", "good day", "greetings", "howdy", "what's up", "salutations") when renewing sessions. This is the original behavior and requires no configuration.
Custom Messages (with --message): You can optionally specify a custom message to maintain context when resuming work after rate limits:
# Use custom message for renewals
./claude-daemon-manager.sh start --message "continue working on the React feature"
# Combine with other options
./claude-daemon-manager.sh start --at "09:00" --stop "17:00" --message "resume our database optimization"
# The message persists across daemon restarts
./claude-daemon-manager.sh restart # Still uses the previous custom message
# Clear custom message (return to random greetings)
./claude-daemon-manager.sh restart # Without --message flagWhy use custom messages?
- Context Continuity: When rate-limited mid-task, resume with relevant context
- Project Tracking: Include project name for better session organization
- Task Resumption: Specify what you were working on before the limit
- Better History: More meaningful renewal entries in your Claude history
Example scenarios:
- Working on a feature:
--message "continue implementing the auth system" - Debugging session:
--message "resume debugging the memory leak issue" - Learning session:
--message "continue the Python tutorial" - Code review:
--message "resume reviewing the pull request"
By default, the daemon uses ccusage for accurate timing information. However, you can bypass ccusage entirely and rely solely on clock-based timing:
# Start with clock-only mode
./claude-daemon-manager.sh start --at "09:00" --stop "17:00" --disableccusageWhen --disableccusage is used:
- π« No ccusage dependency - Works without ccusage installed
- β° Clock-based timing - Relies on 5-hour intervals from last activity
- π Clear logging - Shows "
β οΈ ccusage DISABLED - Using clock-based timing only" - π― Same functionality - All scheduling features still work
This mode is useful when:
- You don't want to install ccusage
- ccusage is causing issues on your system
- You prefer simpler time-based renewal checking
- You're in a restricted environment where ccusage can't run
Problem: Starting daemon at wrong time wastes your 5-hour block
# BAD: Start daemon at 6am but want to code 9am-2pm = 3 hours wasted!
./claude-daemon-manager.sh start
# GOOD: Schedule daemon to start monitoring at 9am
./claude-daemon-manager.sh start --at "09:00"
# Your 5-hour block: 9am-2pm (perfect timing!)
# BETTER: Schedule both start and stop times for daily work schedule
./claude-daemon-manager.sh start --at "09:00" --stop "17:00"
# Monitors 9am-5pm, stops automatically, resumes next day at 9amUse Cases:
- π
Morning Coder:
--at "09:00"for 9am-2pm coding sessions - π Night Owl:
--at "18:00"for 6pm-11pm evening coding - π’ Work Schedule:
--at "09:00" --stop "17:00"for 9am-5pm daily monitoring - π― Focused Sessions:
--at "14:00" --stop "19:00"for afternoon coding blocks - π
Planned Session:
--at "2025-01-28 14:30"for specific date/time - π¬ Context Preservation:
--message "continue React feature"to maintain work context - β‘ Clock-only Mode:
--at "09:00" --stop "17:00" --disableccusageto bypass ccusage
The daemon adjusts its checking frequency based on time remaining:
- Normal: Every 10 minutes
- < 30 minutes: Every 2 minutes
- < 5 minutes: Every 30 seconds
- After renewal: 5-minute cooldown
Run the test suite to verify everything is working:
# Quick test (< 1 minute)
./test-quick.sh
# Comprehensive test suite (includes start-time feature)
./test-start-time-feature.sh
# Legacy comprehensive test
./test-claude-renewal.shThe new comprehensive test includes:
- β Start-time functionality validation
- β Daemon status with scheduling
- β File management and cleanup
- β Integration tests with real timing
- β All existing functionality tests
cc-autorenew/
βββ claude-daemon-manager.sh # Main control script
βββ claude-auto-renew-daemon.sh # Core daemon process
βββ claude-auto-renew-advanced.sh # Standalone renewal script
βββ claude-auto-renew.sh # Basic renewal script
βββ setup-claude-cron.sh # Interactive setup (daemon/cron)
βββ test-start-time-feature.sh # New comprehensive test suite
βββ reddit.md # Reddit post about the project
βββ README.md # This file
Logs are stored in your home directory:
~/.claude-auto-renew-daemon.log- Main daemon activity~/.claude-last-activity- Timestamp of last renewal
View recent activity:
# Last 50 log entries
tail -50 ~/.claude-auto-renew-daemon.log
# Follow logs in real-time
tail -f ~/.claude-auto-renew-daemon.logThe daemon uses smart defaults, but you can modify behavior by editing claude-auto-renew-daemon.sh:
# Adjust check intervals (in seconds)
- Normal: 600 (10 minutes)
- Approaching: 120 (2 minutes)
- Imminent: 30 (30 seconds)# Check if already running
./claude-daemon-manager.sh status
# Check logs for errors
tail -20 ~/.claude-auto-renew-daemon.log# Test ccusage directly
ccusage blocks
# The daemon will fall back to time-based checking automatically
# Or use --disableccusage flag to bypass ccusage entirely# Check logs for clock-only mode confirmation
grep "ccusage DISABLED" ~/.claude-auto-renew-daemon.log
# Should show: "β οΈ ccusage DISABLED - Using clock-based timing only"# Verify Claude CLI is installed
which claude
# Test Claude directly
echo "hi" | claudeContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
When forking or redistributing this project, please:
- Keep original attribution in README acknowledgments
- Maintain the MIT License and copyright notice
- Add your own contributions to the acknowledgments section
- Follow standard open source attribution practices
This project is licensed under the MIT License - see the LICENSE file for details.
- Aniket Karne - @aniketkarne - Original concept, core development, and start-time scheduling feature
- ccusage by @ryoppippi for accurate usage tracking
- Claude Code team for the amazing coding assistant
- Community feedback and contributions
- Open source contributors and testers
- Use
claude-daemon-manager.sh dashfor real-time monitoring with visual progress - Run
claude-daemon-manager.sh statusregularly to ensure the daemon is active - Check logs after updates to verify renewals are working
- The dashboard shows estimated renewal times for the entire day
- Progress bar changes color as renewal approaches (green β yellow β red)
- The daemon is lightweight - uses minimal resources while running
- Can be added to system startup for automatic launch
Made with β€οΈ for the Claude Code community
