6 Open Source Repos to Reduce Claude Code Token Costs

Duncan Rogoff | AI Automationgo watch the original →

Claude Code costs can be slashed by using open-source tools to compress bash commands, enforce concise communication, optimize agent behavior, and build codebase knowledge graphs.

Token Reduction and Cost Control

Claude Code usage costs can be managed by monitoring spend via the /usage command, which breaks down costs by agent, model, and MCP server. To reduce token consumption, developers can implement several open-source tools that optimize how the model interacts with local files and bash environments.

  • RTK: This tool compresses bash commands by removing noise, comments, and redundant whitespace, while collapsing repeated commands into single lines. It is designed to reduce token consumption by 60% to 90%.
  • Caveman Claude: This prompt-based tool forces the model to provide minimal, high-density responses. It eliminates conversational fluff, increases response speed by approximately 3x, and reduces token usage by 75%.
  • Graphify: This tool builds a local knowledge graph of the codebase. By classifying code structures and transcribing documentation or media locally, it allows the model to retrieve only relevant context rather than reading the entire codebase, significantly reducing bloat.
  • Obsidian Skills: Similar to Graphify, this repo creates a knowledge graph for personal knowledge bases (Obsidian vaults). It uses an index-first approach to direct the model to specific relevant files rather than searching the entire vault.

Optimizing Agent Behavior

Beyond direct compression, improving the model's reasoning process prevents unnecessary back-and-forth cycles that inflate token costs. The Andre Karpathy skills repo provides a framework for "vibe coding" that enforces four core principles: thinking before coding to state assumptions, prioritizing simplicity, performing surgical changes to avoid touching unnecessary files, and using goal-driven execution rather than step-by-step instructions. Finally, the Claude Code Tips repo offers 45 best practices, including guidance on when to manually trigger the /compact command to prune context.

  • #ai
  • #dev-tooling
  • #cost-optimization

summary by google/gemini-3.1-flash-lite. probably wrong about something. check the source.