1. Context Hygiene (Saving Credits)
The primary reason tokens and usage credits burn rapidly is loading unnecessary files and history into the AI’s context window. Every request resends previous chat context, attached files, and codebase indexes.
- Start New Chats Aggressively: Never keep a single chat open for multiple tasks. A 20-turn chat resends all previous messages and code diffs on turn 21, costing significantly more per turn than turn 1.
- Rule of Thumb: One feature / bug / file = One chat. Once resolved, open a fresh chat (
Cmd + NorCtrl + N).
- Rule of Thumb: One feature / bug / file = One chat. Once resolved, open a fresh chat (
- Avoid
@codebasefor Small Edits: Do not use@codebaseor@Webfor targeted fixes—it pulls in massive context. Use pinpoint references like@src/auth/login.tsor highlight specific code lines before running inline commands (Cmd + KorCmd + L). - Silence Terminal Noise: When a build or test fails, do not paste hundreds of lines of terminal output. Copy only the relevant stack trace or error line.
- Ignore Lockfiles & Build Artifacts: Exclude files like
package-lock.json, build outputs (dist/,build/), or large JSON fixtures in a.cursorignorefile so the indexing engine skips them.
2. Prompting Strategies to Minimize Bugs
Bugs typically occur when the AI lacks explicit constraints or attempts to write code before analyzing the codebase logic.
A. Use Plan Mode First
For complex edits, require the model to reason through the task before modifying files:
Prompt Pattern:
“Before writing any code, analyze
@file.tsand give me a 3-step execution plan. List the exact functions you will modify and any potential edge cases. Do not write implementation code until I approve the plan.”
(Or toggle Plan Mode with Shift + Tab in Agent mode).
B. Enforce Search / Replace Output Formats
Prevent the model from rewriting long, intact files just to edit a few lines. Generating extensive code blocks consumes significant output tokens.
Prompt Pattern:
“Provide changes as concise
SEARCH / REPLACEblocks only. Do not rewrite unchanged code or explain obvious concepts.”
C. Test-Driven Adjustments
Hold the model accountable using strict tests:
- Ask the AI: “Write a failing unit test for [feature/bug] in
@test_file.ts.” - Run the test locally.
- Instruct the AI: “Now implement the code to make this test pass, without modifying existing behavior.”
3. Model Selection Guide
| Task Type | Recommended Model / Mode | Cost Impact |
| Quick Refactors / Syntax / Boilerplate | Auto or smaller fast models (e.g., Grok, Flash, Haiku) | Very Low |
| Complex Logic / Multi-file Architecture | Frontier models (Claude 3.5/3.7 Sonnet, GPT-4o) | High |
| Deep Debugging | “Thinking” or MAX models | Extremely High |
Optimization Tip: Turn off idle Model Context Protocol (MCP) servers in settings when not in active use. Idle MCP tools inject system prompts and tool schemas into every request.
4. Standard Repository .cursorrules Template
| Task Type | Recommended Model / Mode | Cost Impact |
| Quick Refactors / Syntax / Boilerplate | Auto or smaller fast models (e.g., Grok, Flash, Haiku) | Very Low |
| Complex Logic / Multi-file Architecture | Frontier models (Claude 3.5/3.7 Sonnet, GPT-4o) | High |
| Deep Debugging | “Thinking” or MAX models | Extremely High |
Place a .cursorrules file in your repository’s root directory to enforce quality standards automatically on every prompt:
Markdown
# .cursorrules
## Behavior Guidelines
- Always think step-by-step and keep responses concise.
- Never rewrite entire files; output only modified diffs or SEARCH/REPLACE blocks.
- Do not introduce breaking changes to existing signatures unless explicitly asked.
## Code Quality Rules
- Write type-safe code without using `any`.
- Handle edge cases and null/undefined explicitly.
- Include minimal error handling for all asynchronous operations.
## Token Optimization
- Ask for clarification if context is missing rather than guessing codebase structure.