3 Essential Tools for Saving AI Tokens in Development
When working with AI coding assistants like Claude Code, GitHub Copilot, or Cursor, token consumption can quickly become a significant cost factor. Every command output, file read, and code snippet sent to the AI model consumes tokens—and those costs add up fast.
I've been using three game-changing tools that dramatically reduce token usage while maintaining (or even improving) AI accuracy. These tools have helped me save 60-90% on token costs across my development workflow.
1. RTK (Rust Token Killer) - The CLI Output Optimizer
GitHub: https://github.com/rtk-ai/rtk
What It Does
RTK is a high-performance CLI proxy that filters and compresses command outputs before they reach your AI assistant. It achieves 60-90% token savings on common development operations through smart filtering, grouping, truncation, and deduplication.
Key Features
- Smart Output Filtering: Removes noise like comments and unnecessary whitespace
- Intelligent Grouping: Organizes files by directory, errors by type
- Context Preservation: Truncates while keeping relevant information
- Deduplication: Collapses repeated log lines with occurrence counts
- Wide Command Support: Git, Docker, testing frameworks, build tools, AWS CLI, and more
Installation
# Homebrew (Recommended)
brew install rtk
# Quick Install (Linux/macOS)
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
# Cargo
cargo install --git https://github.com/rtk-ai/rtk
Setup
# Initialize for your AI tool
rtk init -g # Claude Code / Copilot (default)
rtk init -g --gemini # Gemini CLI
rtk init --agent cursor # Cursor
After setup, RTK automatically rewrites your commands. For example, git status becomes rtk git status transparently.
Real-World Impact
In a typical 30-minute coding session, RTK reduces approximately 118,000 tokens to 23,900 tokens—an 80% reduction! Individual operations show even higher savings:
cargo test: 90% token reductiongit add/commit/push: 92% token reduction
Check Your Savings
# Show token savings analytics
rtk gain
# Show command usage history with savings
rtk gain --history
# Analyze missed optimization opportunities
rtk discover
2. Tilth - Smart Code Reading for AI Agents
GitHub: https://github.com/jahala/tilth
What It Does
Tilth is a structural code navigation tool that combines ripgrep, tree-sitter, and intelligent content filtering to deliver only relevant code context to your AI assistant. It reduces token consumption while improving accuracy by providing precise, definition-first results.
Key Features
- Structural Search: Uses tree-sitter AST parsing to find where symbols are actually defined
- Smart Content Filtering: Shows full files under ~6000 tokens, generates structural outlines for larger files
- Callee Resolution: Includes resolved function calls with file locations and signatures
- Structural Diff: Function-level change detection for AI-driven code reviews
- Multi-Language Support: Supports 14 programming languages including Rust, TypeScript, Python, Go, Java, and C++
Performance Metrics
Benchmarks across 160 test runs show impressive results:
- 44% cost reduction on Claude Sonnet (84% → 94% accuracy)
- 39% cost reduction on Claude Opus
- 38% cost reduction on Claude Haiku (54% → 73% accuracy)
Installation
# Binary Installation
cargo install tilth
# NPX (no installation required)
npx tilth
MCP Server Setup
# Install as MCP server for your IDE
tilth install claude-code # Claude Desktop
tilth install cursor # Cursor IDE
tilth install vscode # VS Code
# Add --edit flag for hash-anchored file editing
tilth install claude-code --edit
Use Cases
- Code Navigation: Retrieve specific functions without reading entire files
- Symbol Tracing: Find definitions, usages, and callers across codebases
- Diff Review: Analyze function-level changes in pull requests
- Context Engineering: Provide AI agents precise code snippets, reducing token waste
3. Serena - AI-Powered Code IDE Toolkit
GitHub: https://github.com/oraios/serena
What It Does
Serena functions as an integrated development environment for AI coding agents, providing semantic code retrieval, editing, and refactoring capabilities via the Model Context Protocol (MCP). It replaces manual, error-prone text operations with atomic, IDE-like operations.
Core Features
Retrieval & Navigation
- Symbol-level code discovery across large codebases
- File outlines and cross-reference finding
- Dependency analysis
Refactoring Tools
- Precise renaming operations (symbols, files, directories)
- Safe deletion with unused code detection
- Inline refactoring capabilities
Editing Functions
- Symbol body replacement
- Strategic insertion before/after symbols
- Regex-based content searching and replacement
Token Efficiency
Serena dramatically reduces token consumption by collapsing complex multi-step operations into single atomic calls. Tasks that would normally cost "8–12 careful, error-prone steps" become one efficient operation.
Rather than reading entire files or performing fragile search-and-replace operations, AI agents leverage IDE-like semantic understanding to make precise, contextual changes efficiently.
Installation
uv tool install -p 3.13 serena-agent@latest --prerelease=allow
serena init
Configuration requires connecting to your MCP client (Claude Code, Codex, Claude Desktop, or compatible IDEs).
Use Cases
- Large codebase refactoring and maintenance
- Cross-file symbol renaming and moving
- Monorepo navigation and dependency management
- Long-lived agent workflows requiring consistent code understanding
How These Tools Work Together
The beauty of these tools is how they complement each other:
- RTK optimizes the output of every CLI command, reducing the tokens needed to communicate terminal results to your AI assistant
- Tilth provides smart code reading capabilities, ensuring the AI only sees relevant code context instead of entire files
- Serena enables semantic code operations, replacing multi-step manual editing with single atomic operations
Together, they create a highly optimized workflow that can reduce your AI token costs by 60-90% while actually improving the accuracy and reliability of AI-generated code.
Real-World Configuration: My Claude Code Setup
To show you how these tools work together in practice, here's my actual Claude Code settings.json configuration that integrates RTK, Tilth, and Serena:
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [
"Bash(cat:*)",
"Bash(curl:*)",
"Bash(diff:*)",
"Bash(echo:*)",
"Bash(find:*)",
"Bash(gh:*)",
"Bash(git:*)",
"Bash(grep:*)",
"Bash(head:*)",
"Bash(ls:*)",
"Bash(pwd)",
"Bash(tail:*)",
"Bash(tree:*)",
"Bash(wc:*)",
"Bash(which:*)",
"Bash(php-cs-fixer:*)",
"Bash(php:*)",
"Bash(phpstan:*)",
"Bash(phpunit:*)",
"Bash(symfony:*)",
"Bash(rtk:*)",
"mcp__serena__*",
"mcp__tilth__*"
],
"deny": [
"Bash(rm:*)",
"Read(./.env)",
"Read(./.env.*)",
"Read(./config/secrets/.*)",
"Read(./secrets/**)"
],
"defaultMode": "acceptEdits"
},
"alwaysThinkingEnabled": true,
"enabledPlugins": {
"gopls-lsp@claude-plugins-official": true
},
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "rtk hook claude"
}
]
}
]
}
}
Configuration Breakdown
1. Permissions Setup
The permissions.allow section explicitly whitelists the tools I use:
- Standard Bash Commands: Common Unix utilities like
cat,grep,git, etc. - RTK Integration:
Bash(rtk:*)allows RTK to proxy all commands - MCP Servers:
mcp__serena__*andmcp__tilth__*enable Serena and Tilth operations - Language Tools: PHP, Symfony, and Go-specific tooling for my projects
2. Security Boundaries
The permissions.deny section protects sensitive files:
- Blocks destructive
rmcommands - Prevents reading
.envfiles and secrets directories - Ensures Claude can't accidentally expose credentials
3. RTK Hook Integration
The most critical part is the hooks section:
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "rtk hook claude"
}
]
}
]
}
This configuration tells Claude Code to run rtk hook claude before every Bash command. RTK intercepts the command, optimizes its output, and returns the filtered result—achieving 60-90% token savings automatically.
4. Enhanced Features
- alwaysThinkingEnabled: Shows Claude's reasoning process
- defaultMode: "acceptEdits": Automatically accepts file edits (adjust based on your trust level)
- enabledPlugins: Activates language-specific plugins like
gopls-lspfor better Go support
Setting Up Your Own Configuration
To create a similar setup:
- Locate your Claude Code settings file (usually at
~/.config/claude-code/settings.json) - Install RTK, Tilth, and Serena using the installation commands above
- Add MCP server permissions:
mcp__serena__*andmcp__tilth__* - Configure the RTK pre-hook to intercept all Bash commands
- Customize the
allowanddenylists for your security requirements
This configuration creates a seamless, token-optimized workflow where:
- Every CLI command is automatically filtered by RTK
- Code reading operations use Tilth's structural navigation
- Refactoring operations leverage Serena's semantic tools
- Sensitive files remain protected
My Personal Experience
Since adopting these tools in my development workflow, I've noticed:
- Significant cost savings: My monthly AI token costs have dropped by approximately 70%
- Faster iterations: Less token overhead means faster response times
- Better accuracy: Focused context leads to more accurate AI suggestions
- Cleaner interactions: Less noise in the AI context window means clearer communication
Getting Started
If you're new to these tools, I recommend starting with RTK first—it's the easiest to set up and provides immediate, measurable savings. Once you're comfortable with RTK, add Tilth for improved code reading, and finally integrate Serena for advanced refactoring workflows.
All three tools are open source, actively maintained, and integrate seamlessly with popular AI coding assistants like Claude Code, GitHub Copilot, and Cursor.
Conclusion
As AI coding assistants become more central to our development workflows, optimizing token usage isn't just about saving money—it's about building more efficient, sustainable development practices. RTK, Tilth, and Serena represent the cutting edge of AI token optimization, and they're tools that every serious developer using AI assistance should consider.
Give them a try and watch your token costs drop while your productivity soars!