<< Home | Tech
Saves ~80% tokens per code search
| Area | Tech |
| AI used | Claude Code |
| Source | r/AI_Agents |
| Posted | 2026-04-14 |
The move
Configure Claude Code to use Language Server Protocol (LSP) instead of Grep for code navigation.Steps
- Ensure Claude Code is updated to the latest version.
- Identify the configuration file for your Claude Code environment.
- Add hooks to prioritize LSP over Grep for navigation tasks.
- Verify the agent is using LSP by checking the token usage logs.
Prompt for your AI
Configure your search behavior to prioritize Language Server Protocol (LSP) for all 'Go to Definition' and 'Find References' tasks. Avoid using Grep for code navigation to minimize token consumption.
What happened
Claude Code typically uses Grep for file searching, which often reads unnecessary files and consumes excessive tokens. By forcing the agent to use LSP, it retrieves precise code references instead of broad text matches. This change reduces context usage from approximately 6,500 tokens to 600 tokens per search.Watch out
Older versions of Claude Code may not support these hooks correctly. Incorrect configuration could lead to failed code lookups.Give it to your agent
Read https://howtheyuse.ai/p/saves-80-tokens-per-code-search.md and help me do this.