Skip to content

feat: add quota analysis with multi-tier support#11

Merged
pszymkowiak merged 1 commit intortk-ai:masterfrom
FlorianBruniaux:feat/quota-analysis
Jan 29, 2026
Merged

feat: add quota analysis with multi-tier support#11
pszymkowiak merged 1 commit intortk-ai:masterfrom
FlorianBruniaux:feat/quota-analysis

Conversation

@FlorianBruniaux
Copy link
Collaborator

Summary

Adds --quota flag to rtk gain command to display estimated monthly quota savings across different Claude subscription tiers (Pro, Max 5x, Max 20x).

This helps users understand the real-world impact of RTK's token optimizations in terms of their subscription usage.

Changes

  • Add --quota flag to rtk gain command
  • Add --tier <pro|5x|20x> parameter for subscription tier selection (default: 20x)
  • Implement heuristic quota calculation based on ~44K tokens/5h Pro baseline
  • Display subscription tier, estimated monthly quota, and % preserved

Example Output

$ rtk gain --quota --tier 20x

Monthly Quota Analysis:
────────────────────────────────────────
Subscription tier:        Max 20x ($200/mo)
Estimated monthly quota:  120.0M
Tokens saved (lifetime):  356.7K
Quota preserved:          0.3%

Note: Heuristic estimate based on ~44K tokens/5h (Pro baseline)
      Actual limits use rolling 5-hour windows, not monthly caps.

Quota Estimates

Tier Estimated Monthly Quota Price
Pro 6.0M tokens $20/mo
Max 5x 30.0M tokens $100/mo
Max 20x 120.0M tokens $200/mo

Note: These are heuristic estimates for user guidance. Claude uses rolling 5-hour usage windows, not fixed monthly token quotas. Estimates based on Pro baseline of ~44K tokens/5h.

Test Plan

  • Build succeeds without warnings
  • rtk gain --quota uses default tier (20x)
  • rtk gain --quota --tier pro shows Pro calculations
  • rtk gain --quota --tier 5x shows 5x calculations
  • Compatible with existing --graph and --history flags

Dependencies

None. Uses existing tracking::Tracker infrastructure.

🤖 Generated with Claude Code

Implements heuristic calculation of monthly quota savings percentage
with support for Pro, Max 5x, and Max 20x subscription tiers.

Features:
- --quota flag displays monthly quota analysis
- --tier <pro|5x|20x> selects subscription tier (default: 20x)
- Heuristic based on ~44K tokens/5h Pro baseline
- Estimates: Pro=6M, 5x=30M, 20x=120M tokens/month
- Clear disclaimer about rolling 5-hour windows vs monthly caps

Example output for Max 20x:
  Subscription tier:        Max 20x ($200/mo)
  Estimated monthly quota:  120.0M
  Tokens saved (lifetime):  356.7K
  Quota preserved:          0.3%

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 29, 2026 11:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds quota analysis functionality to the rtk gain command, allowing users to see how their token savings translate to Claude subscription quota usage across different tiers (Pro, Max 5x, Max 20x).

Changes:

  • Added --quota flag and --tier parameter to the rtk gain command
  • Implemented heuristic quota calculation using a Pro baseline of ~44K tokens/5h
  • Added formatted output displaying subscription tier, estimated monthly quota, tokens saved, and quota preserved percentage

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/main.rs Added quota boolean flag and tier string parameter to the Gain command enum, with tier defaulting to "20x" and requiring quota flag
src/gain.rs Updated run function signature to accept quota parameters, implemented quota calculation logic with tier matching, and added formatted output section

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +71 to +92
if quota {
const ESTIMATED_PRO_MONTHLY: usize = 6_000_000; // ~6M tokens/month (heuristic: ~44K/5h × 6 periods/day × 30 days)

let (quota_tokens, tier_name) = match tier {
"pro" => (ESTIMATED_PRO_MONTHLY, "Pro ($20/mo)"),
"5x" => (ESTIMATED_PRO_MONTHLY * 5, "Max 5x ($100/mo)"),
"20x" => (ESTIMATED_PRO_MONTHLY * 20, "Max 20x ($200/mo)"),
_ => (ESTIMATED_PRO_MONTHLY, "Pro ($20/mo)"), // default fallback
};

let quota_pct = (summary.total_saved as f64 / quota_tokens as f64) * 100.0;

println!("Monthly Quota Analysis:");
println!("────────────────────────────────────────");
println!("Subscription tier: {}", tier_name);
println!("Estimated monthly quota: {}", format_tokens(quota_tokens));
println!("Tokens saved (lifetime): {}", format_tokens(summary.total_saved));
println!("Quota preserved: {:.1}%", quota_pct);
println!();
println!("Note: Heuristic estimate based on ~44K tokens/5h (Pro baseline)");
println!(" Actual limits use rolling 5-hour windows, not monthly caps.");
}
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new quota calculation logic lacks test coverage. The repository has comprehensive test coverage (tests found in filter.rs, git.rs, grep_cmd.rs, json_cmd.rs, local_llm.rs, log_cmd.rs, ls.rs, pnpm_cmd.rs, read.rs, runner.rs, vitest_cmd.rs), but gain.rs has no tests. Consider adding unit tests to verify: 1) correct quota calculations for each tier (pro, 5x, 20x), 2) the format_tokens function works correctly with the quota values, 3) percentage calculations are accurate, and 4) edge cases like zero total_saved.

Copilot uses AI. Check for mistakes.
}

if quota {
const ESTIMATED_PRO_MONTHLY: usize = 6_000_000; // ~6M tokens/month (heuristic: ~44K/5h × 6 periods/day × 30 days)
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment states "~44K/5h × 6 periods/day × 30 days" but this calculation yields approximately 7.9M tokens, not 6M. Additionally, 24 hours divided by 5-hour periods equals 4.8 periods per day, not 6. The constant value of 6M appears to be based on different assumptions than what the comment describes. Consider either: 1) updating the comment to accurately reflect the calculation (e.g., "~44K/5h × 4.5 periods/day × 30 days"), or 2) clarifying that this is a conservative estimate with different assumptions.

Suggested change
const ESTIMATED_PRO_MONTHLY: usize = 6_000_000; // ~6M tokens/month (heuristic: ~44K/5h × 6 periods/day × 30 days)
const ESTIMATED_PRO_MONTHLY: usize = 6_000_000; // ~6M tokens/month (heuristic: ~44K/5h × 4.5 periods/day × 30 days)

Copilot uses AI. Check for mistakes.
};

let quota_pct = (summary.total_saved as f64 / quota_tokens as f64) * 100.0;

Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quota output should be preceded by an empty line to visually separate it from the previous section (history, graph, or command summary). Looking at lines 46, 47, and 68-69 in the same file, other sections include a blank line after them. The quota section should follow the same pattern by adding a println!(); before line 83 to maintain consistency with the existing output formatting.

Suggested change
println!();

Copilot uses AI. Check for mistakes.
#[arg(short, long)]
quota: bool,
/// Subscription tier for quota calculation: pro, 5x, 20x
#[arg(short, long, default_value = "20x", requires = "quota")]
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tier parameter accepts any string value but silently falls back to "pro" for invalid values (line 78). This could lead to user confusion. Consider using clap's value_parser with PossibleValue to restrict input to valid values ("pro", "5x", "20x") and provide clear error messages for invalid input. This would make the CLI more robust and user-friendly by catching errors at parse time rather than silently using a fallback.

Suggested change
#[arg(short, long, default_value = "20x", requires = "quota")]
#[arg(
short,
long,
default_value = "20x",
requires = "quota",
value_parser = ["pro", "5x", "20x"]
)]

Copilot uses AI. Check for mistakes.
@pszymkowiak pszymkowiak merged commit 64c0b03 into rtk-ai:master Jan 29, 2026
5 of 7 checks passed
FlorianBruniaux added a commit to FlorianBruniaux/rtk that referenced this pull request Jan 30, 2026
Updates documentation to reflect all features added in recent PRs:

**Version Updates**
- Update installation commands to v0.3.1 (DEB/RPM packages)

**New Sections**
- Add Global Flags section (-u/--ultra-compact, -v/--verbose)
- Add JavaScript/TypeScript Stack section (10 new commands)

**New Commands Documented**
- Files: `rtk smart` (heuristic code summary)
- Commands: `rtk gh` (GitHub CLI), `rtk wget`, `rtk config`
- Data: `rtk gain --quota` and `--tier` flags
- Containers: `rtk kubectl services`
- JS/TS Stack: lint, tsc, next, prettier, vitest, playwright, prisma

**Features Coverage**
This update documents functionality from:
- PR rtk-ai#5: Git argument parsing improvements
- PR rtk-ai#6: pnpm support
- PR rtk-ai#9: Modern JavaScript/TypeScript stack support
- PR rtk-ai#10: GitHub CLI integration
- PR rtk-ai#11: Quota analysis features
- PR rtk-ai#14: Additional command improvements

All commands documented are available in v0.3.1.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
FlorianBruniaux added a commit to FlorianBruniaux/rtk that referenced this pull request Jan 30, 2026
Updates documentation to reflect all features added in recent PRs:

**Version Updates**
- Update installation commands to v0.3.1 (DEB/RPM packages)

**New Sections**
- Add Global Flags section (-u/--ultra-compact, -v/--verbose)
- Add JavaScript/TypeScript Stack section (10 new commands)

**New Commands Documented**
- Files: `rtk smart` (heuristic code summary)
- Commands: `rtk gh` (GitHub CLI), `rtk wget`, `rtk config`
- Data: `rtk gain --quota` and `--tier` flags
- Containers: `rtk kubectl services`
- JS/TS Stack: lint, tsc, next, prettier, vitest, playwright, prisma

**Features Coverage**
This update documents functionality from:
- PR rtk-ai#5: Git argument parsing improvements
- PR rtk-ai#6: pnpm support
- PR rtk-ai#9: Modern JavaScript/TypeScript stack support
- PR rtk-ai#10: GitHub CLI integration
- PR rtk-ai#11: Quota analysis features
- PR rtk-ai#14: Additional command improvements

All commands documented are available in v0.3.1.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
ahundt pushed a commit to ahundt/rtk that referenced this pull request Feb 23, 2026
feat: add quota analysis with multi-tier support
ahundt pushed a commit to ahundt/rtk that referenced this pull request Feb 23, 2026
Updates documentation to reflect all features added in recent PRs:

**Version Updates**
- Update installation commands to v0.3.1 (DEB/RPM packages)

**New Sections**
- Add Global Flags section (-u/--ultra-compact, -v/--verbose)
- Add JavaScript/TypeScript Stack section (10 new commands)

**New Commands Documented**
- Files: `rtk smart` (heuristic code summary)
- Commands: `rtk gh` (GitHub CLI), `rtk wget`, `rtk config`
- Data: `rtk gain --quota` and `--tier` flags
- Containers: `rtk kubectl services`
- JS/TS Stack: lint, tsc, next, prettier, vitest, playwright, prisma

**Features Coverage**
This update documents functionality from:
- PR rtk-ai#5: Git argument parsing improvements
- PR rtk-ai#6: pnpm support
- PR rtk-ai#9: Modern JavaScript/TypeScript stack support
- PR rtk-ai#10: GitHub CLI integration
- PR rtk-ai#11: Quota analysis features
- PR rtk-ai#14: Additional command improvements

All commands documented are available in v0.3.1.

Co-Authored-By: Claude Sonnet 4.5 <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.

3 participants