๐Ÿค– Claude Code Session Reset Scheduler

November 6, 2025 ยท View on GitHub

Automated session management system that ensures fresh Claude Code quotas during your working hours

A GitHub Actions-powered scheduler that automatically triggers Claude Code session resets at optimal times, maintaining a 5-hour countdown to ensure new quotas are available when you need them most. Features health monitoring through simple Q&A checks.


โœจ Key Features

  • ๐Ÿ”„ Automatic Session Management - Triggers 4 daily resets aligned with work periods
  • โฐ Smart Timing - 5-hour countdown ensures sessions refresh during productive hours
  • ๐Ÿงช Health Monitoring - Built-in Q&A checks verify system functionality
  • ๐Ÿ” Multi-Token Support - Configure backup tokens for reliability
  • ๐Ÿ“Š Activity Logging - Track all resets in monthly CSV logs
  • โšก Fast Failure Protection - 5-minute job timeout prevents resource waste

๐Ÿ“… Default Schedule (UTC+8 Timezone)

The system triggers session resets 5 hours before your target work periods:

๐Ÿ• Triggerโฐ Session Resets๐Ÿ’ผ Work Period Coverage
05:2310:00 AMMorning (8:00-12:00)
10:233:00 PMAfternoon (1:00-5:00)
17:2310:00 PMEvening (8:00-12:00)
22:233:00 AM (next)Late night coverage

๐Ÿš€ Quick Start

Step 1: Get the Repository

Choose one option:

Option A: Fork (Recommended for personal use)

# 1. Fork this repo on GitHub
# 2. Clone your fork
git clone https://github.com/codeotter0201/claude-daily-check-in.git
cd claude-daily-check-in

Option B: Clone directly

git clone https://github.com/codeotter0201/claude-daily-check-in.git
cd claude-daily-check-in

Step 2: Generate OAuth Token

claude setup-token

Copy the generated oauth_token_... value.

Step 3: Add to GitHub Secrets

  1. Navigate to: Settings โ†’ Secrets and variables โ†’ Actions
  2. Create new secrets:
Secret NameValueRequired
CLAUDE_CODE_OAUTH_TOKEN_1Your first OAuth tokenโœ… Yes
CLAUDE_CODE_OAUTH_TOKEN_2Your second OAuth tokenโญ Optional

Step 4: Done!

โœ… The scheduler is now active and will run automatically based on the default schedule.

  • First trigger will happen at the next scheduled time
  • Check the Actions tab in your GitHub repository to monitor runs
  • No push needed unless you modify the schedule

โš™๏ธ Customizing Schedule Times

Understanding the Timing System

Each trigger initiates a 5-hour countdown. The formula is:

Trigger Time + 5 hours = Session Reset Time

Quick Examples

๐Ÿ“ Click for Common Schedule Configurations

Single Daily Reset (9:00 AM)

schedule:
  - cron: "23 20 * * *" # Triggers at 4:23 AM โ†’ Resets at 9:00 AM

Twice Daily (10:00 AM & 4:00 PM)

schedule:
  - cron: "23 21,3 * * *" # Triggers at 5:23 AM & 11:23 AM

Business Hours (9:00 AM, 2:00 PM, 7:00 PM)

schedule:
  - cron: "23 20,1,6 * * *" # Triggers 5 hours before each

How to Modify Schedule

  1. Edit .github/workflows/auto-checkin.yml
  2. Find the schedule line (~line 12):
    - cron: "23 21,2,9,14 * * *" # Current schedule
    
  3. Calculate your times:
    • Choose reset times (in your timezone)
    • Subtract 5 hours for trigger times
    • Convert to UTC
    • Use :23 minutes (avoids congestion)
  4. Push your changes to apply the new schedule:
    git add .github/workflows/auto-checkin.yml
    git commit -m "Update schedule times"
    git push origin main
    
๐ŸŒ Time Zone Conversion Helper
Your Reset Time (UTC+8)Trigger Time (UTC+8)Cron Hour (UTC)
9:00 AM4:23 AM20
10:00 AM5:23 AM21
2:00 PM9:23 AM1
3:00 PM10:23 AM2
7:00 PM2:23 PM6
10:00 PM5:23 PM9

๐Ÿงช Testing Your Setup

  1. Go to Actions tab
  2. Select "Claude Code Session Reset Scheduler"
  3. Click "Run workflow"

Local Testing

# Test Q&A functionality
uv run --python 3.13 python src/log_qa_check.py --token TOKEN_1

# View logs
cat logs/$(date +%Y%m)-session-log.csv

๐Ÿ“Š Session Logs

Monthly CSV files track all activities:

Location: logs/YYYYMM-session-log.csv

Format:

timestamp,event_type,token_id,reset_time_utc8
2025-09-04 05:24:27,SESSION-RESET-TRIGGER,TOKEN_1,2025-09-04 18:24:27

๐Ÿ› ๏ธ Architecture

System Flow

graph LR
    A[GitHub Actions] -->|Scheduled Trigger| B[Claude Code]
    B -->|"Q&A Check: 1+1=?"| C[Health Verification]
    C -->|Log Event| D[CSV File]
    D -->|Git Commit| E[Repository]
    B -->|5-hour Countdown| F[Session Reset]

Project Structure

๐Ÿ“ claude-daily-check-in/
โ”œโ”€โ”€ ๐Ÿ“ .github/workflows/
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ auto-checkin.yml         # Scheduler configuration
โ”œโ”€โ”€ ๐Ÿ“ src/
โ”‚   โ””โ”€โ”€ ๐Ÿ log_qa_check.py          # Q&A & logging script
โ”œโ”€โ”€ ๐Ÿ“ logs/                        # Session records
โ”‚   โ””โ”€โ”€ ๐Ÿ“Š YYYYMM-session-log.csv
โ”œโ”€โ”€ ๐Ÿ“„ README.md                    # This file
โ””โ”€โ”€ ๐Ÿ“„ ADR-*.md                     # Architecture decisions

๐Ÿ”ง Advanced Configuration

Multiple Token Setup

Benefits of using multiple tokens:

  • โœ… Redundancy - Backup if one fails
  • โœ… Load Distribution - Parallel processing
  • โœ… Tracking - Individual token monitoring

๐Ÿ› Troubleshooting

โŒ OAuth Token Error

Error: Could not fetch an OIDC token or 401 Bad credentials

Solutions:

  • Regenerate token: claude setup-token
  • Verify secret names match exactly
  • Check GitHub Actions has id-token: write permission
  • Update CLAUDE_CODE_OAUTH_TOKEN_1 and CLAUDE_CODE_OAUTH_TOKEN_2 in GitHub Secrets
โฑ๏ธ Workflow Timeout (6 hours)

Status: Fixed in current version

Solution: The workflow now includes timeout protection:

  • Job-level timeout: 5 minutes
  • Step-level timeout: 2 minutes per action

If you still experience timeouts:

  1. Update to the latest .github/workflows/auto-checkin.yml
  2. Verify timeout configurations are present
  3. Check for authentication errors that may cause hanging
โฐ Wrong Reset Times

Checklist:

  • GitHub Actions uses UTC (not local time)
  • The 5-hour countdown is automatic
  • GitHub may delay execution by several minutes
  • Check timezone conversion calculations
๐Ÿ“ No Logs Created

Debug Steps:

# Check Claude status
claude --version
claude auth status

# Test locally
claude -p "1+1=?"

# Manual trigger
uv run --python 3.13 python src/log_qa_check.py --token TOKEN_1

๐Ÿ“ˆ Monitoring

Health Checks

  • โœ… GitHub Actions - Review workflow runs
  • โœ… CSV Logs - Verify monthly records
  • โœ… Git History - Check automated commits
  • โœ… Session Availability - Monitor actual resets

Maintenance Tasks

  • ๐Ÿ“… Monthly - Review log files
  • ๐Ÿ”„ Quarterly - Rotate OAuth tokens
  • ๐Ÿ“Š As Needed - Adjust schedule based on usage

๐Ÿ”’ Security

โš ๏ธ Important Security Practices:

  • Never hardcode tokens in code
  • Use GitHub Secrets for sensitive data
  • Rotate OAuth tokens regularly
  • Limit repository access permissions

๐Ÿค Contributing

We welcome contributions! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

๐Ÿ“ Version History

v2.3.0 (Current)

  • โœ… Workflow timeout protection (5-minute job, 2-minute steps)
  • โœ… Fast failure mechanism prevents 6-hour runaway executions
  • โœ… Integrated Q&A health checks
  • โœ… Enhanced logging with reset time calculations
  • โœ… Local testing capabilities
  • โœ… Optimized cron timing (:23 minutes)

๐Ÿ“š Documentation


Built with โค๏ธ for productive Claude Code sessions
Based on architecture decisions optimized for reliability and user convenience