Skip to content

Token Optimization

A practical guide to help you avoid busting your token limits

If you are using AI (and AI Agents) inside your code editor, every request costs tokens (and money). The golden rule? Do mechanical work yourself. Let AI do only the thinking.

This playbook shows you when and how to use AI features so you get maximum value for minimum token spend.


1. Token‑Saving Principles

If the task is… Do it yourself (0 tokens) Let AI do it (costs tokens)
Renaming/moving/deleting files IDE Explorer (drag & drop) ❌ Never
Creating folders IDE Explorer or Terminal ❌ Never
Bulk file operations (many files) Terminal (mv, rm) ❌ Never
Checking Git status / staging LazyGit or git add ❌ Never
Writing commit messages ✅ You can do it, or use Ask (low cost) ⚠️ Optional – Ask is cheap
Explaining what a code block does ✅ Use Ask mode (cheapest)
Planning a big refactor (e.g., fixing imports) ✅ Use Plan mode first (moderate)
Actually fixing the imports/code ✅ Use Agent mode only after the plan is approved (most expensive – use sparingly)

2. The Right AI Mode

(Critical for Saving Tokens)

Your IDE / AI tool likely offers three AI modes. Using the wrong one is the #1 token waster.

Mode When to use it Token cost
Ask “What does this function do?” / “Review this diff” / “Suggest a commit message” Very Low (read‑only, no code changes)
Plan “I moved /src to /lib. Show me a step‑by‑step plan to update all imports, but do NOT change any files yet.” Low (generates a roadmap without touching your code)
Agent “Apply the import‑fix plan we just approved. Only edit the 3 files listed.” High (writes code – use only for final execution)

💡 Pro tip: Always start with Plan. A good plan costs a few tokens but prevents the Agent from making mistakes that require multiple expensive retries.


3. Writing Token‑Smart Prompts

The way you ask determines how many tokens you burn. Follow these rules:

❌ Expensive (bad) ✅ Cheap (good)
“Here is my entire project folder. Fix the imports.” “We moved utils/ to helpers/. Update import paths in app.js and api.js only.”
Paste 500 lines of code. Paste the git diff (just the changed lines).
“Find every place that needs changing.” “List all files that import from the old path. I’ll tell you which ones to edit.”
No exclusions. “Ignore node_modules/ and dist/ folders when scanning.”

💡 Pro tip: If you just renamed a file, the git diff already shows exactly what changed. Share that diff with the AI – it is much smaller than pasting full files.


Here is a typical session when restructuring your project:

  1. Move/rename/delete files – use your IDE Explorer (side panel) or Terminal.
    Cost: 0 tokens.

  2. Open LazyGit (or Terminal or your Git client) to see what has changed.
    Cost: 0 tokens.

  3. Stage the changes (Space or a).

  4. Plan the AI work – switch your IDE / AI to Plan mode and prompt:

    “We moved [old_folder] to [new_folder]. List the exact files that need import updates and the changes required. Do not execute.”

  5. Review the plan – if it looks good, switch to Agent mode and prompt:

    “Apply the exact plan we just approved. Only edit the files listed. Do not touch anything else.”
    → This keeps the context tiny.

  6. Stage the AI‑generated changes in LazyGit or Terminal.

  7. Commit (c) and Push (P).


5. Summary CheatSheet

What you want to do Use this Token cost
Browse/rename/move/delete files IDE Explorer (mouse) 0
Bulk file moves Terminal (commands) 0
See Git changes, stage, commit LazyGit (or CLI) 0
“Explain this code to me” Ask mode Low
“Make a plan to fix imports after a move” Plan mode Low
“Execute that plan and edit the files” Agent mode (with explicit file list) Medium
“Fix everything everywhere without telling me” Agent mode (vague) High – Avoid

6. Checklist - Before AI Requests

  • [ ] Have I made the file moves/renames manually?
  • [ ] Have I staged my changes in Git?
  • [ ] Am I using Ask for questions, Plan for roadmaps, and Agent only for execution?
  • [ ] Have I told the AI which specific files/folders to look at?

This approach keeps your token usage low, your wallet happy, and your workflow efficient!


This project captures ideas, decisions, and lessons I’ve learned while building with AI. It aims to help non-technical users understand and use these tools effectively. I also use AI at times to improve or refine the content.

Readers should use the commands and instructions here with care. The creator accepts no responsibility for system damage, data loss or other consequences resulting from their use.

« PrevNext »