Bypassing Context Window Limits in Claude 3.7's Cursor (Without Claude Max Mode Costs)
Blog

Bypassing Context Window Limits in Claude 3.7's Cursor (Without Claude Max Mode Costs)

Young-jae
2025.05.11
Β·WebΒ·by Anonymous
#LLM#Claude 3.7#Context Window#Cursor IDE#Python

Key Points

  • 1This guide details how to expand the Claude 3.7 context window in the Cursor IDE to 200,000 tokens, bypassing the cost of the "Max" variant.
  • 2The expansion can be achieved either by manually modifying the `getEffectiveTokenLimit` function within the `workbench.desktop.main.js` file, or more conveniently, by using an automated Python script from the CursorPlus project.
  • 3This client-side modification enables larger API requests without changing Anthropic's billing to "Max" rates, but users should be aware of potential service term violations and the necessity of re-applying modifications after updates.

This paper details a method for extending the context window of the standard Claude 3.7 model within the Cursor Integrated Development Environment (IDE) to 200,000 tokens, without incurring the additional costs associated with Claude 3.7 Max. The core problem addressed is that while Claude 3.7 Max offers a 200K token context window, it comes at a premium of $0.05 per request and per tool call, which can accumulate significantly when working with large codebases. The standard Claude 3.7 model is limited to approximately 48K tokens, restricting its utility for complex projects involving extensive documentation or multiple files.

The paper presents two primary methodologies to bypass this client-side context window limitation: manual JavaScript modification and an automated Python script.

The first method involves directly modifying Cursor's client-side JavaScript files. The process is as follows:

  1. Locate the main JavaScript file: The critical file is identified as resources/app/out/vs/workbench/workbench.desktop.main.js. Its location varies by operating system (e.g., C:\Users\[Username]\AppData\Local\Programs\Cursor\resourcesC:\Users\[Username]\AppData\Local\Programs\Cursor\resources on Windows, or within the application package contents on macOS).
  2. Backup the original file: Before any modification, a backup of workbench.desktop.main.js is strongly recommended to enable restoration.
  3. Modify the getEffectiveTokenLimit function: This function is responsible for determining the token limit for various AI models used within Cursor. The modification targets the "claude-3.7-sonnet" model. The core technical intervention is to inject a conditional statement that overrides the default token limit for this specific model. The snippet provided illustrates this:
javascriptasync getEffectiveTokenLimit(e) { const n = e.modelName; // 'n' represents the model name if (n === "claude-3.7-sonnet") return 200000; // The original logic of the function continues here for other models or scenarios. }

This modification forces the client to report a 200,000-token limit whenever Claude 3.7 Sonnet is the active model, irrespective of its default configuration.
  1. Save and restart Cursor: After saving the modified JavaScript file, restarting the Cursor application applies the changes.

The second and recommended method utilizes an automated Python script, hack_claude.py, available from the CursorPlus GitHub repository. This approach is preferred for its reliability and user-friendliness:

  1. Download the script: Obtain hack_claude.py.
  2. Ensure Python is installed: The script has no external Python dependencies.
  3. Execute the script: Run the script from the terminal using python hack_claude.py. The script performs several automated actions:
    • Automatically locates the Cursor installation directory.
    • Creates backups of the original workspace files.
    • Applies the necessary modifications to the JavaScript files, including:
      • Increasing the token limit to 200,000.
      • Setting the "thought level" for detailed reasoning to "high."
      • Adding custom UI styling (e.g., gradient, red, animated) to visually distinguish the enhanced model.
  4. Customization Options: The script supports various command-line arguments for fine-grained control:
    • --file or -f: Specifies a custom path to the workspace file.
    • --token-mode or -t: Allows choosing between applying the 200K limit to claude37_only (default) or all_models.
    • --ui-style or -u: Selects the UI styling (e.g., gradient, red, animated).
    • --skip-backup or -s: Skips backup creation (not recommended).
An example command to apply the 200K limit to all models with animated styling is python hack_claude.py --token-mode all_models --ui-style animated.

The paper explains that this bypass is effective because the token limit is primarily enforced client-side within Cursor, rather than being a strict server-side constraint for basic API requests. By modifying the client's cached token limit via the getEffectiveTokenLimit function, the Cursor IDE is permitted to send larger input payloads to Anthropic's API. Crucially, this modification does not alter Anthropic's billing; users will still be charged standard Claude 3.7 rates, not the higher Max rates, for the API usage.

Verification of the modification can be done by testing with larger codebases or extensive documentation, monitoring AI performance to confirm it handles increased input without hitting context limits, and checking for UI changes if styling options were used. The paper concludes by emphasizing the benefits of enhanced productivity for developers working on complex projects, while also cautioning about the risks of software modification, potential service term violations, and the necessity of backing up original files.