Skip to content

Conversation

@ahoward
Copy link
Owner

@ahoward ahoward commented Oct 29, 2025

Summary

Adds a --validate flag that tests all discovered tokens before running long sessions. This helps users verify their setup is correct and catch configuration issues early.

Problem

Users don't know if their tokens are valid until they start a long session. If a token is invalid/expired, they waste time starting the session only to hit errors later. There's no way to preview rate limit status across tokens.

Solution

ddollar --validate

Tests each token with a minimal API call and shows:

  • ✓ Token validity
  • Current rate limit usage (requests & tokens)
  • Time until rate limits reset
  • Summary of valid vs invalid tokens

Example Output

🔍 Validating tokens...

[1/3] Testing Anthropic token...
  ✓ Valid
    Requests: 4850/5000 remaining (3.0% used)
    Tokens:   95234/100000 remaining (4.8% used)
    Reset:    52m 18s

[2/3] Testing Anthropic token...
  ✓ Valid
    Requests: 5000/5000 remaining (0.0% used)
    Tokens:   100000/100000 remaining (0.0% used)

[3/3] Testing OpenAI token...
  ✗ FAILED: HTTP 401: authentication failed or invalid token

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Summary: 2 valid, 1 invalid, 3 total
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Features

  1. Test All Tokens: Rotates through entire token pool
  2. Detect Invalid Tokens: HTTP 401/403/404 = authentication failure
  3. Show Rate Limit Status: Current usage for each token
  4. Smart Output: Only shows rate limit details if available
  5. Exit Code: Non-zero if any tokens fail validation

Use Cases

Before starting overnight session:

# Validate setup first
ddollar --validate

# If all valid, start long session
ddollar claude --continue

Debugging token issues:

# Add multiple tokens
export ANTHROPIC_API_KEYS=key1,key2,key3

# Test which ones work
ddollar --validate

Check rate limit status:

# See how much quota you've used
ddollar --validate

Implementation

New Package: src/validator/validator.go

func Validate(pool *tokens.Pool) error {
    // Test each token with minimal API call
    // Show rate limit status
    // Return error if any fail
}

Updated: src/supervisor/monitor.go

  • Added CheckLimitsPublic() wrapper for external use
  • Added HTTP status code checking (401/403/404 = auth failure)
  • Improved error messages

Updated: src/main.go

  • Added validate, --validate case
  • Added validateTokens() function
  • Updated usage text

Updated: README.md

  • New "Validate Your Setup" section
  • Example output
  • Usage instructions
  • Updated troubleshooting

Testing

Tested with:

  • ✅ Valid token (shows rate limits)
  • ✅ Invalid token (shows HTTP 401 error)
  • ✅ Multiple tokens (tests each one)
  • ✅ No tokens (shows error message)

Benefits

  1. Catch errors early - Before starting long sessions
  2. Preview rate limits - Know what quota is available
  3. Verify rotation - Confirm all tokens work
  4. Debug faster - Quickly identify which tokens have issues

Breaking Changes

None - this is purely additive. Existing functionality unchanged.


Ready to merge? This is a helpful pre-flight check for users. Zero risk to existing functionality.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Implements a validation mode that tests all discovered tokens before
running long sessions. Helps users verify their setup is correct.

Features:
- Test each token with minimal API call
- Show rate limit status for each token
- Detect invalid/expired tokens (HTTP 401, 403, etc)
- Display summary of valid vs invalid tokens
- Exit with error if any tokens fail

Usage:
  ddollar --validate

Benefits:
- Catch configuration errors before starting long sessions
- See current rate limit usage across all tokens
- Verify token rotation will work as expected
- Save time by validating setup first

Implementation:
- New validator package with Validate() function
- Reuses existing Monitor.checkLimits() for API calls
- Added CheckLimitsPublic() wrapper for external use
- Improved error detection (HTTP status codes)
- Smart output (only show rate limits if available)

Example output:
  [1/3] Testing Anthropic token...
    ✓ Valid
      Requests: 4850/5000 remaining (3.0% used)
      Tokens:   95234/100000 remaining (4.8% used)
      Reset:    52m 18s

  Summary: 2 valid, 1 invalid, 3 total

Updates:
- Added src/validator/validator.go (new package)
- Updated src/main.go with --validate flag
- Updated src/supervisor/monitor.go with HTTP error detection
- Updated README.md with validation section

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants