Usage
Preview repairs without making changes to storage.
Output machine-readable JSON instead of human-friendly text.
Perform live quota probes before applying fixes.
Model to use for live quota probes (only with
--live).What Gets Fixed
Automatic Repairs
- Missing account IDs - Extract from JWT access tokens
- Missing emails - Extract from ID tokens
- Duplicate accounts - Merge by token/email/ID
- Invalid active index - Reset to valid range
- Corrupted metadata - Remove invalid fields
- Stale access tokens - Refresh if needed
- Missing timestamps - Set defaults (addedAt, lastUsed)
- Invalid cooldown timers - Clear expired cooldowns
- Orphaned rate limits - Remove stale entries
- Storage format migration - Upgrade V1/V2 to V3
Safe Operations Only
The fix command only performs non-destructive operations:- ✅ Add missing metadata
- ✅ Refresh expired tokens
- ✅ Merge duplicates
- ✅ Reset invalid indices
- ✅ Clear expired timers
- ❌ Delete accounts
- ❌ Disable accounts
- ❌ Change active account
Example Output
Default Mode
Dry Run Mode
Live Mode
JSON Output
Fix Types
Refresh expired access tokens using valid refresh tokens.
Extract and set missing account IDs from JWT tokens.
Extract and set missing email addresses from ID tokens.
Merge accounts with same token/email/ID into single entry.
Reset active account index to valid range (0 to count-1).
Remove expired cooldown timers (past reset time).
Delete corrupted or schema-invalid metadata fields.
Set missing addedAt/lastUsed timestamps to current time.
Upgrade account storage from V1/V2 to V3 format.
Refresh quota cache with live probe data (only with
--live).Examples
Preview fixes
Apply fixes
Fix with live quota update
Machine-readable output
Count fixes needed
Apply fixes and verify
When to Run
After Errors
If you see storage or account errors:After Manual Edits
If you manually edited storage files:Periodic Maintenance
Weekly cleanup:After Upgrades
After updating codex-multi-auth:Exit Codes
Fixes completed successfully (or no fixes needed).
Fix operation failed (storage write error, network failure).
Performance
Default Mode
- Speed: ~100-500ms
- Network: Only for token refresh (if needed)
- Writes: Single storage file update
Live Mode
- Speed: ~2-3 seconds per account
- Network: 1 API request per account + token refresh
- Writes: Storage + quota cache updates
--live: ~30-40 seconds total.
Safety Guarantees
Backup Creation
Before any writes, a backup is created:Atomic Writes
Storage updates use atomic write-then-rename to prevent corruption.Validation
All fixes are validated before write:- Schema compliance checked
- Index bounds validated
- Token format verified
- Duplicate detection run
Troubleshooting
Fix Reports No Issues But Problems Persist
Run doctor for deeper diagnostics:Storage Backup Not Created
Check permissions:Fix Fails with Write Error
Ensure directory is writable:Duplicate Merge Incorrect
Manually remove duplicates via dashboard:Related Commands
codex auth doctor- Full diagnostics with deeper repairscodex auth check- Validate fixes workedcodex auth report- View current statecodex auth verify-flagged- Fix flagged accounts