Calculate and track token savings from optimizations
Calculate actual token savings achieved and estimate potential savings from optimizations. Use this to track efficiency gains and identify high-ROI cleanup opportunities during long sessions.
/plugin marketplace add vzwjustin/Claudecontext/plugin install vzwjustin-context-window-manager@vzwjustin/ClaudecontextCalculate actual token savings achieved and estimate potential savings from optimizations.
Track savings achieved so far:
╔═══════════════════════════════════════════════╗
║ TOKEN SAVINGS REPORT ║
╠═══════════════════════════════════════════════╣
║ Session Started: 2h 15m ago ║
║ Initial Usage: 145K tokens (72%) ║
║ Current Usage: 95K tokens (47%) ║
║ Total Saved: 50K tokens (25% reduction) ║
╠═══════════════════════════════════════════════╣
║ ║
║ SAVINGS BREAKDOWN: ║
║ ║
║ Action Tokens Time ║
║ ──────────────────────── ──────── ──────── ║
║ Pruned test-output.log -12,000 14:23 ║
║ Removed old-schema.sql -18,000 14:25 ║
║ Cleared Bash outputs -8,000 14:30 ║
║ Summarized messages -10,000 14:45 ║
║ Removed backup files -2,000 15:10 ║
║ ──────────────────────── ──────── ──────── ║
║ Total Savings -50,000 ║
║ ║
║ EFFICIENCY GAINS: ║
║ ├─ Extended session time: +45 minutes ║
║ ├─ Prevented compaction: Yes (1 time) ║
║ ├─ Improved response speed: ~15% ║
║ └─ Session health: 🟡 → 🟢 ║
╚═══════════════════════════════════════════════╝
Use an agent to calculate what COULD be saved:
╔═══════════════════════════════════════════════╗
║ POTENTIAL SAVINGS ANALYSIS ║
╠═══════════════════════════════════════════════╣
║ ║
║ 🎯 HIGH-IMPACT OPPORTUNITIES: ║
║ ║
║ 1. Remove unused files (3 files) ║
║ Estimated: -22,000 tokens (23%) ║
║ Effort: Low (30 seconds) ║
║ Risk: Low (can reload if needed) ║
║ ║
║ 2. Clear old tool results (12 results) ║
║ Estimated: -15,000 tokens (16%) ║
║ Effort: Very Low (5 seconds) ║
║ Risk: None (completed tasks) ║
║ ║
║ 3. Compress message history ║
║ Estimated: -18,000 tokens (19%) ║
║ Effort: Medium (AI summarization) ║
║ Risk: Low (preserve key info) ║
║ ║
║ ⚡ QUICK WINS (Low effort, high impact): ║
║ ║
║ 4. Remove duplicate content ║
║ Estimated: -5,000 tokens (5%) ║
║ Effort: Very Low (automatic) ║
║ Risk: None (duplicates) ║
║ ║
║ 5. Clear test/debug outputs ║
║ Estimated: -8,000 tokens (8%) ║
║ Effort: Very Low (5 seconds) ║
║ Risk: None (reproducible) ║
║ ║
║ ──────────────────────────────────────────── ║
║ TOTAL POTENTIAL: -68,000 tokens (72%) ║
║ RECOMMENDED: Execute all (low risk) ║
║ TIME REQUIRED: ~2 minutes ║
║ ║
║ After optimization: ║
║ ├─ Current: 95K → Projected: 27K tokens ║
║ ├─ Usage: 47% → 13% ║
║ ├─ Gained time: ~90 minutes before limit ║
║ └─ Status: 🟢 Healthy → 🟢 Excellent ║
╚═══════════════════════════════════════════════╝
Calculate return on optimization investment:
Optimization ROI Analysis:
Time Investment: 2 minutes
Token Savings: 68,000 tokens
Extended Session: ~90 minutes
Compactions Prevented: 2
ROI Metrics:
├─ Time ROI: 45x (90min gained / 2min spent)
├─ Token ROI: 34,000 tokens/minute
├─ Productivity gain: ~2 hours of uninterrupted work
└─ Context health: Optimal for remainder of session
Recommendation: ✓ HIGHLY RECOMMENDED
Track optimization effectiveness over time:
Last 10 Sessions - Savings Performance:
Session Duration Peak Saved Final Efficiency
────────────── ──────── ────── ────── ────── ──────────
2024-01-15 14h 2h 15m 72% -50K 47% 78% ⭐⭐⭐⭐
2024-01-15 10h 1h 45m 85% -35K 62% 65% ⭐⭐⭐
2024-01-14 16h 3h 20m 91% -78K 48% 85% ⭐⭐⭐⭐⭐
2024-01-14 11h 2h 00m 55% -12K 48% 45% ⭐⭐
2024-01-13 15h 1h 30m 68% -28K 42% 72% ⭐⭐⭐⭐
Insights:
├─ Average savings per session: 40,600 tokens
├─ Most efficient session: 2024-01-14 16h (85%)
├─ Trend: Improving (last 3 sessions ⬆)
└─ Recommendation: Maintain current optimization habits
Gamify your optimization efforts:
🏆 TOP SAVINGS ACTIONS (All Time):
Rank Action Times Total Saved Avg/Action
──── ────────────────────────── ───── ─────────── ──────────
🥇 1 Prune unused files 23 -456K -19.8K
🥈 2 Clear tool outputs 45 -384K -8.5K
🥉 3 Compress message history 12 -198K -16.5K
4 Remove test logs 31 -186K -6.0K
5 Delete duplicate content 18 -92K -5.1K
Total Lifetime Savings: 1,316,000 tokens 🎉
Equivalent to: 6.5 full context windows (200K each)
Simulate impact of different optimization strategies:
SCENARIO ANALYSIS:
Current state: 95K tokens (47%)
Scenario 1: "Quick Cleanup" (5 min effort)
├─ Actions: Remove obvious waste, clear old tools
├─ Projected savings: -25K tokens
├─ Result: 70K tokens (35%)
└─ ROI: High (quick wins)
Scenario 2: "Balanced Optimization" (15 min effort)
├─ Actions: Scenario 1 + prune files + compress messages
├─ Projected savings: -50K tokens
├─ Result: 45K tokens (22%)
└─ ROI: Very High (comprehensive)
Scenario 3: "Aggressive Pruning" (30 min effort)
├─ Actions: Scenario 2 + deep analysis + restructure
├─ Projected savings: -68K tokens
├─ Result: 27K tokens (13%)
└─ ROI: Medium (diminishing returns)
Recommendation: Scenario 2 (Balanced)
Best effort-to-impact ratio for current situation.
Enable automatic savings logging:
{
"savings_tracking": {
"enabled": true,
"log_all_optimizations": true,
"calculate_roi": true,
"show_leaderboard": true,
"alert_on_milestone": true,
"milestones": [50000, 100000, 500000, 1000000]
}
}
Export savings data:
# Get current session savings as JSON
/context-window-manager:savings --format=json
# Get historical savings report
/context-window-manager:savings --history=30days
# Get potential savings only
/context-window-manager:savings --potential-only
# Get ROI analysis
/context-window-manager:savings --roi
This command uses agents to:
Let me calculate your token savings potential now using agent-based analysis.