jahala/tilth

Smart(er) code reading for humans and AI agents. Reduces cost per correct answer by ~40% on average. Install: cargo install tilth -or- npx tilth

What it solves

It reduces the high cost and inefficiency of AI agents reading code. Instead of making multiple tool calls (like globbing, reading entire files, and grepping) to find a specific function or understand a call chain, tilth provides structural awareness in a single call, significantly lowering token usage and increasing accuracy.

How it works

Tilth combines ripgrep for fast searching, tree-sitter for AST parsing across 16 languages, and memory-mapped file reads for speed. It analyzes code structurally rather than just as text, allowing it to:

  • Outline large files: Automatically provides a structural summary of large files instead of the full content to save tokens.
  • Find definitions: Prioritizes where symbols are defined over where they are simply mentioned.
  • Trace call chains: Includes a "callee footer" in search results so agents can follow function calls without new searches.
  • Structural Diffing: Detects changes at the function level rather than the line level.
  • MCP Integration: Acts as a Model Context Protocol (MCP) server, allowing AI agents (like Claude Code or Cursor) to use these structural tools directly.

Who it’s for

  • AI agents and LLM-based coding assistants that need to navigate large codebases efficiently.
  • Developers who want a fast, structural CLI tool for exploring code definitions, dependencies, and call sites.

Highlights

  • Cost Reduction: Benchmarks show a 38-44% reduction in cost per correct answer across various models.
  • Structural Search: Uses tree-sitter to find actual definitions and call sites, not just string matches.
  • Smart Outlining: Switches between full content and structural outlines based on token count (~6000 tokens).
  • Broad Language Support: Supports 16 languages including Rust, TypeScript, Python, Go, and Java.
  • Hash-Anchored Editing: An optional edit mode that uses hashes to ensure edits are applied to the correct version of the code.

Related

  • Project
  • Project
  • Project
  • Project
  • Project